mindspore.ops.cross
- mindspore.ops.cross(input, other, dim=None)[源代码]
按指定维度计算两个输入tensor的叉积。
说明
input 和 other 必须有相同的shape,且指定的 dim 上size必须为3。 如果不指定 dim ,则使用第一个size为3的维度。
- 参数:
input (Tensor) - 第一个输入tensor。
other (Tensor) - 第二个输入tensor。
dim (int,可选) - 指定计算维度。默认
None
。
- 返回:
Tensor
- 支持平台:
Ascend
CPU
样例:
>>> import mindspore >>> input = mindspore.tensor([[1, 2, 3], [1, 2, 3], [1, 2, 3]]) >>> other = mindspore.tensor([[4, 5, 6], [4, 5, 6], [4, 5, 6]]) >>> mindspore.ops.cross(input, other) Tensor(shape=[3, 3], dtype=Int64, value= [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) >>> mindspore.ops.cross(input, other, dim=1) Tensor(shape=[3, 3], dtype=Int64, value= [[-3, 6, -3], [-3, 6, -3], [-3, 6, -3]])