---
title: Ssyr2
description: "| 硬件型号 | 支持情况 |"
url: "https://www.hiascend.com/document/detail/zh/canncommercial/900/API/SiP/SIP_API_0023.html"
---

# Ssyr2

#### 产品支持情况

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


#### 功能描述

接口功能

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

- asdBlasSsyr2：用于计算单精度向量的外积并将结果加到一个矩阵上。

计算公式

- asdBlasSsyr2的计算公式：
- 示例：
  输入“x”为：

```
[ 1, 2 ]
```


  输入“y”为：

```
[ 3, 4 ]
```


  输入A为:

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


  输入“uplo”为： U。

  输入“n”为：2，输入“lda”为：2，输入“incx”为：1，输入“incy”为：1。

  输入“alpha”为：2.345。

  调用“Ssyr2”算子后，输出“A”为：

```
[   [ 15.07,25.45 ],
[ 26.45, 41.52 ]  ].
```


#### 函数原型

- AspbStatus asdBlasMakeSsyr2Plan(asdBlasHandle handle)
- AspbStatus asdBlasSsyr2(asdBlasHandle handle, asdBlasFillMode_t uplo, const int64_t n, const float *alpha, aclTensor *x, int64_t incx, aclTensor *y, int64_t incy, aclTensor *A, const int64_t lda)


#### 参数说明

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


- asdBlasSsyr2| 参数名称 | Input/Output | 类型 | 描述 |
| --- | --- | --- | --- |
| handle | Input | asdBlasHandle | ssyr2算子的句柄。 |
| uplo | Input | asdBlasFillMode\_t | 指定矩阵A的存储方式。 ASDBLAS\_FILL\_MODE\_LOWER // 下三角 ASDBLAS\_FILL\_MODE\_UPPER // 上三角 |
| n | Input | const int64\_t | 向量x中的元素个数，矩阵A的行列数。 |
| alpha | Input | const float \* | 公式中的alpha，标量，向量乘积缩放因子。 |
| x | Input | aclTensor \* | 公式中的x，Device侧的Tensor，数据类型仅支持FLOAT32，数据格式支持ND，shape为[n]。 |
| incx | Input | const int64\_t | x相邻元素间的内存地址偏移量（当前约束为1）。 |
| y | Input | aclTensor \* | 公式中的y，Device侧的Tensor，数据类型仅支持FLOAT32，数据格式支持ND，shape为[n]。 |
| incy | Input | const int64\_t | y相邻元素间的内存地址偏移量（当前约束为1）。 |
| A | Input/Output | aclTensor \* | 公式中的A，Device侧的Tensor，数据类型仅支持FLOAT32，数据格式支持ND，shape为[n，n]。 |
| lda | Input | const int64\_t | 矩阵A的每列元素的存储步长（当前约束为n）。 |


#### 返回值说明

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


#### 约束说明

- asdBlasMakeSsyr2Plan：无。

- asdBlasSsyr2

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


#### 调用示例

算子的调用示例参见Ssyr2。
