Code Generation

loopy Target

pytato.generate_loopy(result, target=None, options=None, *, cl_device=None)[source]

Code generation entry point.

Parameters
Return type

BoundProgram

Returns

A pytato.target.BoundProgram wrapping the generated loopy program.

If result is a dict or a pytato.DictOfNamedArrays and options is not supplied, then the Loopy option return_dict will be set to True.

class pytato.target.loopy.LoopyTarget[source]

An loopy target.

get_loopy_target()[source]

Return the corresponding loopy target.

Return type

TargetBase

class pytato.target.loopy.LoopyPyOpenCLTarget(device=None)[source]

A pyopencl code generation target.

device

The pyopencl device used to construct the loopy.PyOpenCLTarget, or None.

class pytato.target.loopy.BoundPyOpenCLProgram(program, bound_arguments, target)[source]

A wrapper around a loopy kernel for execution with pyopencl.

__call__(queue, *args, **kwargs)[source]

Convenience function for launching a pyopencl computation.

Return type

Any

Generic target support

Code Generation Targets

class pytato.target.Target[source]

An abstract code generation target.

bind_program(program, bound_arguments)[source]

Create a BoundProgram for this code generation target.

Parameters
  • program (Any) – the loopy program

  • bound_arguments (Mapping[str, Any]) – a mapping from argument names to outputs

Return type

BoundProgram

class pytato.target.BoundProgram(program, bound_arguments, target)[source]

A container for the result of code generation along with data bindings for already-bound arguments.

target

The code generation target.

program

Description of the program as per BoundProgram.target.

bound_arguments

A map from names to pre-bound kernel arguments.

__call__()[source]

It is expected that every concrete subclass of this class have a __call__ method to run the generated code, however interfaces may vary based on the specific subclass.