mindspore.ops.cross

mindspore.ops.cross(input, other, dim=None)[source]

Returns the cross product of vectors in dimension dim of input input and other. input and other must have the same shape and the same type, and the size of their dim dimension should be 3. If dim is not given, it defaults to the first dimension found with the size 3.

Parameters
  • input (Tensor) – input is a tensor.

  • other (Tensor) – The other Tensor, other must have the same shape and type as input input, and the size of their dim dimension should be 3.

  • dim (int) – dimension to apply cross product in. Default: None.

Returns

Tensor, has the same shape and type as input input.

Raises
  • TypeError – If input is not a Tensor.

  • TypeError – If other is not a Tensor.

  • TypeError – If the type of input is not the same as that of other.

  • ValueError – If input and other not have the same size, and the size of their dim dimension not be 3.

  • ValueError – If input and other not have the same shape.

  • ValueError – If dim is out of range, dim should be [-len(input.shape), len(input.shape)-1].

Supported Platforms:

CPU

Examples

>>> x = Tensor([1, 2, 3], mstype.int8)
>>> other = Tensor([1, 2, 3], mstype.int8)
>>> output = ops.cross(x, other)
>>> print(output)
[0 0 0]