nabu.processing.processing_base module

class nabu.processing.processing_base.ProcessingBase[source]

Bases: object

array_class = None
dtype_to_ctype

alias of BaseClassError

init_arrays_to_none(arrays_names)[source]

Initialize arrays to None. After calling this method, the current instance will have self.array_name = None, and self._old_array_name = None.

Parameters:

arrays_names (list of str) – List of arrays names.

recover_arrays_references(arrays_names)[source]

Performs self._array_name = self._old_array_name, for each array_name in arrays_names.

Parameters:

arrays_names (list of str) – List of array names

allocate_array(array_name, shape, dtype=<class 'numpy.float32'>)[source]

Allocate a GPU array on the current context/stream/device, and set ‘self.array_name’ to this array.

Parameters:
  • array_name (str) – Name of the array (for book-keeping)

  • shape (tuple of int) – Array shape

  • dtype (numpy.dtype, optional) – Data type. Default is float32.

set_array(array_name, array_ref, dtype=<class 'numpy.float32'>)[source]

Set the content of a device array.

Parameters:
  • array_name (str) – Array name. This method will look for self.array_name.

  • array_ref (array (numpy or GPU array)) – Array containing the data to copy to ‘array_name’.

  • dtype (numpy.dtype, optional) – Data type. Default is float32.

get_array(array_name)[source]
check_array(arr, expected_shape, expected_dtype='f', check_contiguous=True)[source]

Check whether a given array is suitable for being processed (shape, dtype, contiguous)

kernel(*args, **kwargs)[source]
to_device(array_name, array)[source]