mindspore.ops.dot
- mindspore.ops.dot(x1, x2)[source]
Computation a dot product between samples in two tensors.
- Inputs:
x1 (Tensor) - First tensor in Dot op with datatype float16 or float32 The rank must be greater than or equal to 2.
x2 (Tensor) - Second tensor in Dot op with datatype float16 or float32 The rank must be greater than or equal to 2.
- Outputs:
Tensor, dot product of x1 and x2.
- Raises
TypeError – If type of x1 and x2 are not the same.
TypeError – If dtype of x1 or x2 is not float16 or float32.
ValueError – If rank of x1 or x2 less than 2.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> input_x1 = Tensor(np.ones(shape=[2, 3]), mindspore.float32) >>> input_x2 = Tensor(np.ones(shape=[1, 3, 2]), mindspore.float32) >>> output = ops.dot(input_x1, input_x2) >>> print(output) [[[3. 3.]] [[3. 3.]]] >>> print(output.shape) (2, 1, 2) >>> input_x1 = Tensor(np.ones(shape=[1, 2, 3]), mindspore.float32) >>> input_x2 = Tensor(np.ones(shape=[1, 3, 2]), mindspore.float32) >>> output = ops.dot(input_x1, input_x2) >>> print(output) [[[[3. 3.]] [[3. 3.]]]] >>> print(output.shape) (1, 2, 1, 2) >>> input_x1 = Tensor(np.ones(shape=[1, 2, 3]), mindspore.float32) >>> input_x2 = Tensor(np.ones(shape=[2, 3, 2]), mindspore.float32) >>> output = ops.dot(input_x1, input_x2) >>> print(output) [[[[3. 3.] [3. 3.]] [[3. 3.] [3. 3.]]]] >>> print(output.shape) (1, 2, 2, 2) >>> input_x1 = Tensor(np.ones(shape=[3, 2, 3]), mindspore.float32) >>> input_x2 = Tensor(np.ones(shape=[2, 1, 3, 2]), mindspore.float32) >>> output = ops.dot(input_x1, input_x2) >>> print(output) [[[[[3. 3.]] [[3. 3.]]] [[[3. 3.]] [[3. 3.]]]] [[[[3. 3.]] [[3. 3.]]] [[[3. 3.]] [[3. 3.]]]] [[[[3. 3.]] [[3. 3.]]] [[[3. 3.]] [[3. 3.]]]]] >>> print(output.shape) (3, 2, 2, 1, 2)