mode – controlling compilation

Guide

The mode parameter to theano.function() controls how the inputs-to-outputs graph is transformed into a callable object.

Theano defines the following modes by name:

  • 'FAST_COMPILE': Apply just a few graph optimizations and only use Python implementations.
  • 'FAST_RUN': Apply all optimizations, and use C implementations where possible.
  • 'DebugMode': A mode for debuging. See DebugMode for details.
  • 'ProfileMode': Deprecated, use the Theano flag config.profile.
  • 'DEBUG_MODE': Deprecated. Use the string DebugMode.
  • 'PROFILE_MODE': Deprecated. Use the string ProfileMode.

The default mode is typically FAST_RUN, but it can be controlled via the configuration variable config.mode, which can be overridden by passing the keyword argument to theano.function().

Todo

For a finer level of control over which optimizations are applied, and whether C or Python implementations are used, read.... what exactly?

Reference

mode.FAST_COMPILE
mode.FAST_RUN
class mode.Mode(object)

Compilation is controlled by two attributes: the optimizer controls how an expression graph will be transformed; the linker controls how the optimized expression graph will be evaluated.

optimizer

An optimizer instance.

linker

A linker instance.

including(*tags)

Return a new Mode instance like this one, but with an optimizer modified by including the given tags.

excluding(*tags)

Return a new Mode instance like this one, but with an optimizer modified by excluding the given tags.

requiring(*tags)

Return a new Mode instance like this one, but with an optimizer modified by requiring the given tags.