mindspore.ops.ger

mindspore.ops.ger(x1, x2)[source]

Ger product of x1 and x2. Calculate the outer product of two arrays. If x1 is a 1D Tensor of shape \((m,)\) and x2 is a 1D Tensor of shape \((n,)\), then output must be a 2D Tensor of shape \((m, n)\).

Note

Currently Ascend does not support float64 data input.

Parameters
  • x1 (Tensor) – input Tensor, with dtype of float16, float32 or float64.

  • x2 (Tensor) – input Tensor, with dtype of float16, float32 or float64, must have the same dtype as x1.

Returns

Tensor, output matrix with the same dtype as inputs. With x1 shape \((m,)\) and x2 shape of \((n,)\), the output has shape \((m, n)\).

Raises
  • TypeError – If x1 or x2 is not a 1-D Tensor.

  • TypeError – If the dtype of x1 and x2 is not float16, float32 or float64.

  • TypeError – If the dtype of x1 and x2 are not the same.

Supported Platforms:

Ascend GPU CPU

Examples

>>> x1 = Tensor([1., 2., 3., 4.], mindspore.float32)
>>> x2 = Tensor([1., 2., 3.], mindspore.float32)
>>> output = ops.ger(x1, x2)
>>> print(output)
[[ 1.  2.  3.]
 [ 2.  4.  6.]
 [ 3.  6.  9.]
 [ 4.  8. 12.]]