已合并
修改了文档中的中英文错误、标点符号错误等 #3915
向芷萍创建于 4月17日
修改了文档中的中英文错误、标点符号错误等 #3915
已合并
共 13 个文件变更+64-64
| @@ -107,7 +107,7 @@ aclnnStatus aclnnConvTbcBackward( | |||
| 107 | <td>输入</td> | 107 | <td>输入</td> |
| 108 | <td>公式中的输出张量y对L的梯度,表示卷积反向的输入。</td> | 108 | <td>公式中的输出张量y对L的梯度,表示卷积反向的输入。</td> |
| 109 | <td> | 109 | <td> |
| 110 | - <ul><li>支持空Tensor。</li><li>shape为(N,C<sub>out</sub>,H<sub>out</sub>)。</li><li>数据类型与 weight 的数据类型需满足数据类型推导规则(参见<a href="../../../docs/zh/context/互推导关系.md">互推导关系</a>)。</li></ul> | 110 | + <ul><li>支持空Tensor。</li><li>shape为(N,C<sub>out</sub>,H<sub>out</sub>)。</li><li>数据类型与 weight 的数据类型需满足数据类型推导规则(参见<a href="../../../docs/zh/context/互推导关系.md">互推导关系</a>)。</li></ul> |
| 111 | </td> | 111 | </td> |
| 112 | <td>FLOAT、FLOAT16、BFLOAT16</td> | 112 | <td>FLOAT、FLOAT16、BFLOAT16</td> |
| 113 | <td>ND、NCL</td> | 113 | <td>ND、NCL</td> |
| @@ -117,7 +117,7 @@ aclnnStatus aclnnConvolutionBackward( | |||
| 117 | <td>输出张量y对L的梯度。</td> | 117 | <td>输出张量y对L的梯度。</td> |
| 118 | <td> | 118 | <td> |
| 119 | <ul><li>支持空Tensor。</li> | 119 | <ul><li>支持空Tensor。</li> |
| 120 | - <li>数据类型与input、weight满足数据类型推导规则(参见<a href="../../../docs/zh/context/互推导关系.md" target="_blank">互推关系</a>和<a href="#约束说明" target="_blank">约束说明</a>)。</li> | 120 | + <li>数据类型与input、weight满足数据类型推导规则(参见<a href="../../../docs/zh/context/互推导关系.md" target="_blank">互推导关系</a>和<a href="#约束说明" target="_blank">约束说明</a>)。</li> |
| 121 | <li>shape不支持broadcast,要求和input、weight满足卷积输入输出shape的推导关系。</li> | 121 | <li>shape不支持broadcast,要求和input、weight满足卷积输入输出shape的推导关系。</li> |
| 122 | <li>数据格式需要与input、gradInput一致。</li></ul> | 122 | <li>数据格式需要与input、gradInput一致。</li></ul> |
| 123 | </td> | 123 | </td> |
| @@ -6,17 +6,17 @@ | |||
| 6 | 6 | ||
| 7 | 调用算子API时,需引用依赖的头文件和库文件,一般头文件默认在```${INSTALL_DIR}/include/aclnnop```,库文件默认在```${INSTALL_DIR}/lib64```,具体文件如下: | 7 | 调用算子API时,需引用依赖的头文件和库文件,一般头文件默认在```${INSTALL_DIR}/include/aclnnop```,库文件默认在```${INSTALL_DIR}/lib64```,具体文件如下: |
| 8 | 8 | ||
| 9 | -- 依赖的头文件:①方式1 (推荐):引用算子总头文件aclnn\_ops\_\$\{ops\_project\}.h。②方式2:按需引用单算子API头文件aclnn\_\*.h。 | 9 | +- 依赖的头文件:①方式1 (推荐):引用算子总头文件```aclnn_ops_${ops_project}.h```。②方式2:按需引用单算子API头文件```aclnn_*.h```。 |
| 10 | -- 依赖的库文件:按需引用算子总库文件libopapi\_\$\{ops\_project\}.so。 | 10 | +- 依赖的库文件:按需引用算子总库文件```libopapi_${ops_project}.so```。 |
| 11 | 11 | ||
| 12 | -其中${INSTALL_DIR}表示CANN安装后文件路径;\$\{ops\_project\}表示算子仓(如math、nn、cv、transformer),请配置为实际算子仓名。 | 12 | +其中```${INSTALL_DIR}```表示CANN安装后文件路径;```${ops_project}```表示算子仓(如math、nn、cv、transformer),请配置为实际算子仓名。 |
| 13 | 13 | ||
| 14 | ## 接口列表 | 14 | ## 接口列表 |
| 15 | 15 | ||
| 16 | > **确定性简介**: | 16 | > **确定性简介**: |
| 17 | > | 17 | > |
| 18 | > - 配置说明:因CANN或NPU型号不同等原因,可能无法保证同一个算子多次运行结果一致。在相同条件下(平台、设备、版本号和其他随机性参数等),部分算子接口可通过`aclrtCtxSetSysParamOpt`(参见[《acl API(C)》](https://hiascend.com/document/redirect/CannCommunityCppApi))开启确定性算法,使多次运行结果一致。 | 18 | > - 配置说明:因CANN或NPU型号不同等原因,可能无法保证同一个算子多次运行结果一致。在相同条件下(平台、设备、版本号和其他随机性参数等),部分算子接口可通过`aclrtCtxSetSysParamOpt`(参见[《acl API(C)》](https://hiascend.com/document/redirect/CannCommunityCppApi))开启确定性算法,使多次运行结果一致。 |
| 19 | -> - 性能说明:同一个算子采用确定性计算通常比非确定性慢,因此模型单次运行性能可能会下降。但在实验、调试调测等需要保证多次运行结果相同来定位问题的场景,确定性计算可以提升效率。 | 19 | +> - 性能说明:同一个算子采用确定性计算通常比非确定性慢,因此模型单次运行性能可能会下降。但在实验、调试和调测等需要保证多次运行结果相同来定位问题的场景,确定性计算可以提升效率。 |
| 20 | > - 线程说明:同一线程中只能设置一次确定性状态,多次设置以最后一次有效设置为准。有效设置是指设置确定性状态后,真正执行了一次算子任务下发。如果仅设置,没有算子下发,只能是确定性变量开启但未下发给算子,因此不执行算子。 | 20 | > - 线程说明:同一线程中只能设置一次确定性状态,多次设置以最后一次有效设置为准。有效设置是指设置确定性状态后,真正执行了一次算子任务下发。如果仅设置,没有算子下发,只能是确定性变量开启但未下发给算子,因此不执行算子。 |
| 21 | > 解决方案:暂不推荐一个线程多次设置确定性。该问题在二进制开启和关闭情况下均存在,在后续版本中会解决该问题。 | 21 | > 解决方案:暂不推荐一个线程多次设置确定性。该问题在二进制开启和关闭情况下均存在,在后续版本中会解决该问题。 |
| 22 | > - 符号说明:表中 “ - ” 符号表示该接口暂不支持当前列产品。 | 22 | > - 符号说明:表中 “ - ” 符号表示该接口暂不支持当前列产品。 |
| @@ -191,7 +191,7 @@ | |||
| 191 | | [aclnnForeachTan](../../foreach/foreach_tan/docs/aclnnForeachTan.md) | 对输入张量列表的每个张量进行正切函数运算。 | 默认确定性实现 | | | 191 | | [aclnnForeachTan](../../foreach/foreach_tan/docs/aclnnForeachTan.md) | 对输入张量列表的每个张量进行正切函数运算。 | 默认确定性实现 | | |
| 192 | | [aclnnForeachTanh](../../foreach/foreach_tanh/docs/aclnnForeachTanh.md) | 对输入张量列表的每个张量进行双曲正切函数运算。 | 默认确定性实现 | | | 192 | | [aclnnForeachTanh](../../foreach/foreach_tanh/docs/aclnnForeachTanh.md) | 对输入张量列表的每个张量进行双曲正切函数运算。 | 默认确定性实现 | | |
| 193 | | [aclnnForeachZeroInplace](../../foreach/foreach_zero_inplace/docs/aclnnForeachZeroInplace.md) | 原地更新输入张量列表,输入张量列表的每个张量置为0。 | 默认确定性实现 | | | 193 | | [aclnnForeachZeroInplace](../../foreach/foreach_zero_inplace/docs/aclnnForeachZeroInplace.md) | 原地更新输入张量列表,输入张量列表的每个张量置为0。 | 默认确定性实现 | | |
| 194 | -| [aclnnFusedLinearOnlineMaxSum](../../matmul/fused_linear_online_max_sum/docs/aclnnFusedLinearOnlineMaxSum.md) | 功能等价Megatron的matmul与fused\_vocab\_parallel\_cross\_entropy的实现,支持vocabulary\_size维度切卡融合matmul与celoss。 | 默认确定性实现 | 默认确定性实现 | | 194 | +| [aclnnFusedLinearOnlineMaxSum](../../matmul/fused_linear_online_max_sum/docs/aclnnFusedLinearOnlineMaxSum.md) | 功能等价Megatron的matmul与fused\_vocab\_parallel\_cross\_entropy的实现,支持vocabulary\_size维度切卡融合matmul与cross-entropy loss。 | 默认确定性实现 | 默认确定性实现 | |
| 195 | | [aclnnFusedLinearCrossEntropyLossGrad](../../matmul/fused_linear_cross_entropy_loss_grad/docs/aclnnFusedLinearCrossEntropyLossGrad.md) | 是词汇表并行场景下交叉熵损失计算模块中的一部分,解决超大规模词汇表下的显存和计算效率问题,当前部分为梯度计算实现,用于计算叶子节点`input`和`weight`的梯度。 | 默认确定性实现 | - | | 195 | | [aclnnFusedLinearCrossEntropyLossGrad](../../matmul/fused_linear_cross_entropy_loss_grad/docs/aclnnFusedLinearCrossEntropyLossGrad.md) | 是词汇表并行场景下交叉熵损失计算模块中的一部分,解决超大规模词汇表下的显存和计算效率问题,当前部分为梯度计算实现,用于计算叶子节点`input`和`weight`的梯度。 | 默认确定性实现 | - | |
| 196 | | [aclnnFusedMatmul](../../matmul/fused_mat_mul/docs/aclnnFusedMatmul.md) | 矩阵乘与通用向量计算融合。 | 默认确定性实现 | 默认确定性实现 | | 196 | | [aclnnFusedMatmul](../../matmul/fused_mat_mul/docs/aclnnFusedMatmul.md) | 矩阵乘与通用向量计算融合。 | 默认确定性实现 | 默认确定性实现 | |
| 197 | | [aclnnFusedQuantMatmul](../../matmul/fused_quant_mat_mul/docs/aclnnFusedQuantMatmul.md) | 量化矩阵乘与通用向量计算融合。 | 默认确定性实现 | - | | 197 | | [aclnnFusedQuantMatmul](../../matmul/fused_quant_mat_mul/docs/aclnnFusedQuantMatmul.md) | 量化矩阵乘与通用向量计算融合。 | 默认确定性实现 | - | |
| @@ -270,9 +270,9 @@ | |||
| 270 | | [aclnnMaxPool2dWithMask](../../pooling/max_pool3d_with_argmax_v2/docs/aclnnMaxPool2dWithMask.md) | 对于输入信号的输入通道,提供2维最大池化(max pooling)操作,输出池化后的值out和索引indices(采用mask语义计算得出)。 | 默认确定性实现 | - | | 270 | | [aclnnMaxPool2dWithMask](../../pooling/max_pool3d_with_argmax_v2/docs/aclnnMaxPool2dWithMask.md) | 对于输入信号的输入通道,提供2维最大池化(max pooling)操作,输出池化后的值out和索引indices(采用mask语义计算得出)。 | 默认确定性实现 | - | |
| 271 | | [aclnnMaxPool2dWithMaskBackward](../../pooling/max_pool3d_grad_with_argmax/docs/aclnnMaxPool2dWithMaskBackward.md) | 正向最大池化aclnnMaxPool2dWithMask的反向传播。 | 默认非确定性实现,支持配置开启。 | - | | 271 | | [aclnnMaxPool2dWithMaskBackward](../../pooling/max_pool3d_grad_with_argmax/docs/aclnnMaxPool2dWithMaskBackward.md) | 正向最大池化aclnnMaxPool2dWithMask的反向传播。 | 默认非确定性实现,支持配置开启。 | - | |
| 272 | | [aclnnMaxPool3dWithArgmax](../../pooling/max_pool3d_with_argmax_v2/docs/aclnnMaxPool3dWithArgmax.md) | 对于输入信号的输入通道,提供3维最大池化(max pooling)操作,输出池化后的值out和索引indices。 | 默认确定性实现 | 默认确定性实现 | | 272 | | [aclnnMaxPool3dWithArgmax](../../pooling/max_pool3d_with_argmax_v2/docs/aclnnMaxPool3dWithArgmax.md) | 对于输入信号的输入通道,提供3维最大池化(max pooling)操作,输出池化后的值out和索引indices。 | 默认确定性实现 | 默认确定性实现 | |
| 273 | -| [aclnnMaxPool3dWithArgmaxBackWard](../../pooling/max_pool3d_grad_with_argmax/docs/aclnnMaxPool3dWithArgmaxBackward.md) | 正向最大池化aclnnMaxPool3dWithArgmax的反向传播,将梯度回填到每个窗口最大值的坐标处,相同坐标处累加。 | 默认非确定性实现,支持配置开启。 | 默认确定性实现 | | 273 | +| [aclnnMaxPool3dWithArgmaxBackward](../../pooling/max_pool3d_grad_with_argmax/docs/aclnnMaxPool3dWithArgmaxBackward.md) | 正向最大池化aclnnMaxPool3dWithArgmax的反向传播,将梯度回填到每个窗口最大值的坐标处,相同坐标处累加。 | 默认非确定性实现,支持配置开启。 | 默认确定性实现 | |
| 274 | | [aclnnMaxUnpool2dBackward](../../index/gather_elements/docs/aclnnMaxUnpool2dBackward.md) | MaxPool2d的逆运算aclnnMaxUnpool2d的反向传播,根据indices索引在out中填入gradOutput的元素值。 | 默认确定性实现 | 默认非确定性实现,支持配置开启 | | 274 | | [aclnnMaxUnpool2dBackward](../../index/gather_elements/docs/aclnnMaxUnpool2dBackward.md) | MaxPool2d的逆运算aclnnMaxUnpool2d的反向传播,根据indices索引在out中填入gradOutput的元素值。 | 默认确定性实现 | 默认非确定性实现,支持配置开启 | |
| 275 | -| [aclnnMaxUnpool3dBackward](../../index/gather_elements/docs/aclnnMaxUnpool3dBackward.md) | axPool3d的逆运算aclnnMaxUnpool3d的反向传播,根据indices索引在out中填入gradOutput的元素值。 | 默认确定性实现 | 默认非确定性实现,支持配置开启 | | 275 | +| [aclnnMaxUnpool3dBackward](../../index/gather_elements/docs/aclnnMaxUnpool3dBackward.md) | MaxPool3d的逆运算aclnnMaxUnpool3d的反向传播,根据indices索引在out中填入gradOutput的元素值。 | 默认确定性实现 | 默认非确定性实现,支持配置开启 | |
| 276 | | [aclnnMedian](../../index/gather_v2/docs/aclnnMedian.md) | 返回所有元素的中位数。 | 默认确定性实现 | 默认确定性实现 | | 276 | | [aclnnMedian](../../index/gather_v2/docs/aclnnMedian.md) | 返回所有元素的中位数。 | 默认确定性实现 | 默认确定性实现 | |
| 277 | | [aclnnMm](../../matmul/mat_mul_v3/docs/aclnnMm.md) | 完成2维张量self与张量mat2的矩阵乘计算。 | 默认确定性实现 | 默认确定性实现 | | 277 | | [aclnnMm](../../matmul/mat_mul_v3/docs/aclnnMm.md) | 完成2维张量self与张量mat2的矩阵乘计算。 | 默认确定性实现 | 默认确定性实现 | |
| 278 | | [aclnnMish&aclnnInplaceMish](../../activation/mish/docs/aclnnMish&aclnnInplaceMish.md) | 一个自正则化的非单调神经网络激活函数。 | 默认确定性实现 | 默认确定性实现 | | 278 | | [aclnnMish&aclnnInplaceMish](../../activation/mish/docs/aclnnMish&aclnnInplaceMish.md) | 一个自正则化的非单调神经网络激活函数。 | 默认确定性实现 | 默认确定性实现 | |
| @@ -106,7 +106,7 @@ aclnnStatus aclnnAvgPool3d( | |||
| 106 | <td>-</td> | 106 | <td>-</td> |
| 107 | </tr> | 107 | </tr> |
| 108 | <tr> | 108 | <tr> |
| 109 | - <td>stride</td> | 109 | + <td>strides</td> |
| 110 | <td>输入</td> | 110 | <td>输入</td> |
| 111 | <td>池化操作的步长,公式中的strides。</td> | 111 | <td>池化操作的步长,公式中的strides。</td> |
| 112 | <td>长度为0(数值与kernelSize数值保持一致)或者1(SD = SH = SW)或者3(SD, SH, SW),长度为1或3时数值必须大于0。</td> | 112 | <td>长度为0(数值与kernelSize数值保持一致)或者1(SD = SH = SW)或者3(SD, SH, SW),长度为1或3时数值必须大于0。</td> |
| @@ -254,7 +254,7 @@ aclnnStatus aclnnMaxPool2dWithIndicesBackward( | |||
| 254 | <td>padding的元素个数不等于1或2</td> | 254 | <td>padding的元素个数不等于1或2</td> |
| 255 | </tr> | 255 | </tr> |
| 256 | <tr> | 256 | <tr> |
| 257 | - <td>padding的数值中存在小于0或者大于kernelSize</td> | 257 | + <td>padding的数值中存在小于0或者大于kernelSize的数值</td> |
| 258 | </tr> | 258 | </tr> |
| 259 | <tr> | 259 | <tr> |
| 260 | <td>dilation的元素数值不符合入参要求。</td> | 260 | <td>dilation的元素数值不符合入参要求。</td> |
| @@ -229,7 +229,7 @@ aclnnStatus aclnnMaxPool2dWithMaskBackward( | |||
| 229 | <td>padding的长度不等于1或2。</td> | 229 | <td>padding的长度不等于1或2。</td> |
| 230 | </tr> | 230 | </tr> |
| 231 | <tr> | 231 | <tr> |
| 232 | - <td>padding的数值中存在小于0或者大于kernelSize</td> | 232 | + <td>padding的数值中存在小于0或者大于kernelSize的数值</td> |
| 233 | </tr> | 233 | </tr> |
| 234 | <tr> | 234 | <tr> |
| 235 | <td>dilation的数值不等于1。</td> | 235 | <td>dilation的数值不等于1。</td> |
| @@ -240,7 +240,7 @@ aclnnStatus aclnnMaxPool2dWithIndices( | |||
| 240 | <td>padding的长度不等于1或2。</td> | 240 | <td>padding的长度不等于1或2。</td> |
| 241 | </tr> | 241 | </tr> |
| 242 | <tr> | 242 | <tr> |
| 243 | - <td>padding的数值中存在小于0或者大于kernelSize</td> | 243 | + <td>padding的数值中存在小于0或者大于kernelSize/2</td> |
| 244 | </tr> | 244 | </tr> |
| 245 | <tr> | 245 | <tr> |
| 246 | <td>dilation的长度不等于1或2。</td> | 246 | <td>dilation的长度不等于1或2。</td> |
| @@ -367,7 +367,7 @@ int main() { | |||
| 367 | std::vector<char> maskHostData{1}; | 367 | std::vector<char> maskHostData{1}; |
| 368 | int64_t quantMin = 1; | 368 | int64_t quantMin = 1; |
| 369 | int64_t quantMax = 3; | 369 | int64_t quantMax = 3; |
| 370 | - float fakeQuantEnabled; | 370 | + float fakeQuantEnabled = 1.0f; |
| 371 | // 创建 aclTensor | 371 | // 创建 aclTensor |
| 372 | ret = CreateAclTensor(selfHostData, selfShape, &selfDeviceAddr, aclDataType::ACL_FLOAT, &self); | 372 | ret = CreateAclTensor(selfHostData, selfShape, &selfDeviceAddr, aclDataType::ACL_FLOAT, &self); |
| 373 | CHECK_RET(ret == ACL_SUCCESS, return ret); | 373 | CHECK_RET(ret == ACL_SUCCESS, return ret); |
Mquant/fake_quant_affine_cachemask/examples/test_aclnn_fake_quant_per_tensor_affine_cachemask.cpp+6-6
| @@ -68,13 +68,13 @@ int CreateAclTensor(const std::vector<T>& hostData, const std::vector<int64_t>& | |||
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | int main() { | 70 | int main() { |
| 71 | - // 1. (固定写法)device/stream初始化,参考acl API | 71 | + // 1. (固定写法)device/stream初始化,参考acl API手册 |
| 72 | // 根据自己的实际device填写deviceId | 72 | // 根据自己的实际device填写deviceId |
| 73 | int32_t deviceId = 0; | 73 | int32_t deviceId = 0; |
| 74 | aclrtStream stream; | 74 | aclrtStream stream; |
| 75 | auto ret = Init(deviceId, &stream); | 75 | auto ret = Init(deviceId, &stream); |
| 76 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret); | 76 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("Init acl failed. ERROR: %d\n", ret); return ret); |
| 77 | - | 77 | + |
| 78 | // 2. 构造输入与输出,需要根据API的接口自定义构造 | 78 | // 2. 构造输入与输出,需要根据API的接口自定义构造 |
| 79 | std::vector<int64_t> selfShape = {1}; | 79 | std::vector<int64_t> selfShape = {1}; |
| 80 | std::vector<int64_t> scaleShape = {1}; | 80 | std::vector<int64_t> scaleShape = {1}; |
| @@ -98,7 +98,7 @@ int main() { | |||
| 98 | std::vector<char> maskHostData{1}; | 98 | std::vector<char> maskHostData{1}; |
| 99 | int64_t quantMin = 1; | 99 | int64_t quantMin = 1; |
| 100 | int64_t quantMax = 3; | 100 | int64_t quantMax = 3; |
| 101 | - float fakeQuantEnbled; | 101 | + float fakeQuantEnabled = 1.0f; |
| 102 | // 创建 aclTensor | 102 | // 创建 aclTensor |
| 103 | ret = CreateAclTensor(selfHostData, selfShape, &selfDeviceAddr, aclDataType::ACL_FLOAT, &self); | 103 | ret = CreateAclTensor(selfHostData, selfShape, &selfDeviceAddr, aclDataType::ACL_FLOAT, &self); |
| 104 | CHECK_RET(ret == ACL_SUCCESS, return ret); | 104 | CHECK_RET(ret == ACL_SUCCESS, return ret); |
| @@ -115,7 +115,7 @@ int main() { | |||
| 115 | uint64_t workspaceSize = 0; | 115 | uint64_t workspaceSize = 0; |
| 116 | aclOpExecutor* executor; | 116 | aclOpExecutor* executor; |
| 117 | // 调用aclnnEye第一段接口 | 117 | // 调用aclnnEye第一段接口 |
| 118 | - ret = aclnnFakeQuantPerTensorAffineCachemaskGetWorkspaceSize(self, scale, zeroPoint, fakeQuantEnbled, quantMin, quantMax, out, mask, &workspaceSize, &executor); | 118 | + ret = aclnnFakeQuantPerTensorAffineCachemaskGetWorkspaceSize(self, scale, zeroPoint, fakeQuantEnabled, quantMin, quantMax, out, mask, &workspaceSize, &executor); |
| 119 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnFakeQuantPerTensorAffineCachemaskGetWorkspaceSize failed. ERROR: %d\n", ret); return ret); | 119 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnFakeQuantPerTensorAffineCachemaskGetWorkspaceSize failed. ERROR: %d\n", ret); return ret); |
| 120 | // 根据第一段接口计算出的workspaceSize申请device内存 | 120 | // 根据第一段接口计算出的workspaceSize申请device内存 |
| 121 | void* workspaceAddr = nullptr; | 121 | void* workspaceAddr = nullptr; |
| @@ -126,11 +126,11 @@ int main() { | |||
| 126 | // 调用aclnnFakeQuantPerTensorAffineCachemask第二段接口 | 126 | // 调用aclnnFakeQuantPerTensorAffineCachemask第二段接口 |
| 127 | ret = aclnnFakeQuantPerTensorAffineCachemask(workspaceAddr, workspaceSize, executor, stream); | 127 | ret = aclnnFakeQuantPerTensorAffineCachemask(workspaceAddr, workspaceSize, executor, stream); |
| 128 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnFakeQuantPerTensorAffineCachemask failed. ERROR: %d\n", ret); return ret); | 128 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclnnFakeQuantPerTensorAffineCachemask failed. ERROR: %d\n", ret); return ret); |
| 129 | - | 129 | + |
| 130 | // 4. (固定写法)同步等待任务执行结束 | 130 | // 4. (固定写法)同步等待任务执行结束 |
| 131 | ret = aclrtSynchronizeStream(stream); | 131 | ret = aclrtSynchronizeStream(stream); |
| 132 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSynchronizeStream failed. ERROR: %d\n", ret); return ret); | 132 | CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("aclrtSynchronizeStream failed. ERROR: %d\n", ret); return ret); |
| 133 | - | 133 | + |
| 134 | // 5. 获取输出的值,将device侧内存上的结果拷贝至host侧,需要根据具体API的接口定义修改 | 134 | // 5. 获取输出的值,将device侧内存上的结果拷贝至host侧,需要根据具体API的接口定义修改 |
| 135 | auto size = GetShapeSize(outShape); | 135 | auto size = GetShapeSize(outShape); |
| 136 | std::vector<float> resultData(size, 0); | 136 | std::vector<float> resultData(size, 0); |
| @@ -47,12 +47,12 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 47 | const aclTensorList *params, | 47 | const aclTensorList *params, |
| 48 | const aclTensorList *hx, | 48 | const aclTensorList *hx, |
| 49 | const aclTensor *batchSizes, | 49 | const aclTensor *batchSizes, |
| 50 | - bool has_biases, | 50 | + bool hasBias, |
| 51 | int64_t numLayers, | 51 | int64_t numLayers, |
| 52 | - double droupout, | 52 | + double dropout, |
| 53 | bool train, | 53 | bool train, |
| 54 | bool bidirectional, | 54 | bool bidirectional, |
| 55 | - bool batch_first, | 55 | + bool batchFirst, |
| 56 | aclTensor *output, | 56 | aclTensor *output, |
| 57 | aclTensor *hy, | 57 | aclTensor *hy, |
| 58 | aclTensor *cy, | 58 | aclTensor *cy, |
| @@ -108,12 +108,12 @@ aclnnStatus aclnnLSTM( | |||
| 108 | <td> | 108 | <td> |
| 109 | <ul> | 109 | <ul> |
| 110 | <li><strong>若batchSizes传入空指针:</strong> | 110 | <li><strong>若batchSizes传入空指针:</strong> |
| 111 | - <br>shape格式根据batch_first参数区分: | 111 | + <br>shape格式根据batchFirst参数区分: |
| 112 | <ul> | 112 | <ul> |
| 113 | - <li>batch_first=False:(time_step, batch_size, input_size)</li> | 113 | + <li>batchFirst=False:(time_step, batch_size, input_size)</li> |
| 114 | - <li>batch_first=True:(batch_size, time_step, input_size)</li> | 114 | + <li>batchFirst=True:(batch_size, time_step, input_size)</li> |
| 115 | </ul> | 115 | </ul> |
| 116 | - 说明:batch_first表示batch维度是否在第一维;time_step为时间维度;batch_size为每个时刻处理的样本数;input_size为输入特征数。 | 116 | + 说明:batchFirst表示batch维度是否在第一维;time_step为时间维度;batch_size为每个时刻处理的样本数;input_size为输入特征数。 |
| 117 | </li> | 117 | </li> |
| 118 | <li><strong>若传入有效batchSizes:</strong> | 118 | <li><strong>若传入有效batchSizes:</strong> |
| 119 | <br>shape格式:(time_step * batch_size, input_size) | 119 | <br>shape格式:(time_step * batch_size, input_size) |
| @@ -201,7 +201,7 @@ aclnnStatus aclnnLSTM( | |||
| 201 | <td>√</td> | 201 | <td>√</td> |
| 202 | </tr> | 202 | </tr> |
| 203 | <tr> | 203 | <tr> |
| 204 | - <td>droupout</td> | 204 | + <td>dropout</td> |
| 205 | <td>输入</td> | 205 | <td>输入</td> |
| 206 | <td>表示随机掩码的概率。</td> | 206 | <td>表示随机掩码的概率。</td> |
| 207 | <td>当前不支持该功能</td> | 207 | <td>当前不支持该功能</td> |
| @@ -221,7 +221,7 @@ aclnnStatus aclnnLSTM( | |||
| 221 | <td>√</td> | 221 | <td>√</td> |
| 222 | </tr> | 222 | </tr> |
| 223 | <tr> | 223 | <tr> |
| 224 | - <td>bidirection</td> | 224 | + <td>bidirectional</td> |
| 225 | <td>输入</td> | 225 | <td>输入</td> |
| 226 | <td>表示是否是双向。</td> | 226 | <td>表示是否是双向。</td> |
| 227 | <td>/</td> | 227 | <td>/</td> |
| @@ -244,7 +244,7 @@ aclnnStatus aclnnLSTM( | |||
| 244 | <td>output</td> | 244 | <td>output</td> |
| 245 | <td>输出</td> | 245 | <td>输出</td> |
| 246 | <td>表示LSTM运算中最后一层每个时间步的输出结果。</td> | 246 | <td>表示LSTM运算中最后一层每个时间步的输出结果。</td> |
| 247 | - <td><ul><li>若batchSizes传入空指针:<br>当batch_first=False时shape支持三维(time_step, batch_size, D * hidden_size),否则支持三维(batch_size, time_step, D * hidden_size)。</li><li>若传入有效batchSizes:<br>shape应为(time_step, batch_size, D * hidden_size)。</li></ul></td> | 247 | + <td><ul><li>若batchSizes传入空指针:<br>当batchFirst=False时shape支持三维(time_step, batch_size, D * hidden_size),否则支持三维(batch_size, time_step, D * hidden_size)。</li><li>若传入有效batchSizes:<br>shape应为(time_step, batch_size, D * hidden_size)。</li></ul></td> |
| 248 | <td>FLOAT16、FLOAT32</td> | 248 | <td>FLOAT16、FLOAT32</td> |
| 249 | <td>ND</td> | 249 | <td>ND</td> |
| 250 | <td>3</td> | 250 | <td>3</td> |
| @@ -254,7 +254,7 @@ aclnnStatus aclnnLSTM( | |||
| 254 | <td>hy</td> | 254 | <td>hy</td> |
| 255 | <td>输出</td> | 255 | <td>输出</td> |
| 256 | <td>表示进行LSTM运算中每层最后一个时间步的隐藏层(公式(7)的输出)。</td> | 256 | <td>表示进行LSTM运算中每层最后一个时间步的隐藏层(公式(7)的输出)。</td> |
| 257 | - <td>shape支持三维(D * num_layers, batch_size, hidden_size</td> | 257 | + <td>shape支持三维(D * num_layers, batch_size, hidden_size)</td> |
| 258 | <td>FLOAT16、FLOAT32</td> | 258 | <td>FLOAT16、FLOAT32</td> |
| 259 | <td>ND</td> | 259 | <td>ND</td> |
| 260 | <td>3</td> | 260 | <td>3</td> |
| @@ -264,7 +264,7 @@ aclnnStatus aclnnLSTM( | |||
| 264 | <td>cy</td> | 264 | <td>cy</td> |
| 265 | <td>输出</td> | 265 | <td>输出</td> |
| 266 | <td>表示进行LSTM运算中每层最后一个时间步的Cell状态(公式(5)的输出)。</td> | 266 | <td>表示进行LSTM运算中每层最后一个时间步的Cell状态(公式(5)的输出)。</td> |
| 267 | - <td>shape支持三维(D * num_layers, batch_size, hidden_size</td> | 267 | + <td>shape支持三维(D * num_layers, batch_size, hidden_size)</td> |
| 268 | <td>FLOAT16、FLOAT32</td> | 268 | <td>FLOAT16、FLOAT32</td> |
| 269 | <td>ND</td> | 269 | <td>ND</td> |
| 270 | <td>3</td> | 270 | <td>3</td> |
| @@ -274,7 +274,7 @@ aclnnStatus aclnnLSTM( | |||
| 274 | <td>hy</td> | 274 | <td>hy</td> |
| 275 | <td>输出</td> | 275 | <td>输出</td> |
| 276 | <td>表示进行LSTM运算中每层最后一个时间步的隐藏层(公式(7)的输出)。</td> | 276 | <td>表示进行LSTM运算中每层最后一个时间步的隐藏层(公式(7)的输出)。</td> |
| 277 | - <td>shape支持三维(D * num_layers, batch_size, hidden_size</td> | 277 | + <td>shape支持三维(D * num_layers, batch_size, hidden_size)</td> |
| 278 | <td>FLOAT16、FLOAT32</td> | 278 | <td>FLOAT16、FLOAT32</td> |
| 279 | <td>ND</td> | 279 | <td>ND</td> |
| 280 | <td>3</td> | 280 | <td>3</td> |
| @@ -284,7 +284,7 @@ aclnnStatus aclnnLSTM( | |||
| 284 | <td>cy</td> | 284 | <td>cy</td> |
| 285 | <td>输出</td> | 285 | <td>输出</td> |
| 286 | <td>表示进行LSTM运算中每层最后一个时间步的Cell状态(公式(5)的输出)。</td> | 286 | <td>表示进行LSTM运算中每层最后一个时间步的Cell状态(公式(5)的输出)。</td> |
| 287 | - <td>shape支持三维(D * num_layers, batch_size, hidden_size</td> | 287 | + <td>shape支持三维(D * num_layers, batch_size, hidden_size)</td> |
| 288 | <td>FLOAT16、FLOAT32</td> | 288 | <td>FLOAT16、FLOAT32</td> |
| 289 | <td>ND</td> | 289 | <td>ND</td> |
| 290 | <td>3</td> | 290 | <td>3</td> |
| @@ -42,7 +42,7 @@ struct LstmDataParamsIn { | |||
| 42 | const aclTensorList *hx; | 42 | const aclTensorList *hx; |
| 43 | const aclTensor *batchSizes; | 43 | const aclTensor *batchSizes; |
| 44 | int64_t numLayers; | 44 | int64_t numLayers; |
| 45 | - bool has_biases; | 45 | + bool hasBias; |
| 46 | bool train; | 46 | bool train; |
| 47 | bool bidirectional; | 47 | bool bidirectional; |
| 48 | }; | 48 | }; |
| @@ -123,10 +123,10 @@ auto nullptrInner = std::tuple<aclTensor*, aclTensor*, aclTensor*, aclTensor*, a | |||
| 123 | 123 | ||
| 124 | std::tuple<const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *> LstmSingleLayerDirec( | 124 | std::tuple<const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *, const aclTensor *> LstmSingleLayerDirec( |
| 125 | const aclTensor * input, const aclTensorList * params, const aclTensorList * hx, aclTensor *yOutDirec, aclTensor *iOutDirec, aclTensor *jOutDirec, aclTensor *fOutDirec, aclTensor *oOutDirec, aclTensor *hOutDirec, aclTensor *cOutDirec, aclTensor *tanhCOutDirec, | 125 | const aclTensor * input, const aclTensorList * params, const aclTensorList * hx, aclTensor *yOutDirec, aclTensor *iOutDirec, aclTensor *jOutDirec, aclTensor *fOutDirec, aclTensor *oOutDirec, aclTensor *hOutDirec, aclTensor *cOutDirec, aclTensor *tanhCOutDirec, |
| 126 | - const char *direction, bool bidirectional, bool train, int64_t num_layers, bool has_biases, aclOpExecutor* executor) | 126 | + const char *direction, bool bidirectional, bool train, int64_t num_layers, bool hasBias, aclOpExecutor* executor) |
| 127 | { | 127 | { |
| 128 | auto oneLayerParams = bidirectional == true ? 4 : 2; | 128 | auto oneLayerParams = bidirectional == true ? 4 : 2; |
| 129 | - oneLayerParams = has_biases == true ? oneLayerParams * 2 : oneLayerParams; | 129 | + oneLayerParams = hasBias == true ? oneLayerParams * 2 : oneLayerParams; |
| 130 | auto weightStart = strcmp(direction, "UNIDIRECTIONAL") == 0 ? 0 : oneLayerParams / 2; | 130 | auto weightStart = strcmp(direction, "UNIDIRECTIONAL") == 0 ? 0 : oneLayerParams / 2; |
| 131 | auto paramsOffsets = oneLayerParams * num_layers + weightStart; | 131 | auto paramsOffsets = oneLayerParams * num_layers + weightStart; |
| 132 | op::FVector<const aclTensor*> weightConcatList; | 132 | op::FVector<const aclTensor*> weightConcatList; |
| @@ -144,7 +144,7 @@ std::tuple<const aclTensor *, const aclTensor *, const aclTensor *, const aclTen | |||
| 144 | OP_CHECK_NULL(weightTrans, return nullptrInner); | 144 | OP_CHECK_NULL(weightTrans, return nullptrInner); |
| 145 | 145 | ||
| 146 | const aclTensor * bias = nullptr; | 146 | const aclTensor * bias = nullptr; |
| 147 | - if (has_biases) { | 147 | + if (hasBias) { |
| 148 | bias = l0op::Add((*params)[paramsOffsets + 2], (*params)[paramsOffsets + 3], executor); | 148 | bias = l0op::Add((*params)[paramsOffsets + 2], (*params)[paramsOffsets + 3], executor); |
| 149 | OP_CHECK_NULL(bias, return nullptrInner); | 149 | OP_CHECK_NULL(bias, return nullptrInner); |
| 150 | } else { | 150 | } else { |
| @@ -307,10 +307,10 @@ static inline bool CheckDtypeValid(const aclTensor *input, const aclTensorList | |||
| 307 | return true; | 307 | return true; |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | -static bool CheckDimsSize(const aclTensorList *params, const aclTensorList *hx, bool has_biases, int64_t numLayers, bool train, bool bidirectional, aclTensorList *iOut, aclTensorList *jOut, aclTensorList *fOut, aclTensorList *oOut, | 310 | +static bool CheckDimsSize(const aclTensorList *params, const aclTensorList *hx, bool hasBias, int64_t numLayers, bool train, bool bidirectional, aclTensorList *iOut, aclTensorList *jOut, aclTensorList *fOut, aclTensorList *oOut, |
| 311 | aclTensorList *hOut, aclTensorList *cOut, aclTensorList *tanhCOut) { | 311 | aclTensorList *hOut, aclTensorList *cOut, aclTensorList *tanhCOut) { |
| 312 | uint64_t dScale = bidirectional == true ? 2 : 1; | 312 | uint64_t dScale = bidirectional == true ? 2 : 1; |
| 313 | - uint64_t bScale = has_biases == true ? 2 : 1; | 313 | + uint64_t bScale = hasBias == true ? 2 : 1; |
| 314 | uint64_t output_nums = dScale * numLayers; | 314 | uint64_t output_nums = dScale * numLayers; |
| 315 | uint64_t param_nums = 2 * bScale * dScale * numLayers; | 315 | uint64_t param_nums = 2 * bScale * dScale * numLayers; |
| 316 | 316 | ||
| @@ -355,11 +355,11 @@ static bool CheckDimsSize(const aclTensorList *params, const aclTensorList *hx, | |||
| 355 | return true; | 355 | return true; |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | -static bool CheckDims(const aclTensor *input, const aclTensorList *params, const aclTensorList *hx, bool has_biases, int64_t numLayers, bool train, bool bidirectional, | 358 | +static bool CheckDims(const aclTensor *input, const aclTensorList *params, const aclTensorList *hx, bool hasBias, int64_t numLayers, bool train, bool bidirectional, |
| 359 | aclTensor *output, aclTensor *hy, aclTensor *cy, aclTensorList *iOut, aclTensorList *jOut, aclTensorList *fOut, aclTensorList *oOut, | 359 | aclTensor *output, aclTensor *hy, aclTensor *cy, aclTensorList *iOut, aclTensorList *jOut, aclTensorList *fOut, aclTensorList *oOut, |
| 360 | aclTensorList *hOut, aclTensorList *cOut, aclTensorList *tanhCOut) { | 360 | aclTensorList *hOut, aclTensorList *cOut, aclTensorList *tanhCOut) { |
| 361 | OP_CHECK_WRONG_DIMENSION(input, INPUT_DIMS, return false); | 361 | OP_CHECK_WRONG_DIMENSION(input, INPUT_DIMS, return false); |
| 362 | - uint64_t bScale = has_biases == true ? 2 : 1; | 362 | + uint64_t bScale = hasBias == true ? 2 : 1; |
| 363 | uint64_t dScale = bidirectional == true ? 2 : 1; | 363 | uint64_t dScale = bidirectional == true ? 2 : 1; |
| 364 | uint64_t oneLayerParams = 2 * bScale * dScale; | 364 | uint64_t oneLayerParams = 2 * bScale * dScale; |
| 365 | for (uint64_t i = 0; i < (uint64_t)numLayers; i++) { | 365 | for (uint64_t i = 0; i < (uint64_t)numLayers; i++) { |
| @@ -367,7 +367,7 @@ static bool CheckDims(const aclTensor *input, const aclTensorList *params, cons | |||
| 367 | uint64_t offsets = i * oneLayerParams + j * oneLayerParams / 2; | 367 | uint64_t offsets = i * oneLayerParams + j * oneLayerParams / 2; |
| 368 | OP_CHECK_WRONG_DIMENSION((*params)[offsets], WEIGHT_DIMS, return false); | 368 | OP_CHECK_WRONG_DIMENSION((*params)[offsets], WEIGHT_DIMS, return false); |
| 369 | OP_CHECK_WRONG_DIMENSION((*params)[offsets + 1], WEIGHT_DIMS, return false); | 369 | OP_CHECK_WRONG_DIMENSION((*params)[offsets + 1], WEIGHT_DIMS, return false); |
| 370 | - if (has_biases) { | 370 | + if (hasBias) { |
| 371 | OP_CHECK_WRONG_DIMENSION((*params)[offsets + 2], BIAS_DIMS, return false); | 371 | OP_CHECK_WRONG_DIMENSION((*params)[offsets + 2], BIAS_DIMS, return false); |
| 372 | OP_CHECK_WRONG_DIMENSION((*params)[offsets + 3], BIAS_DIMS, return false); | 372 | OP_CHECK_WRONG_DIMENSION((*params)[offsets + 3], BIAS_DIMS, return false); |
| 373 | } | 373 | } |
| @@ -640,7 +640,7 @@ static aclnnStatus CheckDimsAndListLength(const LstmDataParamsIn& inputs, const | |||
| 640 | int64_t currOffset = group * info.groupLen; | 640 | int64_t currOffset = group * info.groupLen; |
| 641 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_0], INDEX_2, return ACLNN_ERR_PARAM_INVALID); | 641 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_0], INDEX_2, return ACLNN_ERR_PARAM_INVALID); |
| 642 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_1], INDEX_2, return ACLNN_ERR_PARAM_INVALID); | 642 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_1], INDEX_2, return ACLNN_ERR_PARAM_INVALID); |
| 643 | - if (inputs.has_biases) { | 643 | + if (inputs.hasBias) { |
| 644 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_2], INDEX_1, return ACLNN_ERR_PARAM_INVALID); | 644 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_2], INDEX_1, return ACLNN_ERR_PARAM_INVALID); |
| 645 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_3], INDEX_1, return ACLNN_ERR_PARAM_INVALID); | 645 | OP_CHECK_WRONG_DIMENSION((*inputs.params)[currOffset + INDEX_3], INDEX_1, return ACLNN_ERR_PARAM_INVALID); |
| 646 | } | 646 | } |
| @@ -716,7 +716,7 @@ static aclnnStatus CheckShapes(const LstmDataParamsIn& inputs, const LstmDataPar | |||
| 716 | return ACLNN_ERR_PARAM_INVALID | 716 | return ACLNN_ERR_PARAM_INVALID |
| 717 | ); | 717 | ); |
| 718 | OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE((*inputs.params)[currOffset + INDEX_1], weightHhShape, return ACLNN_ERR_PARAM_INVALID); | 718 | OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE((*inputs.params)[currOffset + INDEX_1], weightHhShape, return ACLNN_ERR_PARAM_INVALID); |
| 719 | - if (inputs.has_biases) { | 719 | + if (inputs.hasBias) { |
| 720 | OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE((*inputs.params)[currOffset + INDEX_2], biasShape, return ACLNN_ERR_PARAM_INVALID); | 720 | OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE((*inputs.params)[currOffset + INDEX_2], biasShape, return ACLNN_ERR_PARAM_INVALID); |
| 721 | OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE((*inputs.params)[currOffset + INDEX_3], biasShape, return ACLNN_ERR_PARAM_INVALID); | 721 | OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE((*inputs.params)[currOffset + INDEX_3], biasShape, return ACLNN_ERR_PARAM_INVALID); |
| 722 | } | 722 | } |
| @@ -807,7 +807,7 @@ static aclnnStatus CheckParamsValid(const LstmDataParamsIn& inputs, const LstmDa | |||
| 807 | 807 | ||
| 808 | info.L = inputs.numLayers; | 808 | info.L = inputs.numLayers; |
| 809 | info.D = (inputs.bidirectional) ? INDEX_2 : INDEX_1; | 809 | info.D = (inputs.bidirectional) ? INDEX_2 : INDEX_1; |
| 810 | - info.groupLen = (inputs.has_biases) ? INDEX_4 : INDEX_2; | 810 | + info.groupLen = (inputs.hasBias) ? INDEX_4 : INDEX_2; |
| 811 | info.LD = info.L * info.D; | 811 | info.LD = info.L * info.D; |
| 812 | 812 | ||
| 813 | // list长度与tensor dim校验 | 813 | // list长度与tensor dim校验 |
| @@ -992,7 +992,7 @@ static aclnnStatus LstmDataProcessParams( | |||
| 992 | CHECK_RET(baseIn.weight != nullptr, ACLNN_ERR_INNER_NULLPTR); | 992 | CHECK_RET(baseIn.weight != nullptr, ACLNN_ERR_INNER_NULLPTR); |
| 993 | 993 | ||
| 994 | // bias。add | 994 | // bias。add |
| 995 | - if (inputs.has_biases) { | 995 | + if (inputs.hasBias) { |
| 996 | baseIn.bias = l0op::Add( | 996 | baseIn.bias = l0op::Add( |
| 997 | (*inputs.params)[currOffset + INDEX_2], | 997 | (*inputs.params)[currOffset + INDEX_2], |
| 998 | (*inputs.params)[currOffset + INDEX_3], | 998 | (*inputs.params)[currOffset + INDEX_3], |
| @@ -1213,12 +1213,12 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1213 | const aclTensorList *params, | 1213 | const aclTensorList *params, |
| 1214 | const aclTensorList *hx, | 1214 | const aclTensorList *hx, |
| 1215 | const aclTensor *batchSizes, | 1215 | const aclTensor *batchSizes, |
| 1216 | - bool has_biases, | 1216 | + bool hasBias, |
| 1217 | int64_t numLayers, | 1217 | int64_t numLayers, |
| 1218 | - double droupout, | 1218 | + double dropout, |
| 1219 | bool train, | 1219 | bool train, |
| 1220 | bool bidirectional, | 1220 | bool bidirectional, |
| 1221 | - bool batch_first, | 1221 | + bool batchFirst, |
| 1222 | aclTensor *output, | 1222 | aclTensor *output, |
| 1223 | aclTensor *hy, | 1223 | aclTensor *hy, |
| 1224 | aclTensor *cy, | 1224 | aclTensor *cy, |
| @@ -1232,12 +1232,12 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1232 | uint64_t *workspaceSize, | 1232 | uint64_t *workspaceSize, |
| 1233 | aclOpExecutor **executor){ | 1233 | aclOpExecutor **executor){ |
| 1234 | OP_CHECK_COMM_INPUT(workspaceSize, executor); | 1234 | OP_CHECK_COMM_INPUT(workspaceSize, executor); |
| 1235 | - L2_DFX_PHASE_1(aclnnLSTM, DFX_IN(input, params, hx, batchSizes, has_biases, numLayers, droupout, train, bidirectional, batch_first), | 1235 | + L2_DFX_PHASE_1(aclnnLSTM, DFX_IN(input, params, hx, batchSizes, hasBias, numLayers, dropout, train, bidirectional, batchFirst), |
| 1236 | DFX_OUT(output, hy, cy, iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut)); | 1236 | DFX_OUT(output, hy, cy, iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut)); |
| 1237 | 1237 | ||
| 1238 | // 判断是否进入data模式 | 1238 | // 判断是否进入data模式 |
| 1239 | if (batchSizes) { | 1239 | if (batchSizes) { |
| 1240 | - LstmDataParamsIn inputs = {input, params, hx, batchSizes, numLayers, has_biases, train, bidirectional}; | 1240 | + LstmDataParamsIn inputs = {input, params, hx, batchSizes, numLayers, hasBias, train, bidirectional}; |
| 1241 | LstmDataParamsOut outputs = {output, hy, cy, iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut}; | 1241 | LstmDataParamsOut outputs = {output, hy, cy, iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut}; |
| 1242 | return LstmDataGetWorkspaceSize(inputs, outputs, workspaceSize, executor); | 1242 | return LstmDataGetWorkspaceSize(inputs, outputs, workspaceSize, executor); |
| 1243 | } | 1243 | } |
| @@ -1254,7 +1254,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1254 | } | 1254 | } |
| 1255 | 1255 | ||
| 1256 | // 固定写法,参数检查 | 1256 | // 固定写法,参数检查 |
| 1257 | - auto ret = CheckParams(input, params, hx, has_biases, numLayers, train, bidirectional, batch_first, output, hy, cy, | 1257 | + auto ret = CheckParams(input, params, hx, hasBias, numLayers, train, bidirectional, batchFirst, output, hy, cy, |
| 1258 | iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut); | 1258 | iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut); |
| 1259 | CHECK_RET(ret == ACLNN_SUCCESS, ret); | 1259 | CHECK_RET(ret == ACLNN_SUCCESS, ret); |
| 1260 | 1260 | ||
| @@ -1275,7 +1275,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1275 | 1275 | ||
| 1276 | // 输入batchFirst转换 | 1276 | // 输入batchFirst转换 |
| 1277 | auto curInput = inputContiguous; | 1277 | auto curInput = inputContiguous; |
| 1278 | - if (batch_first == true) { | 1278 | + if (batchFirst == true) { |
| 1279 | std::vector<int64_t> perm={1, 0, 2}; | 1279 | std::vector<int64_t> perm={1, 0, 2}; |
| 1280 | auto valuePerm = uniqueExecutor.get()->AllocIntArray(perm.data(), 3); | 1280 | auto valuePerm = uniqueExecutor.get()->AllocIntArray(perm.data(), 3); |
| 1281 | curInput = l0op::Transpose(inputContiguous, valuePerm, uniqueExecutor.get()); | 1281 | curInput = l0op::Transpose(inputContiguous, valuePerm, uniqueExecutor.get()); |
| @@ -1309,7 +1309,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1309 | CHECK_RET(tanhCOutForward != nullptr, ACLNN_ERR_INNER_NULLPTR); | 1309 | CHECK_RET(tanhCOutForward != nullptr, ACLNN_ERR_INNER_NULLPTR); |
| 1310 | 1310 | ||
| 1311 | auto layerResultForward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutForward, iOutForward, jOutForward, fOutForward, oOutForward, hOutForward, cOutForward, tanhCOutForward, | 1311 | auto layerResultForward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutForward, iOutForward, jOutForward, fOutForward, oOutForward, hOutForward, cOutForward, tanhCOutForward, |
| 1312 | - "UNIDIRECTIONAL", bidirectional, train, i, has_biases, uniqueExecutor.get()); | 1312 | + "UNIDIRECTIONAL", bidirectional, train, i, hasBias, uniqueExecutor.get()); |
| 1313 | 1313 | ||
| 1314 | ProcessViewCopy(layerResultForward, iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut, i, bidirectional, "UNIDIRECTIONAL", uniqueExecutor.get()); | 1314 | ProcessViewCopy(layerResultForward, iOut, jOut, fOut, oOut, hOut, cOut, tanhCOut, i, bidirectional, "UNIDIRECTIONAL", uniqueExecutor.get()); |
| 1315 | ProcessOutputHC(layerResultForward, hyVector, cyVector, "UNIDIRECTIONAL", uniqueExecutor.get()); | 1315 | ProcessOutputHC(layerResultForward, hyVector, cyVector, "UNIDIRECTIONAL", uniqueExecutor.get()); |
| @@ -1333,7 +1333,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1333 | CHECK_RET(tanhCOutBackward != nullptr, ACLNN_ERR_INNER_NULLPTR); | 1333 | CHECK_RET(tanhCOutBackward != nullptr, ACLNN_ERR_INNER_NULLPTR); |
| 1334 | 1334 | ||
| 1335 | auto layerResultBackward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutBackward, iOutBackward, jOutBackward, fOutBackward, oOutBackward, hOutBackward, cOutBackward, tanhCOutBackward, | 1335 | auto layerResultBackward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutBackward, iOutBackward, jOutBackward, fOutBackward, oOutBackward, hOutBackward, cOutBackward, tanhCOutBackward, |
| 1336 | - "REDIRECTIONAL", bidirectional, train, i, has_biases, uniqueExecutor.get()); | 1336 | + "REDIRECTIONAL", bidirectional, train, i, hasBias, uniqueExecutor.get()); |
| 1337 | // ConcatInput | 1337 | // ConcatInput |
| 1338 | op::FVector<const aclTensor*> inputConcat; | 1338 | op::FVector<const aclTensor*> inputConcat; |
| 1339 | inputConcat.emplace_back(std::get<0>(layerResultForward)); | 1339 | inputConcat.emplace_back(std::get<0>(layerResultForward)); |
| @@ -1348,7 +1348,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1348 | } | 1348 | } |
| 1349 | 1349 | ||
| 1350 | auto outputY = curInput; | 1350 | auto outputY = curInput; |
| 1351 | - if (batch_first) { | 1351 | + if (batchFirst) { |
| 1352 | std::vector<int64_t> perm={1, 0, 2}; | 1352 | std::vector<int64_t> perm={1, 0, 2}; |
| 1353 | auto valuePerm = uniqueExecutor.get()->AllocIntArray(perm.data(), 3); | 1353 | auto valuePerm = uniqueExecutor.get()->AllocIntArray(perm.data(), 3); |
| 1354 | outputY = l0op::Transpose(curInput, valuePerm, uniqueExecutor.get()); | 1354 | outputY = l0op::Transpose(curInput, valuePerm, uniqueExecutor.get()); |
| @@ -1396,7 +1396,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1396 | CHECK_RET(cOutForward != nullptr, ACLNN_ERR_INNER_NULLPTR); | 1396 | CHECK_RET(cOutForward != nullptr, ACLNN_ERR_INNER_NULLPTR); |
| 1397 | 1397 | ||
| 1398 | auto layerResultForward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutForward, iOutForward, jOutForward, fOutForward, oOutForward, hOutForward, cOutForward, tanhCOutForward, | 1398 | auto layerResultForward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutForward, iOutForward, jOutForward, fOutForward, oOutForward, hOutForward, cOutForward, tanhCOutForward, |
| 1399 | - "UNIDIRECTIONAL", bidirectional, train, i, has_biases, uniqueExecutor.get()); | 1399 | + "UNIDIRECTIONAL", bidirectional, train, i, hasBias, uniqueExecutor.get()); |
| 1400 | ProcessOutputHC(layerResultForward, hyVector, cyVector, "UNIDIRECTIONAL", uniqueExecutor.get()); | 1400 | ProcessOutputHC(layerResultForward, hyVector, cyVector, "UNIDIRECTIONAL", uniqueExecutor.get()); |
| 1401 | 1401 | ||
| 1402 | if (bidirectional == true) { | 1402 | if (bidirectional == true) { |
| @@ -1408,7 +1408,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1408 | CHECK_RET(yOutBackward != nullptr, ACLNN_ERR_INNER_NULLPTR); | 1408 | CHECK_RET(yOutBackward != nullptr, ACLNN_ERR_INNER_NULLPTR); |
| 1409 | 1409 | ||
| 1410 | auto layerResultBackward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutBackward, iOutBackward, jOutBackward, fOutBackward, oOutBackward, hOutBackward, cOutBackward, tanhCOutBackward, | 1410 | auto layerResultBackward = LstmSingleLayerDirec(curInput, paramsContiguous, hxContiguous, yOutBackward, iOutBackward, jOutBackward, fOutBackward, oOutBackward, hOutBackward, cOutBackward, tanhCOutBackward, |
| 1411 | - "REDIRECTIONAL", bidirectional, train, i, has_biases, uniqueExecutor.get()); | 1411 | + "REDIRECTIONAL", bidirectional, train, i, hasBias, uniqueExecutor.get()); |
| 1412 | // ConcatInput | 1412 | // ConcatInput |
| 1413 | op::FVector<const aclTensor*> inputConcat; | 1413 | op::FVector<const aclTensor*> inputConcat; |
| 1414 | inputConcat.emplace_back(std::get<0>(layerResultForward)); | 1414 | inputConcat.emplace_back(std::get<0>(layerResultForward)); |
| @@ -1421,7 +1421,7 @@ aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 1421 | } | 1421 | } |
| 1422 | } | 1422 | } |
| 1423 | auto outputY = curInput; | 1423 | auto outputY = curInput; |
| 1424 | - if (batch_first) { | 1424 | + if (batchFirst) { |
| 1425 | std::vector<int64_t> perm={1, 0, 2}; | 1425 | std::vector<int64_t> perm={1, 0, 2}; |
| 1426 | auto valuePerm = uniqueExecutor.get()->AllocIntArray(perm.data(), 3); | 1426 | auto valuePerm = uniqueExecutor.get()->AllocIntArray(perm.data(), 3); |
| 1427 | outputY = l0op::Transpose(curInput, valuePerm, uniqueExecutor.get()); | 1427 | outputY = l0op::Transpose(curInput, valuePerm, uniqueExecutor.get()); |
| @@ -22,12 +22,12 @@ ACLNN_API aclnnStatus aclnnLSTMGetWorkspaceSize( | |||
| 22 | const aclTensorList *params, | 22 | const aclTensorList *params, |
| 23 | const aclTensorList *hx, | 23 | const aclTensorList *hx, |
| 24 | const aclTensor *batchSizes, | 24 | const aclTensor *batchSizes, |
| 25 | - bool has_biases, | 25 | + bool hasBias, |
| 26 | int64_t numLayers, | 26 | int64_t numLayers, |
| 27 | - double droupout, | 27 | + double dropout, |
| 28 | bool train, | 28 | bool train, |
| 29 | bool bidirectional, | 29 | bool bidirectional, |
| 30 | - bool batch_first, | 30 | + bool batchFirst, |
| 31 | aclTensor *output, | 31 | aclTensor *output, |
| 32 | aclTensor *hy, | 32 | aclTensor *hy, |
| 33 | aclTensor *cy, | 33 | aclTensor *cy, |
| @@ -388,7 +388,7 @@ aclnnStatus aclnnLstmBackward( | |||
| 388 | <tr> | 388 | <tr> |
| 389 | <td>o</td> | 389 | <td>o</td> |
| 390 | <td>输入</td> | 390 | <td>输入</td> |
| 391 | - <td>LSTM正向中每层输出门的激活值。对于公式中的o。</td> | 391 | + <td>LSTM正向中每层输出门的激活值。对应公式中的o。</td> |
| 392 | <td><ul><li>列表长度为 D * num_layers。</li><li>多层双向时tensor间按先双向后多层排布。</li><li>数据类型与input一致。</li></ul></td> | 392 | <td><ul><li>列表长度为 D * num_layers。</li><li>多层双向时tensor间按先双向后多层排布。</li><li>数据类型与input一致。</li></ul></td> |
| 393 | <td>FLOAT32、FLOAT16</td> | 393 | <td>FLOAT32、FLOAT16</td> |
| 394 | <td>ND</td> | 394 | <td>ND</td> |