Extra operators

class stride.utils.operators.Add(*args, **kwargs)[source]

Bases: Operator

adjoint(d_sum, a, b, **kwargs)[source]

Method defining the adjoint behaviour of the operator. This method needs to be defined by classes inheriting from the operator.

The method will be called with positional arguments comprised of: the gradients of every output of the forward operation, followed by the arguments originally given when calling the forward method.

The adjoint method needs to return a gradient for each of its Variable inputs (or None if the variable does not needs_grad).

This method should not be called directly from user code.

Parameters:
  • args

  • kwargs

forward(a, b, **kwargs)[source]

Method defining the forward behaviour of the operator. This method needs to be defined by classes inheriting from the operator.

The method can take multiple inputs and produce multiple outputs. Outputs of this method should be of type Variable.

Positional and keyword arguments to forward are processed so that present variables are tracked.

This method should not be called directly from user code.

Parameters:
  • args

  • kwargs

class stride.utils.operators.Concatenate(*args, **kwargs)[source]

Bases: Operator

Concatenate multiple StructuredData objects.

Parameters:
  • start_end (2d-array, optional) – Array containing start and end indices pointing to each objects’ position in the concatenated object. Shape should be (num_objects, 2)

  • new_axis (bool, optional) – Whether to concatenate on a new axis. Defaults to False.

  • axis (int, optional) – Axis to perform the concatenation. Defaults to 0.

async adjoint(d_concat, *args, **kwargs)[source]

Method defining the adjoint behaviour of the operator. This method needs to be defined by classes inheriting from the operator.

The method will be called with positional arguments comprised of: the gradients of every output of the forward operation, followed by the arguments originally given when calling the forward method.

The adjoint method needs to return a gradient for each of its Variable inputs (or None if the variable does not needs_grad).

This method should not be called directly from user code.

Parameters:
  • args

  • kwargs

build_start_end(args)[source]

Build start and end indices from the Sequence of StructuredData objects.

Parameters:

args (Sequence[StructuredData]) – Sequence of StructuredData objects to be combined.

property comms
async forward(*args, **kwargs)[source]
Parameters:
  • args (Sequence[StructuredData]) – Sequence of StructuredData objects to be combined.

  • start_end (2d-array, optional) – Array containing start and end indices pointing to each objects’ position in the concatenated object. Shape should be (num_objects, 2)

  • axis (int, optional) – The axis to concatenate on. Defaults to 0.

  • new_axis (bool, optional) – Whether to create a new axis when concatenating, or maintain the dimensions. Defaults to False.

Returns:

Concatenated data as a single StructuredData object.

Return type:

StructuredData

property head
classmethod local(*args, uid=None, **kwargs)
classmethod local_parameter(*args, uid=None, **kwargs)
property logger
property loop
property monitor
property node
classmethod parameter(*args, uid=None, **kwargs)
classmethod remote(*args, **kwargs)
property runtime
async classmethod select_worker(runtime=None)

Select an available worker.

Parameters:

runtime (str or Runtime, optional) – If a valid runtime is given, this will be selected as the target worker.

Returns:

UID of the target worker.

Return type:

str

property worker
property zmq_context
class stride.utils.operators.Mul(*args, **kwargs)[source]

Bases: Operator

adjoint(d_mul, a, b, **kwargs)[source]

Method defining the adjoint behaviour of the operator. This method needs to be defined by classes inheriting from the operator.

The method will be called with positional arguments comprised of: the gradients of every output of the forward operation, followed by the arguments originally given when calling the forward method.

The adjoint method needs to return a gradient for each of its Variable inputs (or None if the variable does not needs_grad).

This method should not be called directly from user code.

Parameters:
  • args

  • kwargs

forward(a, b, **kwargs)[source]

Method defining the forward behaviour of the operator. This method needs to be defined by classes inheriting from the operator.

The method can take multiple inputs and produce multiple outputs. Outputs of this method should be of type Variable.

Positional and keyword arguments to forward are processed so that present variables are tracked.

This method should not be called directly from user code.

Parameters:
  • args

  • kwargs