Universal Functions (ufunc)

CuPy provides universal functions (a.k.a. ufuncs) to support various elementwise operations. CuPy’s ufunc supports following features of NumPy’s one:

  • Broadcasting
  • Output type determination
  • Casting rules

CuPy’s ufunc currently does not provide methods such as reduce, accumulate, reduceat, outer, and at.

Ufunc class

class cupy.ufunc

Universal function.

Variables:
  • name (str) – The name of the universal function.
  • nin (int) – Number of input arguments.
  • nout (int) – Number of output arguments.
  • nargs (int) – Number of all arguments.
types

A list of type signatures.

Each type signature is represented by type character codes of inputs and outputs separated by ‘->’.

ufunc.at

Currently, CuPy does not support at for ufuncs in general. However, cupy.scatter_add() can substitute add.at as both behave identically.