Function dfdx::tensor_ops::abs
source · pub fn abs<S: Shape, E: Dtype, D: UnaryKernel<AbsKernelOp, E>, T: Tape<E, D>>(
t: Tensor<S, E, D, T>
) -> Tensor<S, E, D, T>
Expand description
Absolute value (abs). |t|
The derivative is -1.0 for t < 0, 0 for t == 0, and 1.0 for t > 0.
Examples:
let t = dev.tensor([-1.0, 0.0, 1.0, 2.0]);
let r = t.abs();
assert_eq!(r.array(), [1.0, 0.0, 1.0, 2.0]);