Return the element-wise absolute value of the index expression.

This must be assigned to a tensor for the computation to be performed.

e1: index_expression

Input index expression

abs_exp: index_expression

An index expression representing the element wise absolute value of its inputs.


>>> import pytaco as pt
>>> t = pt.as_tensor([-2, 0, 1])
>>> i = pt.index_var()
>>> abs_expr = pt.abs(t[i])

We can then assign this description to a tensor to actually perform the computation

>>> res_t = pt.tensor([3])
>>> res_t[i] = abs_expr
>>> res_t.to_array()
array([2., 0., 1.], dtype=float32)

The above tells taco to compute the absolute value expression and store it in the tensor res_t keeping the dimension since i is specified in both the right hand side and the left hand side of the expression.