mindspore.ops.csr_inv
- mindspore.ops.csr_inv(x: CSRTensor)[source]
Computes Reciprocal of input CSRTensor element-wise.
\[out_i = \frac{1}{x_{i} }\]- Parameters
x (CSRTensor) – Input CSRTensor. Must be one of the following types: float16, float32 or int32.
- Returns
CSRTensor, has the same type and shape as input shape value.
- Raises
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> indptr = Tensor([0, 1, 2, 2], dtype=mstype.int32) >>> indices = Tensor([3, 0], dtype=mstype.int32) >>> values = Tensor([-1, 2], dtype=mstype.float32) >>> shape = (3, 4) >>> x = CSRTensor(indptr, indices, values, shape) >>> output = ops.csr_inv(x) >>> print(output.values) [-1. 0.5]