theano.sandbox.gpuarray.type – Type classes

class theano.sandbox.gpuarray.type.GpuArrayConstant(type, data, name=None)

A constant representing a value on a certain GPU.

This supports all the operations that TensorType supports.

See also

Constant

class theano.sandbox.gpuarray.type.GpuArraySharedVariable(name, type, value, strict, allow_downcast=None, container=None)

A variable representing a shared value on a certain GPU.

This supports all the operations that TensorType supports.

See also

SharedVariable

class theano.sandbox.gpuarray.type.GpuArrayType(dtype, broadcastable, context_name=None, name=None)

The type that represents an array on a gpu.

The dtype indicates what scalar data type the elements of variables of this type will be.

broadcastable indicates whether each dimension is broadcastable or not (to be broadcastable a dimension must always be of length 1).

The context_name is the name of the context on will values of variables of this type will be stored.

Parameters:
  • dtype (str) – The name of a numpy dtype
  • broadcastable (tuple of bools) – A tuple that indicates both the number of dimensions (by its length) and whether those dimensions are broadcastable or not (by the boolean values).
  • context_name (str) – The name of the context the that this type is attached to (default: None, which is the context specified by config.device).
  • name (string, optional) – A name for the type that will be used in printouts.
dtype

str

Data type used for scalar elements of variables.

broadcastable

tuple of bools

Indicates whether the dimensions are broadcastable or not.

ndim

int

The number of dimensions

context_name

str

The name of a gpu context on which variables will have their values.

name

str

A string used to print the type if given.

typecode

int

The gpuarray typecode for dtype

Constant

alias of GpuArrayConstant

SharedVariable

alias of GpuArraySharedVariable

Variable

alias of GpuArrayVariable

context

The context object mapped to the type’s context_name. This is a property.

dtype_specs()

Return a tuple (python type, c type, numpy typenum) that corresponds to self.dtype.

This function is used internally as part of C code generation.

class theano.sandbox.gpuarray.type.GpuArrayVariable(type, owner=None, index=None, name=None)

A variable representing a computation on a certain GPU.

This supports all the operations that TensorType supports.

See also

Variable

class theano.sandbox.gpuarray.type.GpuContextType

Minimal type used for passing contexts to nodes.

This Type is not a complete type and should never be used for regular graph operations.

theano.sandbox.gpuarray.type.get_context(name)

Retrive the context associated with a name.

Return the context object mapped to ref that was previously register through reg_context(). Trying to get the context for an unregistered ref will raise a exception.

Parameters:name (hashable object) – Name associated with the context we want (usually a string)
theano.sandbox.gpuarray.type.gpuarray_shared_constructor(value, name=None, strict=False, allow_downcast=None, borrow=False, broadcastable=None, target=None)

SharedVariable constructor for GpuArrayType.

See theano.shared().

theano.sandbox.gpuarray.type.list_contexts()

Return an iterable of all the registered context names.

theano.sandbox.gpuarray.type.reg_context(name, ctx)

Register a context by mapping it to a name.

The context must be of type GpuContext and the name can be anything hashable (but is usually a string). Only one context can be registered per name and the second registration for a given name will raise an error.

Parameters:
  • name (hashable object) – Name to associate the context with (usually a string)
  • ctx (GpuContext) – Context instance