copapy.Target#

class copapy.Target(arch='native', optimization='O3')#

Bases: _LocalMemory

Target device for compiling for and running on copapy code.

Initialize Target object

Parameters:
  • arch (str) – Target architecture

  • optimization (str) – Optimization level

buffer(variable)#

Returns memory of an array on the target as memoryview.

Only available for the local target. All buffers must be released or deleted before a new program is compiled on the same target.

Parameters:

variable (array[Any]) – Array-variable to get the memory of

Return type:

memoryview[Any]

Returns:

Writable memoryview of the array memory

compile(*values)#

Compiles the code to compute the given values.

Parameters:

values (Any) – Values, vectors, tensors and arrays to compute, also in (nested) sequences or as values of dicts

Return type:

None

read_value(variables)#

Reads the numeric value of a copapy type.

Overloads:
  • variables (value[T]) → T

  • variables (value[int] | value[float] | int | float) → float | int | bool

  • variables (ArrayType[T]) → ArrayType[T]

  • variables (Iterable[T | value[T]]) → list[T]

  • variables (array[T]) → Any

  • variables (Any) → Any

Parameters:

variables (Any) – Variable or multiple variables to read

Returns:

Numeric value or values. Arrays are returned as nested lists, arrays marked with map_to_buffer or map_to_numpy as memoryview or numpy array. Sequences and dicts are returned as lists and dicts of the values of their items.

read_value_remote(variable)#

Reads the raw data of a value by the runner.

Return type:

None

run()#

Runs the compiled code on the target device.

Return type:

None

sdb: stencil_database#
write_value(variables, data)#

Write to a copapy value on the target.

Parameters:
  • variables (value[Any] | array[Any] | Iterable[value[Any]]) – Single variable, array or multiple variables to overwrite

  • value – Single value or multiple values to write, (nested) sequences for arrays

Return type:

None