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

#### 产品支持情况

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


#### 功能描述

接口功能

- asdBlasMakeIamaxPlan：初始化该句柄对应的Iamax算子配置。
- asdBlasIsamax：找到实数向量中绝对值最大的元素，并返回其索引。如果有多个元素相等，则返回其中的最小索引。
- asdBlasIcamax：找到复数向量中虚部、实部绝对值之和最大的元素，并返回其索引。如果有多个元素的绝对值之和相等，则返回最先找到的那个元素的索引。

计算公式

- asdBlasIsamax的计算公式：

  - 示例：
    输入“x”为：

```
[3, 4, 4,3]
```


    调用“Isamax”算子后，输出“result”为：

```
2
```


- asdBlasIcamax的计算公式：
其中，Re(∙)表示复数的实部，Im(∙)表示复数的虚部。

  - 示例：
    输入“x”为：

```
[3+4i,4-3i,4+2i,3-1i]
```


    调用“Icamax”算子后，输出“result”为：

```
1
```


#### 函数原型

- AspbStatus asdBlasMakeIamaxPlan(asdBlasHandle handle)
- AspbStatus asdBlasIcamax(asdBlasHandle handle, const int64_t n, aclTensor *x, const int64_t incx,aclTensor *result)
- AspbStatus asdBlasIsamax(asdBlasHandle handle, const int64_t n, aclTensor *x, const int64_t incx,aclTensor *result)


#### 参数说明

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


- asdBlasIsamax & asdBlasIcamax| 参数名称 | Input/Output | 类型 | 描述 |
| --- | --- | --- | --- |
| handle | Input | asdBlasHandle | Iamax算子的句柄。 |
| n | Input | const int64\_t | 总的元素个数。 |
| x | Input | aclTensor \* | 公式中的x，Device侧的Tensor，数据格式支持ND，shape为[n]。 Isamax下数据类型支持FLOAT32。 Icamax下数据类型支持COMPLEX64。 |
| incx | Input | const int64\_t | x相邻元素间的内存地址偏移量（当前约束为1）。 |
| result | Output | aclTensor \* | 公式中的result，Device侧的Tensor，数据类型支持INT32，只包含一个元素，数据格式支持ND，shape为[1]。 |


#### 返回值说明

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


#### 约束说明

- asdBlasMakeIamaxPlan：无。
- asdBlasIsamax

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

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


#### 调用示例

算子的调用示例参见Iamax。
