pytaco.cube

pytaco.cube(e1)

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

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

Parameters
e1: index_expression

Input index expression

Returns
cube_exp: index_expression

An index expression representing the element wise cube of the input expression.

Examples

The code below tells taco to compute the cube of each value, sum over all the j indices and store the result in res_t. Since j appears on the right hand side of the expression but not on the left, taco will take the sum of the values over the dimension indexed by j.

>>> import pytaco as pt
>>> t = pt.as_tensor([[-2, 2, 1], [2, 3, 1]])
>>> i, j = pt.get_index_vars(2)
>>> res_t = pt.tensor([t.shape[0]])
>>> res_t[i] = pt.cube(t[i, j])
>>> res_t.to_array()
array([ 1., 36.], dtype=float32)