pytaco.tensor_heaviside

pytaco.tensor_heaviside(t1, t2, out_format, dtype=None)

Computes the element wise heaviside step function of two tensors.

This is defined as:

  • 0 if t1 < 0

  • t2 if t1 == 0

  • 1 if t1 > 0

Also note:

  • If the two tensors are equal order, performs the operation element-wise

  • If the two tensors have order N and M and N > M, requires the last M dimensions of the tensor with order N be equal to the dimensions of the tensor with order M in order to broadcast.

Parameters
t1, t2: tensors, array_like

tensors or array_like input operands.

out_format: format, mode_format
  • If a format is specified, the result tensor is stored in the format out_format.

  • If a mode_format is specified, the result the result tensor has a with all of the dimensions stored in the mode_format passed in.

dtype: Datatype, optional

The datatype of the output tensor.

Returns
heaviside: tensor

The element wise heaviside step function of the input tensors broadcasted as required.

Notes

The inner dimensions of the input tensor is broadcasted along the dimensions of whichever tensor has a higher order.

Examples

>>> import pytaco as pt
>>> pt.tensor_heaviside([0, 0.5, 6], [0.5, 10, 10], pt.dense).to_array()
array([0.5, 1. , 1. ])