Subtraction (Sub)#

API#

class warp_nn.modules.operators.Sub(*, requires_grad: bool = True)[source]#

Bases: Module

Subtraction (Sub) operation.

This class computes the element-wise subtraction of two arrays:

\[\text{Sub}(a, b) = a - b\]
Parameters:

requires_grad – Whether the cached output arrays of the module require gradients.

__call__(
a: array,
b: array,
) → array[source]#

Forward pass of the operation.

Parameters:
  • a – The minuend array, with up to 3 dimensions.

  • b – The subtrahend array, with the same shape and data type as a.

Returns:

The output array, with same shape as the input arrays.

Raises:
  • ValueError – If the input arrays’ shapes differ.

  • TypeError – If the input arrays’ data types differ, or if their data type or number of dimensions is not supported.