brainpy.math.operators.XLACustomOp#

class brainpy.math.operators.XLACustomOp(eval_shape=None, con_compute=None, cpu_func=None, gpu_func=None, apply_cpu_func_to_gpu=False, name=None)[source]#

Creating a XLA custom call operator.

Parameters
  • name (str) – The name of operator.

  • eval_shape (callable) –

    The function to evaluate the shape and dtype of the output according to the input. This function should receive the abstract information of inputs, and return the abstract information of the outputs. For example:

    >>> def eval_shape(inp1_info, inp2_info, inp3_info, ...):
    >>>   return out1_info, out2_info
    

  • con_compute (callable) –

    The function to make the concrete computation. This function receives inputs, and returns outputs. For example:

    >>> def con_compute(inp1, inp2, inp3, ...):
    >>>   return out1, out2
    

  • cpu_func (callable) – The function defines the computation on CPU backend. Same as con_compute.

  • gpu_func (callable) – The function defines the computation on GPU backend. Currently, this function is not supportted.

  • apply_cpu_func_to_gpu (bool) – Whether allows to apply CPU function on GPU backend. If True, the GPU data will move to CPU, and after calculation, the returned outputs on CPU backend will move to GPU.

__init__(eval_shape=None, con_compute=None, cpu_func=None, gpu_func=None, apply_cpu_func_to_gpu=False, name=None)[source]#

Methods

__init__([eval_shape, con_compute, ...])

load_states(filename[, verbose])

Load the model states.

nodes([method, level, include_self])

Collect all children nodes.

register_implicit_nodes(*nodes, **named_nodes)

register_implicit_vars(*variables, ...)

save_states(filename[, variables])

Save the model states.

train_vars([method, level, include_self])

The shortcut for retrieving all trainable variables.

unique_name([name, type_])

Get the unique name for this object.

vars([method, level, include_self])

Collect all variables in this node and the children nodes.

Attributes

name

Name of the model.