---
title: Strmm
description: "| 硬件型号 | 支持情况 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/SiP/SIP_API_0024.html
sourcePath: /source/zh/canncommercial/900/API/SiP/SIP_API_0024.html
indexId: 918a45278a2fc8470703cb0b80ae062efe938da284418456d7c84448e45fb94d55
---
# Strmm

#### 产品支持情况

| 硬件型号 | 支持情况 |
| --- | --- |
| Atlas 200I/500 A2 推理产品 | 不支持 |
| Atlas 推理系列产品 | 不支持 |
| Atlas 训练系列产品 | 不支持 |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | 支持 |
| Atlas A3 推理系列产品 / Atlas A3 训练系列产品 | 支持 |


#### 功能描述

接口功能

- asdBlasMakeStrmmPlan：初始化该句柄对应的Strmm算子配置。

- asdBlasStrmm：单精度，其功能是将一个三角矩阵A乘一个矩阵B，得到一个新的矩阵C。

计算公式

- asdBlasStrmm的计算公式：
- 示例：
  输入“A”为：

```
[   [ 1, 0 ],
[ 3, 4 ]  ]
```


  输入“B”为：

```
[   [ 1, 2 ],
[ 3, 4 ]  ]
```


  输入“side”为：L，“uplo”为：L，输入“trans”为：N，输入“diag”为：N。

  输入“n”为：2，输入“lda”为：2，输入“ldb”为：2，输入“ldc”为：2。

  输入“alpha”为：2.345。

  调用“Strmm”算子后，输出“C”为：

```
[  [ 2.3450,  4.6900],
[35.1750, 51.5900]  ]
```


#### 函数原型

- AspbStatus asdBlasMakeStrmmPlan(asdBlasHandle handle)
- AspbStatus asdBlasStrmm(asdBlasHandle handle, asdBlasSideMode_t side, asdBlasFillMode_t uplo, asdBlasOperation_t trans,asdBlasDiagType_t diag, const int64_t m, const int64_t n, const float *alpha, aclTensor *A,const int64_t lda, aclTensor *B, const int64_t ldb, aclTensor *C, const int64_t ldc)


#### 参数说明

- asdBlasMakeStrmmPlan| 参数名称 | Input/Output | 类型 | 描述 |
| --- | --- | --- | --- |
| handle | Input | asdBlasHandle | Strmm算子的句柄。 |


- asdBlasStrmm| 参数名称 | Input/Output | 类型 | 描述 |
| --- | --- | --- | --- |
| handle | Input | asdBlasHandle | Strmm算子的句柄。 |
| side | Input | asdBlasSideMode\_t | 指定矩阵A是乘法左侧还是右侧。 ASDBLAS\_SIDE\_LEFT // 左侧 ASDBLAS\_SIDE\_RIGHT // 右侧 |
| uplo | Input | asdBlasFillMode\_t | 指定矩阵A的存储方式。 ASDBLAS\_FILL\_MODE\_LOWER // 下三角 ASDBLAS\_FILL\_MODE\_UPPER // 上三角 |
| trans | Input | asdBlasOperation\_t | 指定是否对矩阵A进行转置。 ASDBLAS\_OP\_N // 不转置 ASDBLAS\_OP\_T // 转置 |
| diag | Input | asdBlasDiagType\_t | 指定是否假定矩阵A的对角线元素为1。 ASDBLAS\_DIAG\_NON\_UNIT // 不假定为1 ASDBLAS\_DIAG\_UNIT // 假定为1 |
| m | Input | const int64\_t | 矩阵B和C的行数。 |
| n | Input | const int64\_t | 矩阵B和C的列数。 |
| alpha | Input | const float \* | 公式中的alpha，用于计算矩阵乘法的系数。 |
| A | Input | aclTensor \* | 公式中的A，Device侧的Tensor，数据类型仅支持FLOAT32，数据格式支持ND，当A为乘法左矩阵时，shape为[m，m]，当A为乘法右矩阵时，shape为[n，n]。 |
| lda | Input | const int64\_t | 表示张量A中元素的间隔（当前约束为m/n，当side=ASDBLAS\_SIDE\_LEFT时为m，ASDBLAS\_SIDE\_RIGHT时为n）。 |
| B | Input | aclTensor \* | 公式中的B，Device侧的Tensor，数据类型仅支持FLOAT32，数据格式支持ND，shape为[m，n]。 |
| ldb | Input | const int64\_t | 表示张量B中元素的间隔（当前约束为m）。 |
| C | Output | aclTensor \* | 公式中的C，Device侧的Tensor，数据类型仅支持FLOAT32，数据格式支持ND，shape为[m，n]。 |
| ldc | Input | const int64\_t | 表示张量C中元素的间隔（当前约束为m）。 |


#### 返回值说明

返回值相关说明参见返回值。


#### 约束说明

- asdBlasMakeStrmmPlan：无。

- asdBlasStrmm

  - 输入的元素个数m，n当前覆盖支持[1，8193]。
  - 当side = ASDBLAS_SIDE_LEFT时，算子输入shape为[m，m]、[m，n]，输出shape为[m，n]。
  - 当side = ASDBLAS_SIDE_RIGHT时，算子输入shape为[n，n]、[m，n]，输出shape为[m，n]。
  - 算子实际计算时，不支持ND高维度运算（不支持维度≥3的运算）。


#### 调用示例

算子的调用示例参见Strmm。
