gpuarray.type – Type classes

class theano.gpuarray.type.GpuArrayConstant(type, data, name=None)[source]

A constant representing a value on a certain GPU.

This supports all the operations that TensorType supports.

See also

Constant

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

A variable representing a shared value on a certain GPU.

This supports all the operations that TensorType supports.

See also

SharedVariable

class theano.gpuarray.type.GpuArrayType(dtype, broadcastable, context_name=None, name=None)[source]

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[source]

str – Data type used for scalar elements of variables.

broadcastable[source]

tuple of bools – Indicates whether the dimensions are broadcastable or not.

ndim[source]

int – The number of dimensions

context_name[source]

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

name[source]

str – A string used to print the type if given.

typecode[source]

int – The gpuarray typecode for dtype

Constant[source]

alias of GpuArrayConstant

SharedVariable[source]

alias of GpuArraySharedVariable

Variable[source]

alias of GpuArrayVariable

context[source]

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

dtype_specs()[source]

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.gpuarray.type.GpuArrayVariable(type, owner=None, index=None, name=None)[source]

A variable representing a computation on a certain GPU.

This supports all the operations that TensorType supports.

See also

Variable

class theano.gpuarray.type.GpuContextType[source]

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.gpuarray.type.get_context(name)[source]

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.gpuarray.type.gpuarray_shared_constructor(value, name=None, strict=False, allow_downcast=None, borrow=False, broadcastable=None, target=<object object>)[source]

SharedVariable constructor for GpuArrayType.

See theano.shared().

Target:default None The device target. As None is a valid value and we need to differentiate from the parameter notset and None, we use a notset object.
theano.gpuarray.type.list_contexts()[source]

Return an iterable of all the registered context names.

theano.gpuarray.type.move_to_gpu(data)[source]

Do we want to move this computation to the GPU?

Currently, we don’t move complex and scalar int.

Parameters:data (numpy.ndarray or TensorVariable) – (it must have dtype and ndim parameter)
theano.gpuarray.type.reg_context(name, ctx)[source]

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