From e427c49bab9e9e3aa46737f3130ddb19f55bb302 Mon Sep 17 00:00:00 2001 From: zyf <2536180464@qq.com> Date: Sun, 24 Aug 2025 20:01:04 +0800 Subject: [PATCH 01/26] T1-1-1 --- infiniop/ops/Cos/Cos.md | 133 +++++++++++++++++++++ infiniop/ops/Exp/Exp.md | 133 +++++++++++++++++++++ infiniop/ops/LeakyRelu/LeakyReLU.md | 147 ++++++++++++++++++++++++ infiniop/ops/cast/README.md | 134 +++++++++++++++++++++ infiniop/ops/hard_swish/README.md | 131 +++++++++++++++++++++ infiniop/ops/sigmoid_backward/README.md | 144 +++++++++++++++++++++++ infiniop/ops/sin/sin.md | 126 ++++++++++++++++++++ infiniop/ops/tanh/tanh.md | 126 ++++++++++++++++++++ infiniop/ops/where/where.md | 140 ++++++++++++++++++++++ 9 files changed, 1214 insertions(+) create mode 100644 infiniop/ops/Cos/Cos.md create mode 100644 infiniop/ops/Exp/Exp.md create mode 100644 infiniop/ops/LeakyRelu/LeakyReLU.md create mode 100644 infiniop/ops/cast/README.md create mode 100644 infiniop/ops/hard_swish/README.md create mode 100644 infiniop/ops/sigmoid_backward/README.md create mode 100644 infiniop/ops/sin/sin.md create mode 100644 infiniop/ops/tanh/tanh.md create mode 100644 infiniop/ops/where/where.md diff --git a/infiniop/ops/Cos/Cos.md b/infiniop/ops/Cos/Cos.md new file mode 100644 index 0000000..86070b3 --- /dev/null +++ b/infiniop/ops/Cos/Cos.md @@ -0,0 +1,133 @@ + +# Cos + +Cos, 即**余弦运算**算子,为单目逐元素算子。其计算可被表述为: + +$$ +output = e^{input} +$$ +其中 `input` 和 为输入,`output` 为输出。 + +## 接口 + +### 计算 + +```c + +infiniStatus_t infiniopExp( + infiniopExpDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *output, + const void *input, + void *stream +); + +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateAddDescriptor()` 初始化的算子描述符; +- `workspace`: + 指向算子计算所需的额外工作空间; +- `workspace_size`: + `workspace` 的大小,单位:字节; +- `output`: + 输出张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `input`: + 输入张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `stream`: + 计算流/队列; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`]. + +### 创建算子描述 + +```c +infiniStatus_t infiniopCreateExpDescriptor( + infiniopHandle_t handle, + infiniopAddDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t output_desc, + infiniopTensorDescriptor_t input_desc, +); +``` + +
参数:
+ +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopAddDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- output_desc` - { dT | (d1,...,dn) | (...) }: + 算子计算参数 output` 的张量描述,支持原位计算。 +- input_desc` - { dT | (d1,...,dn) | (...) }: + 算子计算参数 input` 的张量描述,支持原位计算。 + + + +参数限制: + +- `dT`: (`Float16`, `Float32`, `BFloat16`) 之一。 +- 输入 `input ` 的形状需与 `output` 相同。 +- 支持原位计算,即计算时`input` 可以和 `output` 指向同一地址。 + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetAddWorkspaceSize( + infiniopAddDescriptor_t desc, + size_t *size +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateAddDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroyAddDescriptor( + infiniopAddDescriptor_t desc +); +``` + +
参数:
+ +- `desc`: + 输入。 待销毁的算子描述符; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES diff --git a/infiniop/ops/Exp/Exp.md b/infiniop/ops/Exp/Exp.md new file mode 100644 index 0000000..2a9443c --- /dev/null +++ b/infiniop/ops/Exp/Exp.md @@ -0,0 +1,133 @@ + +# Exp + +Exp, 即**指数运算**算子,为单目逐元素算子。其计算可被表述为: + +$$ +output = cos({input}) +$$ +其中 `input` 和 为输入,`output` 为输出。 + +## 接口 + +### 计算 + +```c + +infiniStatus_t infiniopCos( + infiniopCosDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *output, + const void *input, + void *stream +); + +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateAddDescriptor()` 初始化的算子描述符; +- `workspace`: + 指向算子计算所需的额外工作空间; +- `workspace_size`: + `workspace` 的大小,单位:字节; +- `output`: + 输出张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `input`: + 输入张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `stream`: + 计算流/队列; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`]. + +### 创建算子描述 + +```c +infiniStatus_t infiniopCreateCosDescriptor( + infiniopHandle_t handle, + infiniopCosDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t output, + infiniopTensorDescriptor_t input +); +``` + +
参数:
+ +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopAddDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- output_desc` - { dT | (d1,...,dn) | (...) }: + 算子计算参数 output` 的张量描述,支持原位计算。 +- input_desc` - { dT | (d1,...,dn) | (...) }: + 算子计算参数 input` 的张量描述,支持原位计算。 + + + +参数限制: + +- `dT`: (`Float16`, `Float32`, `BFloat16`) 之一。 +- 输入 `input ` 的形状需与 `output` 相同。 +- 支持原位计算,即计算时`input` 可以和 `output` 指向同一地址。 + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetCosWorkspaceSize( + infiniopCosDescriptor_t desc, + size_t *size +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateAddDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroyCosDescriptor( + infiniopCosDescriptor_t desc +); +``` + +
参数:
+ +- `desc`: + 输入。 待销毁的算子描述符; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md new file mode 100644 index 0000000..49b108b --- /dev/null +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -0,0 +1,147 @@ + +# LeakyReLU + +LeakyReLU, 即 **非线性激活函数**算子,为单目逐元素算子。其计算可被表述为: + +$$ +output = \text{LeakyReLU}({input}) = +\begin{cases} +{input}, & \text{if } {input} \geq 0 \\[6pt] +{negative\_slope}* {input}, & \text{if } {input} < 0 +\end{cases} +$$ +其中 `input` 和 为输入,`output` 为输出, `negative_slope`为构建函数时的常数。 + +## 接口 + +### 计算 + +```c +infiniStatus_t infiniopLeakyRelu( + infiniopLeakyReluDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *output, + const void *input, + float negative_slope, + void *stream +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateAddDescriptor()` 初始化的算子描述符; + +- `workspace`: + 指向算子计算所需的额外工作空间; + +- `workspace_size`: + `workspace` 的大小,单位:字节; + +- `output`: + 输出张量。张量限制见[创建算子描述](#创建算子描述)部分; + +- `input`: + 输入张量。张量限制见[创建算子描述](#创建算子描述)部分; + +- `negative_slope` + + 常量,构建函数时设置 + +- `stream`: + 计算流/队列; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`]. + +### 创建算子描述 + +```c +infiniStatus_t infiniopCreateLeakyReluDescriptor( + infiniopHandle_t handle, + infiniopLeakyReluDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t output, + infiniopTensorDescriptor_t input +); +``` + +
参数:
+ +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopAddDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- output_desc` - { dT | (d1,...,dn) | (...) }: + 算子计算参数 output` 的张量描述,支持原位计算。 +- input_desc` - { dT | (d1,...,dn) | (...) }: + 算子计算参数 input` 的张量描述,支持原位计算。 + + + +参数限制: + +- `dT`: (`Float16`, `Float32`, `BFloat16`) 之一。 +- 输入 `input ` 的形状需与 `output` 相同。 +- 支持原位计算,即计算时`input` 可以和 `output` 指向同一地址。 + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetLeakyReluWorkspaceSize( + infiniopLeakyReluDescriptor_t desc, + size_t *size +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateAddDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroyLeakyReluDescriptor( + infiniopLeakyReluDescriptor_t desc +); +``` + +
参数:
+ +- `desc`: + 输入。 待销毁的算子描述符; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES + diff --git a/infiniop/ops/cast/README.md b/infiniop/ops/cast/README.md new file mode 100644 index 0000000..c1b85d1 --- /dev/null +++ b/infiniop/ops/cast/README.md @@ -0,0 +1,134 @@ + +# `Cast` + +`Cast`,即**类型转换**算子,用于将输入张量中的数据转换为目标数据类型。其计算可表述为: + +$$ +\text{output} = \text{cast}(\text{input}) +$$ + +其中 `input` 为输入张量,`output` 为输出张量。 + +## 接口 + +### 计算 + +```c +infiniStatus_t infiniopCast( + infiniopCastDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *output, + const void *input, + void *stream +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateCastDescriptor()` 初始化的算子描述符; +- `workspace`: + 指向算子计算所需的额外工作空间; +- `workspace_size`: + `workspace` 的大小,单位:字节; +- `output`: + 输出张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `input`: + 输入张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `stream`: + 计算流/队列; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_INTERNAL_ERROR`],[`INFINI_STATUS_BAD_TENSOR_DTYPE`]. + +### 创建算子描述 + +```c +infiniStatus_t infiniopCreateCastDescriptor( + infiniopHandle_t handle, + infiniopCastDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t output, + infiniopTensorDescriptor_t input +); +``` + +
参数:
+ +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopCastDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- `output` - { dT | (d1,...,dn) | (...) }: + 输出张量描述符,必须与输入张量形状完全一致,数据类型可不同。 +- `input` - { dT | (d1,...,dn) | (...) }: + 输入张量描述符,必须与输出张量形状一致。 + +参数限制: + +- 输入输出张量需拥有相同的形状; +- 支持的数据类型转换包括: +- 浮点类型间转换:Float64, Float32, Float16 +- 整数类型间转换:Int32, Int64, UInt32, UInt64 +- 整数类型转换为浮点类型 +- 不支持原位操作; + + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetCastWorkspaceSize( + infiniopCastDescriptor_t desc, + size_t *size +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateCastDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroyCastDescriptor( + infiniopCastDescriptor_t desc +); +``` + +
参数:
+ +- `desc`: + 输入。 待销毁的算子描述符; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES diff --git a/infiniop/ops/hard_swish/README.md b/infiniop/ops/hard_swish/README.md new file mode 100644 index 0000000..7ebd17b --- /dev/null +++ b/infiniop/ops/hard_swish/README.md @@ -0,0 +1,131 @@ + +# `HardSwish` + +`HardSwish`,即 HardSwish 激活函数算子,为单输入逐元素非线性算子。其计算公式如下: + +$$ +\text{output} = \frac{\text{x} \cdot \text{ReLU6}(\text{x}+3)}{6} = \frac{x \cdot \min\left(\max(x+3,0),6\right)}{6} +$$ + +其中 `x` 为输入张量,`output` 为输出张量。 + +## 接口 + +### 计算 + +```c +infiniStatus_t infiniopHardSwish( + infiniopHardSwishDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *output, + const void *input, + void *stream +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateHardSwishDescriptor()` 初始化的算子描述符; +- `workspace`: + 指向算子计算所需的额外工作空间; +- `workspace_size`: + `workspace` 的大小,单位:字节; +- `output`: + 输出张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `input`: + 输入张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `stream`: + 计算流/队列; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_INTERNAL_ERROR`],[`INFINI_STATUS_BAD_TENSOR_DTYPE`]. + +### 创建算子描述 + +```c +infiniStatus_t infiniopCreateHardSwishDescriptor( + infiniopHandle_t handle, + infiniopHardSwishDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t output, + infiniopTensorDescriptor_t input +); +``` + +
参数:
+ +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopHardSwishDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- `output`: + 输出张量的描述符,支持原位计算; +- `input`: + 输入张量的描述符; + +参数限制: + +- 输入输出张量需拥有相同的形状; +- 支持的数据类型包括:`Float16`, `Float32`, `Float64`, `BFloat16`; +- 支持原位计算; + + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetHardSwishWorkspaceSize( + infiniopHardSwishDescriptor_t desc, + size_t *size +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateHardSwishDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroyHardSwishDescriptor( + infiniopHardSwishDescriptor_t desc +); +``` + +
参数:
+ +- `desc`: + 输入。 待销毁的算子描述符; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md new file mode 100644 index 0000000..da5ae17 --- /dev/null +++ b/infiniop/ops/sigmoid_backward/README.md @@ -0,0 +1,144 @@ +# `SigmoidBackward` + +`SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: + +$$ +\text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) +$$ + +$$ +\text{sigmoid}(x) = \frac{1}{1 + e^{-x}} +$$ + +其中: + +- `input`:正向传播中的输入 `x` +- `grad_output`:来自上一层的反向梯度 +- `grad_input`: 输出张量指针,用于存储本层反向传播计算结果; + +## 接口 + +### 计算 + +```c +infiniStatus_t infiniopSigmoidBackward( + infiniopSigmoidBackwardDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *grad_input, + const void *grad_output, + const void *input, + void *stream +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateSigmoidBackwardDescriptor()` 初始化的算子描述符; +- `workspace`: + 算子计算所需的额外工作空间指针(如无需可为 `NULL`); +- `workspace_size`: + `workspace` 的大小,单位为字节; +- `grad_input`: + 输出张量(反向传播计算结果)描述符; +- `grad_output`: + 输入张量(来自上层的梯度); +- `input`: + 正向传播中的输入张量; +- `stream`: + 计算流/队列; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_INTERNAL_ERROR`],[`INFINI_STATUS_BAD_TENSOR_DTYPE`]. + +### 创建算子描述 + +```c +infiniStatus_t infiniopCreateSigmoidBackwardDescriptor( + infiniopHandle_t handle, + infiniopSigmoidBackwardDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t grad_input, + infiniopTensorDescriptor_t grad_output, + infiniopTensorDescriptor_t input +); +``` + +
参数:
+ +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopSigmoidBackwardDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- `grad_input`: + 反向输出张量描述符,支持原位计算; +- `grad_output`: + 反向输入张量描述符; +- `input`: + 正向输入张量描述符; + +参数限制: + +- 输入输出张量需拥有相同的形状; +- 支持的数据类型:`Float16`, `Float32`, `Float64`, `BFloat16`; +- 支持原位计算; + + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetSigmoidBackwardWorkspaceSize( + infiniopSigmoidBackwardDescriptor_t desc, + size_t *size +); +``` + +
参数:
+ +- `desc`: + 已使用 `infiniopCreateSigmoidBackwardDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroySigmoidBackwardDescriptor( + infiniopSigmoidBackwardDescriptor_t desc +); +``` + +
参数:
+ +- `desc`: + 输入。 待销毁的算子描述符; + +
返回值:
+ +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES diff --git a/infiniop/ops/sin/sin.md b/infiniop/ops/sin/sin.md new file mode 100644 index 0000000..ef2c433 --- /dev/null +++ b/infiniop/ops/sin/sin.md @@ -0,0 +1,126 @@ +# Sin + +`Sin`, 即**正弦**算子,为单目算子。其计算可被表述为: +$$ +output = sin(input) +$$ +其中 `input` 为输入,`output` 为输出。 + +## 接口 + +### 计算 + +```c +infiniStatus_t infiniopAdd( + infiniopAddDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *output, + const void *input, + void *stream +); +``` + +参数: + +- `desc`: + 已使用 `infiniopCreateSinDescriptor()` 初始化的算子描述符; +- `workspace`: + 指向算子计算所需的额外工作空间; +- `workspace_size`: + `workspace` 的大小,单位:字节; +- `output`: + 输出张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `input`: + 输入张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `stream`: + 计算流/队列; + +返回值: + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_INTERNAL_ERROR`],[`INFINI_STATUS_BAD_TENSOR_DTYPE`]. + +### 创建算子描述 + +```c++ +infiniStatus_t infiniopCreateSinDescriptor(infiniopHandle_t handle, + infiniopSinDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t output, + infiniopTensorDescriptor_t input); +``` + +参数: + +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopAddDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- `output - { dT | (d1,...,dn) | (...) }:` + 算子计算参数 `output` 的张量描述,支持原位计算。 +- `input - { dT | (d1,...,dn) | (...) }:` + 算子计算参数 `input` 的张量描述,支持原位计算,支持多向广播。 + +参数限制: + +- `dT`: (`Float16`, `Float32`, `Float64`, `BFloat16`) 之一。 +- 输入 `input` 的形状需与 `output` 相同。 +- 支持原位计算,即计算时 `output` 可以和 `input` 指向同一地址。 +- 计算输出参数 `output` 不能进行广播 + +返回值 + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetSinWorkspaceSize( + infiniopAddDescriptor_t desc, + size_t *size +); +``` + +参数: + +- `desc`: + 已使用 `infiniopCreateSinDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +返回值: + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroySinDescriptor( + infiniopAddDescriptor_t desc +); +``` + +参数: + +- `desc`: + 输入。 待销毁的算子描述符; + +返回值: + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES diff --git a/infiniop/ops/tanh/tanh.md b/infiniop/ops/tanh/tanh.md new file mode 100644 index 0000000..341e1bd --- /dev/null +++ b/infiniop/ops/tanh/tanh.md @@ -0,0 +1,126 @@ +# Tanh + +`Tanh`, 对输入张量的每个元素执行双曲正切变换,为单目算子。其计算可被表述为: +$$ +\tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}} +$$ +其中 `x` 为输入,`tan(x)` 为输出。 + +## 接口 + +### 计算 + +```c +infiniStatus_t infiniopTanh( + infiniopAddDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *output, + const void *input, + void *stream +); +``` + +参数: + +- `desc`: + 已使用 `infiniopCreateSinDescriptor()` 初始化的算子描述符; +- `workspace`: + 指向算子计算所需的额外工作空间; +- `workspace_size`: + `workspace` 的大小,单位:字节; +- `output`: + 输出张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `input`: + 输入张量。张量限制见[创建算子描述](#创建算子描述)部分; +- `stream`: + 计算流/队列; + +返回值: + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_INSUFFICIENT_WORKSPACE`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`], [`INFINI_STATUS_INTERNAL_ERROR`],[`INFINI_STATUS_BAD_TENSOR_DTYPE`]. + +### 创建算子描述 + +```c++ +infiniStatus_t infiniopCreateTanhDescriptor(infiniopHandle_t handle, + infiniopSinDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t output, + infiniopTensorDescriptor_t input); +``` + +参数: + +- `handle`: + `infiniopHandle_t` 类型的硬件控柄。详情请看:[`InfiniopHandle_t`]。 +- `desc_ptr`: + `infiniopAddDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- `output - { dT | (d1,...,dn) | (...) }:` + 算子计算参数 `output` 的张量描述,支持原位计算。 +- `input - { dT | (d1,...,dn) | (...) }:` + 算子计算参数 `input` 的张量描述,支持原位计算,支持多向广播。 + +参数限制: + +- `dT`: (`Float16`, `Float32`, `Float64`, `BFloat16`) 之一。 +- 输入 `input` 的形状需与 `output` 相同。 +- 支持原位计算,即计算时 `output` 可以和 `input` 指向同一地址。 +- 计算输出参数 `output` 不能进行广播 + +返回值 + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_BAD_PARAM`], [`INFINI_STATUS_BAD_TENSOR_SHAPE`], [`INFINI_STATUS_BAD_TENSOR_DTYPE`], [`INFINI_STATUS_BAD_TENSOR_STRIDES`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetTanhWorkspaceSize( + infiniopAddDescriptor_t desc, + size_t *size +); +``` + +参数: + +- `desc`: + 已使用 `infiniopCreateSinDescriptor()` 初始化的算子描述符; +- `size`: + 额外空间大小的计算结果的写入地址; + +返回值: + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_NULL_POINTER`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroyTanhDescriptor( + infiniopAddDescriptor_t desc +); +``` + +参数: + +- `desc`: + 输入。 待销毁的算子描述符; + +返回值: + +- [`INFINI_STATUS_SUCCESS`], [`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES diff --git a/infiniop/ops/where/where.md b/infiniop/ops/where/where.md new file mode 100644 index 0000000..7c2ca00 --- /dev/null +++ b/infiniop/ops/where/where.md @@ -0,0 +1,140 @@ +# `Where` + +`Where` 算子为三目元素选择算子,其计算可表示为: +$$ +c_i = \text{cond}_i ? a_i : b_i +$$ +其中 `cond` 为条件张量,`a` 和 `b` 为输入张量,`c` 为输出张量。 + +## 接口 + +### 计算 + +```c +infiniStatus_t infiniopWhere( + infiniopWhereDescriptor_t desc, + void *workspace, + size_t workspace_size, + void *c, + const void *a, + const void *b, + const void *condition, + void *stream); +``` + + 参数: + +- `desc` + 已使用 `infiniopCreateWhereDescriptor()` 初始化的算子描述符; +- `workspace` + 指向算子计算所需的额外工作空间; +- `workspace_size` + `workspace` 的大小,单位:字节; +- `c` + 输出张量。张量限制见创建算子描述部分; +- `condition` + 条件张量。张量限制见创建算子描述部分; +- `a` + 输入张量。张量限制见创建算子描述部分; +- `b` + 输入张量。张量限制见创建算子描述部分; +- `stream` + 计算流/队列; + +返回值: + +- `INFINI_STATUS_SUCCESS`, `INFINI_STATUS_BAD_PARAM`, `INFINI_STATUS_INSUFFICIENT_WORKSPACE`, `INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`, `INFINI_STATUS_INTERNAL_ERROR`, `INFINI_STATUS_BAD_TENSOR_DTYPE`. + +### 创建算子描述 + +```c +infiniStatus_t infiniopCreateWhereDescriptor( + infiniopHandle_t handle, + infiniopWhereDescriptor_t *desc_ptr, + infiniopTensorDescriptor_t c_desc, + infiniopTensorDescriptor_t a_desc, + infiniopTensorDescriptor_t b_desc, + infiniopTensorDescriptor_t condition_desc); +``` + + 参数: + +- `handle` + `infiniopHandle_t` 类型的硬件句柄。详情请参见 `InfiniopHandle_t`。 +- `desc_ptr` + `infiniopWhereDescriptor_t` 指针,指向将被初始化的算子描述符地址; +- `c_desc - { dT | (d1,…,dn) | (…) }` + 算子输出张量 `c` 的张量描述,支持原位计算; +- `condition_desc- { Bool | (d1,…,dn) | (…) }` + 条件张量 `condition` 的张量描述,支持多向广播; +- `a_desc- { dT | (d1,…,dn) | (…) }` + 输入张量 `a` 的张量描述,支持原位计算,支持多向广播; +- `b_desc- { dT | (d1,…,dn) | (…) }` + 输入张量 `b` 的张量描述,支持原位计算,支持多向广播。 + +参数限制: + +- `dT` ∈ { `int8`,`int16`,`int32`,`int164`,`Float16`, `Float32`, `Float64`, `BFloat16`,`BOOL`}; +- `cond` 的数据类型为 `Bool`,其形状需与 `a`、`b` 以及 `c` 通过多向广播后得到的形状一致; +- 输入 `a`、`b` 必须与 `c` 的形状一致,或可通过多向广播匹配 `c`; +- `condition`、`a`、`b` 的步长需与多向广播后的映射关系一致; +- 支持原位计算:`c` 可与 `a` 或 `b` 指向同一地址,但不可与 `condition` 共址; +- 输出张量 `c` 不能进行广播(`c` 的步长不能含 0)。 + +返回值: + +- `INFINI_STATUS_SUCCESS`, `INFINI_STATUS_BAD_PARAM`, `INFINI_STATUS_BAD_TENSOR_SHAPE`, `INFINI_STATUS_BAD_TENSOR_DTYPE`, `INFINI_STATUS_BAD_TENSOR_STRIDES`, `INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`. + +### 计算额外工作空间 + +```c +infiniStatus_t infiniopGetWhereWorkspaceSize( + infiniopWhereDescriptor_t desc, + size_t *size +); +``` + + 参数: + +- `desc` + 已使用 `infiniopCreateWhereDescriptor()` 初始化的算子描述符; +- `size` + 额外空间大小的计算结果写入地址; + +回值: + +- `INFINI_STATUS_SUCCESS`, `INFINI_STATUS_NULL_POINTER`, `INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`. + +### 销毁算子描述符 + +```c +infiniStatus_t infiniopDestroyWhereDescriptor( + infiniopWhereDescriptor_t desc +); +``` + +参数: + +- `desc` + 待销毁的算子描述符; + +返回值: + +- `INFINI_STATUS_SUCCESS`, `INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`. + +## 已知问题 + +无 + + +[`InfiniopHandle_t`]: /infiniop/handle/README.md + +[`INFINI_STATUS_SUCCESS`]: /common/status/README.md#INFINI_STATUS_SUCCESS +[`INFINI_STATUS_BAD_PARAM`]: /common/status/README.md#INFINI_STATUS_BAD_PARAM +[`INFINI_STATUS_INSUFFICIENT_WORKSPACE`]: /common/status/README.md#INFINI_STATUS_INSUFFICIENT_WORKSPACE +[`INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED`]: /common/status/README.md#INFINI_STATUS_DEVICE_TYPE_NOT_SUPPORTED +[`INFINI_STATUS_INTERNAL_ERROR`]: /common/status/README.md#INFINI_STATUS_INTERNAL_ERROR +[`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER +[`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE +[`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES \ No newline at end of file From 87dcf8e1bc1e42dd19dc709093cbcd564b8b32e0 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:03:59 +0800 Subject: [PATCH 02/26] Update LeakyReLU.md --- infiniop/ops/LeakyRelu/LeakyReLU.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md index 49b108b..f7bdbc0 100644 --- a/infiniop/ops/LeakyRelu/LeakyReLU.md +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -3,13 +3,11 @@ LeakyReLU, 即 **非线性激活函数**算子,为单目逐元素算子。其计算可被表述为: -$$ -output = \text{LeakyReLU}({input}) = +$$ output = \text{LeakyReLU}({input}) = \begin{cases} {input}, & \text{if } {input} \geq 0 \\[6pt] {negative\_slope}* {input}, & \text{if } {input} < 0 -\end{cases} -$$ +\end{cases} $$ 其中 `input` 和 为输入,`output` 为输出, `negative_slope`为构建函数时的常数。 ## 接口 From d068e4b7920b6b2a6d5a25d98d086662f7ca2433 Mon Sep 17 00:00:00 2001 From: theFly6 <145251194+theFly6@users.noreply.github.com> Date: Sun, 24 Aug 2025 20:06:47 +0800 Subject: [PATCH 03/26] Update Exp.md --- infiniop/ops/Exp/Exp.md | 1 + 1 file changed, 1 insertion(+) diff --git a/infiniop/ops/Exp/Exp.md b/infiniop/ops/Exp/Exp.md index 2a9443c..7f4fc34 100644 --- a/infiniop/ops/Exp/Exp.md +++ b/infiniop/ops/Exp/Exp.md @@ -6,6 +6,7 @@ Exp, 即**指数运算**算子,为单目逐元素算子。其计算可被表 $$ output = cos({input}) $$ + 其中 `input` 和 为输入,`output` 为输出。 ## 接口 From 7266e3bae8c9827b6dcf6e9a9da713d747648b94 Mon Sep 17 00:00:00 2001 From: theFly6 <145251194+theFly6@users.noreply.github.com> Date: Sun, 24 Aug 2025 20:07:03 +0800 Subject: [PATCH 04/26] Update Cos.md --- infiniop/ops/Cos/Cos.md | 1 + 1 file changed, 1 insertion(+) diff --git a/infiniop/ops/Cos/Cos.md b/infiniop/ops/Cos/Cos.md index 86070b3..a102537 100644 --- a/infiniop/ops/Cos/Cos.md +++ b/infiniop/ops/Cos/Cos.md @@ -6,6 +6,7 @@ Cos, 即**余弦运算**算子,为单目逐元素算子。其计算可被表 $$ output = e^{input} $$ + 其中 `input` 和 为输入,`output` 为输出。 ## 接口 From 3f5beb51bd0cc053211f16de2c02ba3b7113689b Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:07:24 +0800 Subject: [PATCH 05/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index da5ae17..3afd370 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -3,11 +3,15 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: $$ + \text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) + $$ $$ + \text{sigmoid}(x) = \frac{1}{1 + e^{-x}} + $$ 其中: From 8519cde6e66c5476617e4bdae7dd67bbfd2be4cf Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:07:51 +0800 Subject: [PATCH 06/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index 3afd370..e0dd93d 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -8,6 +8,7 @@ $$ $$ + $$ \text{sigmoid}(x) = \frac{1}{1 + e^{-x}} From b7bd90ef684a3d8b3be657d377b5ebac9c0573e3 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:08:07 +0800 Subject: [PATCH 07/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index e0dd93d..f4f2933 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -3,16 +3,12 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: $$ - \text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) - $$ $$ - \text{sigmoid}(x) = \frac{1}{1 + e^{-x}} - $$ 其中: From 4bb8fc64f21e6975325e95b9f385e89bd5a93e60 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:08:28 +0800 Subject: [PATCH 08/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index f4f2933..b1ae8b5 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -2,9 +2,9 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: -$$ + \text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) -$$ + $$ From e45b4a7dc0356808035ed86a228a149b4cd526aa Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:08:45 +0800 Subject: [PATCH 09/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index b1ae8b5..f4f2933 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -2,9 +2,9 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: - +$$ \text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) - +$$ $$ From 1798059530374491f49189574b8940d479bfe025 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:09:05 +0800 Subject: [PATCH 10/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index f4f2933..ee6ed9b 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -7,6 +7,8 @@ $$ $$ +fsfsdfsdfsdf + $$ \text{sigmoid}(x) = \frac{1}{1 + e^{-x}} $$ From d1ab3d352e333e18be5b3972f63a25377b4041a9 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:09:21 +0800 Subject: [PATCH 11/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index ee6ed9b..da5ae17 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -6,9 +6,6 @@ $$ \text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) $$ - -fsfsdfsdfsdf - $$ \text{sigmoid}(x) = \frac{1}{1 + e^{-x}} $$ From 05c63761136b4313505df4d97729c6c92dde64f1 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:10:06 +0800 Subject: [PATCH 12/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index da5ae17..6f9c723 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -3,7 +3,7 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: $$ -\text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) +\text{grad\input} = \text{grad\output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) $$ $$ From db8392eedd0d6f769c239a7c7c3736f19eacc519 Mon Sep 17 00:00:00 2001 From: theFly6 <145251194+theFly6@users.noreply.github.com> Date: Sun, 24 Aug 2025 20:10:59 +0800 Subject: [PATCH 13/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index 6f9c723..b9871e5 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -3,7 +3,7 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: $$ -\text{grad\input} = \text{grad\output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) +\text{grad_input} = \text{grad_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) $$ $$ From 7b989321ceece6c15c624268aa8a04d69b59ab6f Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:12:32 +0800 Subject: [PATCH 14/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index b9871e5..984c4bd 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -3,7 +3,7 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: $$ -\text{grad_input} = \text{grad_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) +\text{gradinput} = \text{gradoutput} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) $$ $$ From 3f1da8c2fcdbd532fa933cb502f4bad810939ee2 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:13:01 +0800 Subject: [PATCH 15/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index 984c4bd..da5ae17 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -3,7 +3,7 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: $$ -\text{gradinput} = \text{gradoutput} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) +\text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) $$ $$ From a16da26f7aa39c9be67b2680e6727f2cc33e41eb Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:13:31 +0800 Subject: [PATCH 16/26] Update README.md --- infiniop/ops/sigmoid_backward/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/sigmoid_backward/README.md b/infiniop/ops/sigmoid_backward/README.md index da5ae17..d90b023 100644 --- a/infiniop/ops/sigmoid_backward/README.md +++ b/infiniop/ops/sigmoid_backward/README.md @@ -3,7 +3,7 @@ `SigmoidBackward`,即 **Sigmoid 函数的反向传播算子**,为单输入、单输出的逐元素算子。其计算公式如下: $$ -\text{grad\_input} = \text{grad\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) +\text{grad\\_input} = \text{grad\\_output} \cdot \text{sigmoid}(x) \cdot (1 - \text{sigmoid}(x)) $$ $$ From a792053e6b4dfbdbf6236325be2a32dd44e514d4 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:14:28 +0800 Subject: [PATCH 17/26] Update LeakyReLU.md --- infiniop/ops/LeakyRelu/LeakyReLU.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md index f7bdbc0..120d4de 100644 --- a/infiniop/ops/LeakyRelu/LeakyReLU.md +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -6,7 +6,7 @@ LeakyReLU, 即 **非线性激活函数**算子,为单目逐元素算子。其 $$ output = \text{LeakyReLU}({input}) = \begin{cases} {input}, & \text{if } {input} \geq 0 \\[6pt] -{negative\_slope}* {input}, & \text{if } {input} < 0 +{negative\\_slope}* {input}, & \text{if } {input} < 0 \end{cases} $$ 其中 `input` 和 为输入,`output` 为输出, `negative_slope`为构建函数时的常数。 From 71eb65bcd89f958fd13989b1193fc23d92c57305 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:15:01 +0800 Subject: [PATCH 18/26] Update LeakyReLU.md --- infiniop/ops/LeakyRelu/LeakyReLU.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md index 120d4de..694ebf7 100644 --- a/infiniop/ops/LeakyRelu/LeakyReLU.md +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -3,11 +3,14 @@ LeakyReLU, 即 **非线性激活函数**算子,为单目逐元素算子。其计算可被表述为: -$$ output = \text{LeakyReLU}({input}) = +$$ +output = \text{LeakyReLU}({input}) = \begin{cases} {input}, & \text{if } {input} \geq 0 \\[6pt] {negative\\_slope}* {input}, & \text{if } {input} < 0 -\end{cases} $$ +\end{cases} +$$ + 其中 `input` 和 为输入,`output` 为输出, `negative_slope`为构建函数时的常数。 ## 接口 From e4f6b81a39c42a327041204c24afc3524553cd67 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:15:20 +0800 Subject: [PATCH 19/26] Update LeakyReLU.md --- infiniop/ops/LeakyRelu/LeakyReLU.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md index 694ebf7..3b4578c 100644 --- a/infiniop/ops/LeakyRelu/LeakyReLU.md +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -7,7 +7,7 @@ $$ output = \text{LeakyReLU}({input}) = \begin{cases} {input}, & \text{if } {input} \geq 0 \\[6pt] -{negative\\_slope}* {input}, & \text{if } {input} < 0 +{negative\_slope}* {input}, & \text{if } {input} < 0 \end{cases} $$ From 4d8a805318ee859d7eabea2f46688a4929753cbb Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:16:24 +0800 Subject: [PATCH 20/26] Update LeakyReLU.md --- infiniop/ops/LeakyRelu/LeakyReLU.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md index 3b4578c..c2306c2 100644 --- a/infiniop/ops/LeakyRelu/LeakyReLU.md +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -6,7 +6,7 @@ LeakyReLU, 即 **非线性激活函数**算子,为单目逐元素算子。其 $$ output = \text{LeakyReLU}({input}) = \begin{cases} -{input}, & \text{if } {input} \geq 0 \\[6pt] +{input}, & \text{if } {input} \geq 0 {negative\_slope}* {input}, & \text{if } {input} < 0 \end{cases} $$ From fc9e9b546cc8415c102a8c278559f2ebda76810c Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:17:48 +0800 Subject: [PATCH 21/26] Update LeakyReLU.md --- infiniop/ops/LeakyRelu/LeakyReLU.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md index c2306c2..9c4bed2 100644 --- a/infiniop/ops/LeakyRelu/LeakyReLU.md +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -6,7 +6,7 @@ LeakyReLU, 即 **非线性激活函数**算子,为单目逐元素算子。其 $$ output = \text{LeakyReLU}({input}) = \begin{cases} -{input}, & \text{if } {input} \geq 0 +{input}, & \text{if } {input} \geq 0 \\ {negative\_slope}* {input}, & \text{if } {input} < 0 \end{cases} $$ From e6488074a374bafd79d999c71c6ae9ebb8262fa4 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:18:20 +0800 Subject: [PATCH 22/26] Update LeakyReLU.md --- infiniop/ops/LeakyRelu/LeakyReLU.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infiniop/ops/LeakyRelu/LeakyReLU.md b/infiniop/ops/LeakyRelu/LeakyReLU.md index 9c4bed2..08525b5 100644 --- a/infiniop/ops/LeakyRelu/LeakyReLU.md +++ b/infiniop/ops/LeakyRelu/LeakyReLU.md @@ -7,7 +7,7 @@ $$ output = \text{LeakyReLU}({input}) = \begin{cases} {input}, & \text{if } {input} \geq 0 \\ -{negative\_slope}* {input}, & \text{if } {input} < 0 +{negative\\_slope}* {input}, & \text{if } {input} < 0 \end{cases} $$ From f6c0b7c8947a55b7a3fb1db4d8a70dfb96505d24 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:19:32 +0800 Subject: [PATCH 23/26] Update sin.md --- infiniop/ops/sin/sin.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/infiniop/ops/sin/sin.md b/infiniop/ops/sin/sin.md index ef2c433..84d899b 100644 --- a/infiniop/ops/sin/sin.md +++ b/infiniop/ops/sin/sin.md @@ -1,9 +1,11 @@ # Sin `Sin`, 即**正弦**算子,为单目算子。其计算可被表述为: + $$ output = sin(input) $$ + 其中 `input` 为输入,`output` 为输出。 ## 接口 From 751cd431fc49853b2e74952aaa555febe6d241a3 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:20:02 +0800 Subject: [PATCH 24/26] Update tanh.md --- infiniop/ops/tanh/tanh.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/infiniop/ops/tanh/tanh.md b/infiniop/ops/tanh/tanh.md index 341e1bd..d26f997 100644 --- a/infiniop/ops/tanh/tanh.md +++ b/infiniop/ops/tanh/tanh.md @@ -1,9 +1,11 @@ # Tanh `Tanh`, 对输入张量的每个元素执行双曲正切变换,为单目算子。其计算可被表述为: + $$ \tanh(x) = \frac{e^x - e^{-x}}{e^x + e^{-x}} $$ + 其中 `x` 为输入,`tan(x)` 为输出。 ## 接口 From 4a4835e526d6c1911ab094a5d7fa6fd9a8f29216 Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:20:26 +0800 Subject: [PATCH 25/26] Update where.md --- infiniop/ops/where/where.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infiniop/ops/where/where.md b/infiniop/ops/where/where.md index 7c2ca00..082eb9d 100644 --- a/infiniop/ops/where/where.md +++ b/infiniop/ops/where/where.md @@ -1,9 +1,11 @@ # `Where` `Where` 算子为三目元素选择算子,其计算可表示为: + $$ c_i = \text{cond}_i ? a_i : b_i $$ + 其中 `cond` 为条件张量,`a` 和 `b` 为输入张量,`c` 为输出张量。 ## 接口 @@ -137,4 +139,4 @@ infiniStatus_t infiniopDestroyWhereDescriptor( [`INFINI_STATUS_NULL_POINTER`]: /common/status/README.md#INFINI_STATUS_NULL_POINTER [`INFINI_STATUS_BAD_TENSOR_SHAPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_SHAPE [`INFINI_STATUS_BAD_TENSOR_DTYPE`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_DTYPE -[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES \ No newline at end of file +[`INFINI_STATUS_BAD_TENSOR_STRIDES`]: /common/status/README.md#INFINI_STATUS_BAD_TENSOR_STRIDES From 90fc2697508a1d14c3a0bf738e5075d2fe17fbca Mon Sep 17 00:00:00 2001 From: ywx980615 Date: Sun, 24 Aug 2025 20:24:39 +0800 Subject: [PATCH 26/26] Update README.md --- infiniop/ops/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/infiniop/ops/README.md b/infiniop/ops/README.md index 0633ec6..3e1db1f 100644 --- a/infiniop/ops/README.md +++ b/infiniop/ops/README.md @@ -12,3 +12,13 @@ - [`Softmax`](/infiniop/ops/softmax/README.md) - [`Sub`](/infiniop/ops/sub/README.md) - [`SwiGLU`](/infiniop/ops/swiglu/README.md) + +- [`Exp`](/infiniop/ops/Exp/README.md) +- [`Sin`](/infiniop/ops/Sin/README.md) +- [`Cos`](/infiniop/ops/Cos/README.md) +- [`LeakyRelu`](/infiniop/ops/LeakyRelu/README.md) +- [`Tanh`](/infiniop/ops/Tanh/README.md) +- [`sigmoid_backward`](/infiniop/ops/sigmoid_backward/README.md) +- [`Hard_swish`](/infiniop/ops/hard_swish/README.md) +- [`Cast`](/infiniop/ops/cast/README.md) +- [`Where`](/infiniop/ops/where/README.md)