mindspore.ops.sub
- mindspore.ops.sub(input, other)[source]
Subtract the second input from the first input element-wise.
Note
When the two inputs have different shapes, they must be able to broadcast to a common shape.
The two inputs can not be bool type at the same time, [True, Tensor(True, bool_), Tensor(np.array([True]), bool_)] are all considered bool type.
Support implicit type conversion and type promotion.
- Parameters
- Returns
Tensor
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore >>> input = mindspore.tensor([1, 2, 3], mindspore.int32) >>> other = mindspore.tensor([4, 5, 6], mindspore.int32) >>> output = mindspore.ops.sub(input, other) >>> print(output) [-3 -3 -3]