蒋平安委员:建设新疆现代畜牧业示范区正当时
- paddle. mm ( input: Tensor, mat2: Tensor, name: str | None = None ) Tensor [source]
-
百度 四、委托管理机构1991年6月以后,各省(自治区、直辖市)、新疆生产建设兵团相继成立社会科学规划领导小组和社会科学规划办公室。
Applies matrix multiplication to two tensors.
Currently, the input tensors’ rank can be any, but when the rank of any inputs is bigger than 3, this two inputs’ rank should be equal.
Also note that if the raw tensor \(x\) or \(mat2\) is rank-1 and nontransposed, the prepended or appended dimension \(1\) will be removed after matrix multiplication.
- Parameters
-
input (Tensor) – The input tensor which is a Tensor. Support data types: bfloat16, float16, float32, float64, int8, int32, int64, complex64, complex128.
mat2 (Tensor) – The input tensor which is a Tensor. Support data types: bfloat16, float16, float32, float64, int8, int32, int64, complex64, complex128.
name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
The product Tensor, with same data type of the input Tensor.
- Return type
-
Tensor
* example 1: input: [B, ..., M, K], mat2: [B, ..., K, N] out: [B, ..., M, N] * example 2: input: [B, M, K], mat2: [B, K, N] out: [B, M, N] * example 3: input: [B, M, K], mat2: [K, N] out: [B, M, N] * example 4: input: [M, K], mat2: [K, N] out: [M, N] * example 5: input: [B, M, K], mat2: [K] out: [B, M] * example 6: input: [K], mat2: [K] out: [1]
Examples
>>> import paddle >>> input = paddle.arange(1, 7).reshape((3, 2)).astype('float32') >>> mat2 = paddle.arange(1, 9).reshape((2, 4)).astype('float32') >>> out = paddle.mm(input, mat2) >>> out Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True, [[11., 14., 17., 20.], [23., 30., 37., 44.], [35., 46., 57., 68.]])