| Files | Last commit | Last update |
|---|---|---|
修复 ops-nn 接口文档扫描问题(错别字/标点/多字,117处) Co-authored-by: liujing987913<liujing407@h-partners.com> # message auto-generated for no-merge-commit merge: !13766 merge master into master 修复 ops-nn 接口文档扫描问题(错别字/标点/多字,117处) Created-by: liujing987913 Commit-by: liujing987913 Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> - 背景:大模型扫描发现 ops-nn 接口文档问题 117 处 - 修改分类:多字/中文多字 70、同音字 17、形近字 3、引号未成对 4、代码括号 2、术语拼写 2、字母顺序 2(文本替换 100 处);MD 结构 17 处(tab→空格 6、列表空行 9、连续空行 2) - 涉及文件:docs 目录下 85 个接口文档 md - 验证:git diff 确认为纯文本替换(100 处)+ 纯结构操作(17 处),无代码内容误改;已人工复核 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue [#8245](https://gitcode.com/cann/ops-nn/issues/8245) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> 本次 PR 更新了 ops-nn 接口文档 85 个 md 文件,修正错别字/标点/多字 100 处、MD 结构 17 处,详见 diff。 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!13766 | 15 days ago | |
fix example code and md Co-authored-by: shilulu<shilulu8@huawei.com> # message auto-generated for no-merge-commit merge: !10363 merge master into master fix example code and md Created-by: guijianwei Commit-by: shilulu Merged-by: cann-robot Description: ## 描述 <!--在这里详细描述你的改动,包括改动的原因和所采取的方法。--> 激活类算子issue修复,问题内容详见issue | 编号 | 文档 | 修复内容 | 涉及文件(md + cpp 同步) | 状态 | |---|---|---|---|---| | 367 | aclnnDequantSwigluQuantV2.md | weightScale 创建后补 CHECK_RET(ret == ACL_SUCCESS, return ret);,与其他 tensor 创建一致 | quant/dequant_swiglu_quant/docs/aclnnDequantSwigluQuantV2.md、examples/test_aclnn_dequant_swiglu_quant_v2.cpp | 已修复 | | 368 | aclnnDequantSwigluQuantV2.md | host 数据元素个数补齐至与 shape 一致:weightScaleData/biasData 补至 64、activationScaleData 补至 2、scaleHostData 补至 32、outHostData 补至 64,消除 aclrtMemcpy 越界读 | 同上 | 已修复 | | 369 | aclnnDequantSwigluQuantV2.md | 按参数表默认值改正:gluAlpha = 1.702; gluBias = 1.0;(原示例两值互换) | 同上 | 已修复 | | 427 | aclnnSwiGluQuantV2.md | x 的 host 数据为 float,tensor 类型由 ACL_BF16 改为 ACL_FLOAT(参数表支持 FLOAT16/BFLOAT16/FLOAT),消除 float 字节流按 BF16 重解释导致的错误数值 | quant/swi_glu_quant/docs/aclnnSwiGluQuantV2.md、examples/test_aclnn_swi_glu_quant_v2.cpp | 已修复 | | 429 | aclnnSwiGluQuantV2.md | groupIndexHostData 由 std::vector<float> 改为 std::vector<int32_t>,与 ACL_INT32 匹配(float 1.0 字节重解释为 int32 会得到 1065353216) | 同上 | 已修复 | | 430 | aclnnSwiGluQuantV2.md | outDeviceAddr,size 逗号后补空格 | 同上(md) | 已修复 | | 476 | aclnnSwiGluQuant.md | 注释「// 创建scale aclTensor」改为「// 创建smoothScales aclTensor」,与实际创建的变量一致 | quant/swi_glu_quant/docs/aclnnSwiGluQuant.md(v2 文档及两份 cpp 同步修正同类注释) | 已修复(工作区已有,本次复核) | | 513 | aclnnDequantSwigluQuant.md | xHostData 由 float 改为 std::vector<aclFloat16>,与 ACL_FLOAT16 匹配 | quant/dequant_swiglu_quant/docs/aclnnDequantSwigluQuant.md、examples/test_aclnn_dequant_swiglu_quant.cpp | 已修复(工作区已有,本次复核) | | 2087 | aclnnErfinv&aclnnInplaceErfinv.md | 输入数据替换为 erfinv 定义域 [-1,1] 内的典型值(-0.95…0.99),消除大量 NaN/Inf 误导 | activation/erfinv/docs/…md、examples/test_aclnn_erfinv.cpp、test_aclnn_inplace_erfinv.cpp | 已修复(工作区已有,本次复核) | | 2430 | aclnnSquaredRelu.md | LOG_PRINT("mean input…") 改为 "input…"(另将 "mean result…" 同步改为 "output…") | activation/squared_relu/docs/aclnnSquaredRelu.md、examples/test_aclnn_squared_relu.cpp | 已修复(工作区已有,本次复核) | | 2431 | aclnnSquaredRelu.md | workspaceSize 初始化由硬编码 16*1024*1024 改为 0,由第一段接口返回实际值 | 同上 | 已修复(工作区已有,本次复核) | | 2443 | aclnnHardswishBackwardV2.md | return ret;); 去掉多余分号,改为 return ret); | activation/hard_swish_grad_v2/docs/aclnnHardswishBackwardV2.md、examples/test_aclnn_hard_swish_backward_v2.cpp | 已修复(工作区已有,本次复核) | ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #000--> Issue [#5821](https://gitcode.com/cann/ops-nn/issues/5821) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> | # | op_name | 验证命令 | 结果 | |---|---|---|---| | 1 | dequant_swiglu_quant | bash build.sh --run_example dequant_swiglu_quant eager --example_name=dequant_swiglu_quant | **success** | | 2 | dequant_swiglu_quant | bash build.sh --run_example dequant_swiglu_quant eager --example_name=dequant_swiglu_quant_v2 | **success** | | 3 | swi_glu_quant | bash build.sh --run_example swi_glu_quant eager --example_name=swi_glu_quant | **success** | | 4 | swi_glu_quant | bash build.sh --run_example swi_glu_quant eager --example_name=swi_glu_quant_v2 | **success** | | 5 | erfinv | bash build.sh --run_example erfinv eager --example_name=erfinv | **success** | | 6 | erfinv | bash build.sh --run_example erfinv eager --example_name=inplace_erfinv | **success** | | 7 | squared_relu | bash build.sh --run_example squared_relu eager --example_name=squared_relu | **success** | | 8 | hard_swish_grad_v2 | bash build.sh --run_example hard_swish_grad_v2 eager --example_name=hard_swish_backward_v2 | **success** | | 9 | hard_shrink | bash build.sh --run_example hard_shrink eager --example_name=hard_shrink | **success** | ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [x] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!10363 | 2 months ago | |
issue修复 Co-authored-by: guijianwei<guijianwei@huawei.com> # message auto-generated for no-merge-commit merge: !13494 merge master into master issue修复 Created-by: guijianwei Commit-by: guijianwei Merged-by: cann-robot Description: ## 描述 修复 cann/ops-nn 缺陷/文档反馈(#7757、#7756、#7741、#7743),共 11 个提交: ### 112e84b7b fix(squared_relu):非连续 out 静默错位 + out shape 不一致越界写 - 参照 sigmoid 将 SquaredRelu 迁移为手写 aclnn 两段式接口(ACLNNTYPE aclnn_exclude,新增 op_api/),L1 完成入参校验(空指针 161001、dtype 及 out dtype 一致性 161002、out 与 input shape 一致性 161002、维度数 ≤8 161002),通过 l0op::ViewCopy 将结果按 out 的逻辑视图回写——非连续 out 从「忽略 strides 静默错位」变为「正确支持」 - 顺带关闭该算子 rank≥26 静默失败:L1 直接持有 aclTensor*,OP_CHECK_MAX_DIM 在框架 shape 物化(gert::Shape 25 维上限)之前拦截 - op_host tiling 同步补 out 容量兜底校验(防越界写;动态维/未知 rank 跳过),保护 graph-mode 路径 - 头文件原型与原自动生成头逐字一致(const aclTensor* out,含 aeec6f2b6 对齐 stream 参数),不破坏存量调用方;L0 头文件命名 squared_relu_op_api.h 避免与 op_kernel/squared_relu.h 包内重名(API_CHECK 门禁) ### 1063d885b perf(squared_relu):连续 out 直写优化 - IsContiguous(out) 分流:连续 out 由 kernel 直接写入(省去一份 out 大小的中间 tensor 与回写拷贝;AllocTensor 内存经实证从用户 workspace 切出);非连续 out 保持中间 tensor + ViewCopy - 连带修正 tiling out 校验语义为容量兜底(直写路径 tiling 看到的是 storageDims,可能大于逻辑 view),精确 shape 一致性由 L1 保证 ### 84b1d3b18 + 1367a19ca docs(situ_glu):#7741/#7743 资料对码 - rank 9–25 按兼容性决策不做代码拦截(kernel 合轴后与 rank 无关,实测 rank 25 与 rank 8 结果逐字节一致),维度声明 1-8 → 1-25 - 错误码表按真机对码订正:561001 三子项(dim 越界/奇数切分/shape 维度)删除——两段式不回调 infershape,561001 不可达;dim/out 维度项实测 561002;**out dtype 与 x 不一致实测 161002**(生成 wrapper 按 dtype 组合选 bin,参数校验段拦截,#7743 D 项) - 约束说明一句话收敛:「受框架约束,x的维度数最多支持25」 ### 检视意见闭环(9ef2d478b / 81654c645 / 8c890f3a8) EN 文档回退(走专用合入流程)、situ_glu 约束收敛、squared_relu tiling 补 rank≤8 对齐 L1 覆盖 graph 路径、op_api UT bf16 判据与实现对齐、README 补非连续 out 说明 ### 767c87e18 / 995f68e76 / cf6068d51 torchapi 资料同步 1-25、新增文件版权年份 2026、op_api 头文件重命名 ## 关联的Issue - 关联Issue [cann/ops-nn#7757](https://gitcode.com/cann/ops-nn/issues/7757)(非连续 out 静默错位) - 关联Issue [cann/ops-nn#7756](https://gitcode.com/cann/ops-nn/issues/7756)(out shape 不一致未拦截并越界写) - 关联Issue [cann/ops-nn#7741](https://gitcode.com/cann/ops-nn/issues/7741)(rank 上限资料与行为不一致) - 关联Issue [cann/ops-nn#7743](https://gitcode.com/cann/ops-nn/issues/7743)(错误码表子项与实测不符) ## 测试 - **UT**(全绿):op_api 14 例(含 strides/storageDims 构造的非连续 out 正向、shape 不一致、rank>8、dtype 不一致等负向);op_host 26 例(squared_relu 15 含 tiling rank-9/容量不足负向,situ_glu 11) - **ST**(ATK,Atlas A2 910B3,pyaclnn vs cpu golden):**201/201 全部通过**(3 条大 shape 用例在空卡 NPU3 单跑通过,设备 HBM 资源竞争与实现无关) - **真机**(CANN 9.3.0,按 issue 原版 repro 验证): | 用例 | 修复前 | 修复后 | |---|---|---| | #7757 非连续 out | ret=0,逻辑视图错值 4 | ret=0,**错值 0** | | #7756 out [4x4]/input [4x8] | ret=0,越界写 16 元素 | **ret=161002,越界写 0** | | squared_relu rank=26 | ret=0、ws=0 静默不执行 | **ret=161002** | | situ_glu rank=25 / dim 越界 / out dtype | 561001 声明不可达 / 561002 声明错误 | 资料对码 1-25 / **561002 / 161002** | | CTRL 合法形态回归 | — | 全部不受影响 | ## 文档更新 - activation/squared_relu/docs/aclnnSquaredRelu.md:out「非连续Tensor」× → √,错误码表补 161002 各行,约束说明同步;README.md 补非连续 out 说明(**EN 文档按检视意见回退,走专用合入流程**) - activation/situ_glu/docs/aclnnSituGlu.md:维度 1-25、错误码表对码(561001 删除、out dtype → 161002)、约束说明;torchapi_situ_glu.md 维度同步 1-25(**EN 文档同上回退**) ## 类型标签 - [x] Bug修复 - [x] 新特性 - [x] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!13494 | 18 days ago | |
format cpp Co-authored-by: yang-di52<yangdi52@huawei.com> # message auto-generated for no-merge-commit merge: !6784 merge issue_fix into master format cpp Created-by: yang-di52 Commit-by: yang-di52 Merged-by: cann-robot Description: ## 描述 批量刷新cpp代码格式 ## 关联的Issue [#3791](https://gitcode.com/cann/ops-nn/issues/3791) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:代码格式化 ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!6784 | 4 months ago | |
issue修复 Co-authored-by: guijianwei<guijianwei@huawei.com> # message auto-generated for no-merge-commit merge: !13494 merge master into master issue修复 Created-by: guijianwei Commit-by: guijianwei Merged-by: cann-robot Description: ## 描述 修复 cann/ops-nn 缺陷/文档反馈(#7757、#7756、#7741、#7743),共 11 个提交: ### 112e84b7b fix(squared_relu):非连续 out 静默错位 + out shape 不一致越界写 - 参照 sigmoid 将 SquaredRelu 迁移为手写 aclnn 两段式接口(ACLNNTYPE aclnn_exclude,新增 op_api/),L1 完成入参校验(空指针 161001、dtype 及 out dtype 一致性 161002、out 与 input shape 一致性 161002、维度数 ≤8 161002),通过 l0op::ViewCopy 将结果按 out 的逻辑视图回写——非连续 out 从「忽略 strides 静默错位」变为「正确支持」 - 顺带关闭该算子 rank≥26 静默失败:L1 直接持有 aclTensor*,OP_CHECK_MAX_DIM 在框架 shape 物化(gert::Shape 25 维上限)之前拦截 - op_host tiling 同步补 out 容量兜底校验(防越界写;动态维/未知 rank 跳过),保护 graph-mode 路径 - 头文件原型与原自动生成头逐字一致(const aclTensor* out,含 aeec6f2b6 对齐 stream 参数),不破坏存量调用方;L0 头文件命名 squared_relu_op_api.h 避免与 op_kernel/squared_relu.h 包内重名(API_CHECK 门禁) ### 1063d885b perf(squared_relu):连续 out 直写优化 - IsContiguous(out) 分流:连续 out 由 kernel 直接写入(省去一份 out 大小的中间 tensor 与回写拷贝;AllocTensor 内存经实证从用户 workspace 切出);非连续 out 保持中间 tensor + ViewCopy - 连带修正 tiling out 校验语义为容量兜底(直写路径 tiling 看到的是 storageDims,可能大于逻辑 view),精确 shape 一致性由 L1 保证 ### 84b1d3b18 + 1367a19ca docs(situ_glu):#7741/#7743 资料对码 - rank 9–25 按兼容性决策不做代码拦截(kernel 合轴后与 rank 无关,实测 rank 25 与 rank 8 结果逐字节一致),维度声明 1-8 → 1-25 - 错误码表按真机对码订正:561001 三子项(dim 越界/奇数切分/shape 维度)删除——两段式不回调 infershape,561001 不可达;dim/out 维度项实测 561002;**out dtype 与 x 不一致实测 161002**(生成 wrapper 按 dtype 组合选 bin,参数校验段拦截,#7743 D 项) - 约束说明一句话收敛:「受框架约束,x的维度数最多支持25」 ### 检视意见闭环(9ef2d478b / 81654c645 / 8c890f3a8) EN 文档回退(走专用合入流程)、situ_glu 约束收敛、squared_relu tiling 补 rank≤8 对齐 L1 覆盖 graph 路径、op_api UT bf16 判据与实现对齐、README 补非连续 out 说明 ### 767c87e18 / 995f68e76 / cf6068d51 torchapi 资料同步 1-25、新增文件版权年份 2026、op_api 头文件重命名 ## 关联的Issue - 关联Issue [cann/ops-nn#7757](https://gitcode.com/cann/ops-nn/issues/7757)(非连续 out 静默错位) - 关联Issue [cann/ops-nn#7756](https://gitcode.com/cann/ops-nn/issues/7756)(out shape 不一致未拦截并越界写) - 关联Issue [cann/ops-nn#7741](https://gitcode.com/cann/ops-nn/issues/7741)(rank 上限资料与行为不一致) - 关联Issue [cann/ops-nn#7743](https://gitcode.com/cann/ops-nn/issues/7743)(错误码表子项与实测不符) ## 测试 - **UT**(全绿):op_api 14 例(含 strides/storageDims 构造的非连续 out 正向、shape 不一致、rank>8、dtype 不一致等负向);op_host 26 例(squared_relu 15 含 tiling rank-9/容量不足负向,situ_glu 11) - **ST**(ATK,Atlas A2 910B3,pyaclnn vs cpu golden):**201/201 全部通过**(3 条大 shape 用例在空卡 NPU3 单跑通过,设备 HBM 资源竞争与实现无关) - **真机**(CANN 9.3.0,按 issue 原版 repro 验证): | 用例 | 修复前 | 修复后 | |---|---|---| | #7757 非连续 out | ret=0,逻辑视图错值 4 | ret=0,**错值 0** | | #7756 out [4x4]/input [4x8] | ret=0,越界写 16 元素 | **ret=161002,越界写 0** | | squared_relu rank=26 | ret=0、ws=0 静默不执行 | **ret=161002** | | situ_glu rank=25 / dim 越界 / out dtype | 561001 声明不可达 / 561002 声明错误 | 资料对码 1-25 / **561002 / 161002** | | CTRL 合法形态回归 | — | 全部不受影响 | ## 文档更新 - activation/squared_relu/docs/aclnnSquaredRelu.md:out「非连续Tensor」× → √,错误码表补 161002 各行,约束说明同步;README.md 补非连续 out 说明(**EN 文档按检视意见回退,走专用合入流程**) - activation/situ_glu/docs/aclnnSituGlu.md:维度 1-25、错误码表对码(561001 删除、out dtype → 161002)、约束说明;torchapi_situ_glu.md 维度同步 1-25(**EN 文档同上回退**) ## 类型标签 - [x] Bug修复 - [x] 新特性 - [x] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!13494 | 18 days ago | |
format cpp Co-authored-by: yang-di52<yangdi52@huawei.com> # message auto-generated for no-merge-commit merge: !6784 merge issue_fix into master format cpp Created-by: yang-di52 Commit-by: yang-di52 Merged-by: cann-robot Description: ## 描述 批量刷新cpp代码格式 ## 关联的Issue [#3791](https://gitcode.com/cann/ops-nn/issues/3791) ## 测试 <!--描述进行了哪些测试来验证你的改动。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [x] 其他,请描述:代码格式化 ## AI/Agent生成声明 <!-- [x] 表示选中 --> - [ ] AI辅助编写 See merge request: cann/ops-nn!6784 | 4 months ago | |
issue修复 Co-authored-by: guijianwei<guijianwei@huawei.com> # message auto-generated for no-merge-commit merge: !13494 merge master into master issue修复 Created-by: guijianwei Commit-by: guijianwei Merged-by: cann-robot Description: ## 描述 修复 cann/ops-nn 缺陷/文档反馈(#7757、#7756、#7741、#7743),共 11 个提交: ### 112e84b7b fix(squared_relu):非连续 out 静默错位 + out shape 不一致越界写 - 参照 sigmoid 将 SquaredRelu 迁移为手写 aclnn 两段式接口(ACLNNTYPE aclnn_exclude,新增 op_api/),L1 完成入参校验(空指针 161001、dtype 及 out dtype 一致性 161002、out 与 input shape 一致性 161002、维度数 ≤8 161002),通过 l0op::ViewCopy 将结果按 out 的逻辑视图回写——非连续 out 从「忽略 strides 静默错位」变为「正确支持」 - 顺带关闭该算子 rank≥26 静默失败:L1 直接持有 aclTensor*,OP_CHECK_MAX_DIM 在框架 shape 物化(gert::Shape 25 维上限)之前拦截 - op_host tiling 同步补 out 容量兜底校验(防越界写;动态维/未知 rank 跳过),保护 graph-mode 路径 - 头文件原型与原自动生成头逐字一致(const aclTensor* out,含 aeec6f2b6 对齐 stream 参数),不破坏存量调用方;L0 头文件命名 squared_relu_op_api.h 避免与 op_kernel/squared_relu.h 包内重名(API_CHECK 门禁) ### 1063d885b perf(squared_relu):连续 out 直写优化 - IsContiguous(out) 分流:连续 out 由 kernel 直接写入(省去一份 out 大小的中间 tensor 与回写拷贝;AllocTensor 内存经实证从用户 workspace 切出);非连续 out 保持中间 tensor + ViewCopy - 连带修正 tiling out 校验语义为容量兜底(直写路径 tiling 看到的是 storageDims,可能大于逻辑 view),精确 shape 一致性由 L1 保证 ### 84b1d3b18 + 1367a19ca docs(situ_glu):#7741/#7743 资料对码 - rank 9–25 按兼容性决策不做代码拦截(kernel 合轴后与 rank 无关,实测 rank 25 与 rank 8 结果逐字节一致),维度声明 1-8 → 1-25 - 错误码表按真机对码订正:561001 三子项(dim 越界/奇数切分/shape 维度)删除——两段式不回调 infershape,561001 不可达;dim/out 维度项实测 561002;**out dtype 与 x 不一致实测 161002**(生成 wrapper 按 dtype 组合选 bin,参数校验段拦截,#7743 D 项) - 约束说明一句话收敛:「受框架约束,x的维度数最多支持25」 ### 检视意见闭环(9ef2d478b / 81654c645 / 8c890f3a8) EN 文档回退(走专用合入流程)、situ_glu 约束收敛、squared_relu tiling 补 rank≤8 对齐 L1 覆盖 graph 路径、op_api UT bf16 判据与实现对齐、README 补非连续 out 说明 ### 767c87e18 / 995f68e76 / cf6068d51 torchapi 资料同步 1-25、新增文件版权年份 2026、op_api 头文件重命名 ## 关联的Issue - 关联Issue [cann/ops-nn#7757](https://gitcode.com/cann/ops-nn/issues/7757)(非连续 out 静默错位) - 关联Issue [cann/ops-nn#7756](https://gitcode.com/cann/ops-nn/issues/7756)(out shape 不一致未拦截并越界写) - 关联Issue [cann/ops-nn#7741](https://gitcode.com/cann/ops-nn/issues/7741)(rank 上限资料与行为不一致) - 关联Issue [cann/ops-nn#7743](https://gitcode.com/cann/ops-nn/issues/7743)(错误码表子项与实测不符) ## 测试 - **UT**(全绿):op_api 14 例(含 strides/storageDims 构造的非连续 out 正向、shape 不一致、rank>8、dtype 不一致等负向);op_host 26 例(squared_relu 15 含 tiling rank-9/容量不足负向,situ_glu 11) - **ST**(ATK,Atlas A2 910B3,pyaclnn vs cpu golden):**201/201 全部通过**(3 条大 shape 用例在空卡 NPU3 单跑通过,设备 HBM 资源竞争与实现无关) - **真机**(CANN 9.3.0,按 issue 原版 repro 验证): | 用例 | 修复前 | 修复后 | |---|---|---| | #7757 非连续 out | ret=0,逻辑视图错值 4 | ret=0,**错值 0** | | #7756 out [4x4]/input [4x8] | ret=0,越界写 16 元素 | **ret=161002,越界写 0** | | squared_relu rank=26 | ret=0、ws=0 静默不执行 | **ret=161002** | | situ_glu rank=25 / dim 越界 / out dtype | 561001 声明不可达 / 561002 声明错误 | 资料对码 1-25 / **561002 / 161002** | | CTRL 合法形态回归 | — | 全部不受影响 | ## 文档更新 - activation/squared_relu/docs/aclnnSquaredRelu.md:out「非连续Tensor」× → √,错误码表补 161002 各行,约束说明同步;README.md 补非连续 out 说明(**EN 文档按检视意见回退,走专用合入流程**) - activation/situ_glu/docs/aclnnSituGlu.md:维度 1-25、错误码表对码(561001 删除、out dtype → 161002)、约束说明;torchapi_situ_glu.md 维度同步 1-25(**EN 文档同上回退**) ## 类型标签 - [x] Bug修复 - [x] 新特性 - [x] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!13494 | 18 days ago | |
issue修复 Co-authored-by: guijianwei<guijianwei@huawei.com> # message auto-generated for no-merge-commit merge: !13494 merge master into master issue修复 Created-by: guijianwei Commit-by: guijianwei Merged-by: cann-robot Description: ## 描述 修复 cann/ops-nn 缺陷/文档反馈(#7757、#7756、#7741、#7743),共 11 个提交: ### 112e84b7b fix(squared_relu):非连续 out 静默错位 + out shape 不一致越界写 - 参照 sigmoid 将 SquaredRelu 迁移为手写 aclnn 两段式接口(ACLNNTYPE aclnn_exclude,新增 op_api/),L1 完成入参校验(空指针 161001、dtype 及 out dtype 一致性 161002、out 与 input shape 一致性 161002、维度数 ≤8 161002),通过 l0op::ViewCopy 将结果按 out 的逻辑视图回写——非连续 out 从「忽略 strides 静默错位」变为「正确支持」 - 顺带关闭该算子 rank≥26 静默失败:L1 直接持有 aclTensor*,OP_CHECK_MAX_DIM 在框架 shape 物化(gert::Shape 25 维上限)之前拦截 - op_host tiling 同步补 out 容量兜底校验(防越界写;动态维/未知 rank 跳过),保护 graph-mode 路径 - 头文件原型与原自动生成头逐字一致(const aclTensor* out,含 aeec6f2b6 对齐 stream 参数),不破坏存量调用方;L0 头文件命名 squared_relu_op_api.h 避免与 op_kernel/squared_relu.h 包内重名(API_CHECK 门禁) ### 1063d885b perf(squared_relu):连续 out 直写优化 - IsContiguous(out) 分流:连续 out 由 kernel 直接写入(省去一份 out 大小的中间 tensor 与回写拷贝;AllocTensor 内存经实证从用户 workspace 切出);非连续 out 保持中间 tensor + ViewCopy - 连带修正 tiling out 校验语义为容量兜底(直写路径 tiling 看到的是 storageDims,可能大于逻辑 view),精确 shape 一致性由 L1 保证 ### 84b1d3b18 + 1367a19ca docs(situ_glu):#7741/#7743 资料对码 - rank 9–25 按兼容性决策不做代码拦截(kernel 合轴后与 rank 无关,实测 rank 25 与 rank 8 结果逐字节一致),维度声明 1-8 → 1-25 - 错误码表按真机对码订正:561001 三子项(dim 越界/奇数切分/shape 维度)删除——两段式不回调 infershape,561001 不可达;dim/out 维度项实测 561002;**out dtype 与 x 不一致实测 161002**(生成 wrapper 按 dtype 组合选 bin,参数校验段拦截,#7743 D 项) - 约束说明一句话收敛:「受框架约束,x的维度数最多支持25」 ### 检视意见闭环(9ef2d478b / 81654c645 / 8c890f3a8) EN 文档回退(走专用合入流程)、situ_glu 约束收敛、squared_relu tiling 补 rank≤8 对齐 L1 覆盖 graph 路径、op_api UT bf16 判据与实现对齐、README 补非连续 out 说明 ### 767c87e18 / 995f68e76 / cf6068d51 torchapi 资料同步 1-25、新增文件版权年份 2026、op_api 头文件重命名 ## 关联的Issue - 关联Issue [cann/ops-nn#7757](https://gitcode.com/cann/ops-nn/issues/7757)(非连续 out 静默错位) - 关联Issue [cann/ops-nn#7756](https://gitcode.com/cann/ops-nn/issues/7756)(out shape 不一致未拦截并越界写) - 关联Issue [cann/ops-nn#7741](https://gitcode.com/cann/ops-nn/issues/7741)(rank 上限资料与行为不一致) - 关联Issue [cann/ops-nn#7743](https://gitcode.com/cann/ops-nn/issues/7743)(错误码表子项与实测不符) ## 测试 - **UT**(全绿):op_api 14 例(含 strides/storageDims 构造的非连续 out 正向、shape 不一致、rank>8、dtype 不一致等负向);op_host 26 例(squared_relu 15 含 tiling rank-9/容量不足负向,situ_glu 11) - **ST**(ATK,Atlas A2 910B3,pyaclnn vs cpu golden):**201/201 全部通过**(3 条大 shape 用例在空卡 NPU3 单跑通过,设备 HBM 资源竞争与实现无关) - **真机**(CANN 9.3.0,按 issue 原版 repro 验证): | 用例 | 修复前 | 修复后 | |---|---|---| | #7757 非连续 out | ret=0,逻辑视图错值 4 | ret=0,**错值 0** | | #7756 out [4x4]/input [4x8] | ret=0,越界写 16 元素 | **ret=161002,越界写 0** | | squared_relu rank=26 | ret=0、ws=0 静默不执行 | **ret=161002** | | situ_glu rank=25 / dim 越界 / out dtype | 561001 声明不可达 / 561002 声明错误 | 资料对码 1-25 / **561002 / 161002** | | CTRL 合法形态回归 | — | 全部不受影响 | ## 文档更新 - activation/squared_relu/docs/aclnnSquaredRelu.md:out「非连续Tensor」× → √,错误码表补 161002 各行,约束说明同步;README.md 补非连续 out 说明(**EN 文档按检视意见回退,走专用合入流程**) - activation/situ_glu/docs/aclnnSituGlu.md:维度 1-25、错误码表对码(561001 删除、out dtype → 161002)、约束说明;torchapi_situ_glu.md 维度同步 1-25(**EN 文档同上回退**) ## 类型标签 - [x] Bug修复 - [x] 新特性 - [x] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!13494 | 18 days ago | |
issue修复 Co-authored-by: guijianwei<guijianwei@huawei.com> # message auto-generated for no-merge-commit merge: !13494 merge master into master issue修复 Created-by: guijianwei Commit-by: guijianwei Merged-by: cann-robot Description: ## 描述 修复 cann/ops-nn 缺陷/文档反馈(#7757、#7756、#7741、#7743),共 11 个提交: ### 112e84b7b fix(squared_relu):非连续 out 静默错位 + out shape 不一致越界写 - 参照 sigmoid 将 SquaredRelu 迁移为手写 aclnn 两段式接口(ACLNNTYPE aclnn_exclude,新增 op_api/),L1 完成入参校验(空指针 161001、dtype 及 out dtype 一致性 161002、out 与 input shape 一致性 161002、维度数 ≤8 161002),通过 l0op::ViewCopy 将结果按 out 的逻辑视图回写——非连续 out 从「忽略 strides 静默错位」变为「正确支持」 - 顺带关闭该算子 rank≥26 静默失败:L1 直接持有 aclTensor*,OP_CHECK_MAX_DIM 在框架 shape 物化(gert::Shape 25 维上限)之前拦截 - op_host tiling 同步补 out 容量兜底校验(防越界写;动态维/未知 rank 跳过),保护 graph-mode 路径 - 头文件原型与原自动生成头逐字一致(const aclTensor* out,含 aeec6f2b6 对齐 stream 参数),不破坏存量调用方;L0 头文件命名 squared_relu_op_api.h 避免与 op_kernel/squared_relu.h 包内重名(API_CHECK 门禁) ### 1063d885b perf(squared_relu):连续 out 直写优化 - IsContiguous(out) 分流:连续 out 由 kernel 直接写入(省去一份 out 大小的中间 tensor 与回写拷贝;AllocTensor 内存经实证从用户 workspace 切出);非连续 out 保持中间 tensor + ViewCopy - 连带修正 tiling out 校验语义为容量兜底(直写路径 tiling 看到的是 storageDims,可能大于逻辑 view),精确 shape 一致性由 L1 保证 ### 84b1d3b18 + 1367a19ca docs(situ_glu):#7741/#7743 资料对码 - rank 9–25 按兼容性决策不做代码拦截(kernel 合轴后与 rank 无关,实测 rank 25 与 rank 8 结果逐字节一致),维度声明 1-8 → 1-25 - 错误码表按真机对码订正:561001 三子项(dim 越界/奇数切分/shape 维度)删除——两段式不回调 infershape,561001 不可达;dim/out 维度项实测 561002;**out dtype 与 x 不一致实测 161002**(生成 wrapper 按 dtype 组合选 bin,参数校验段拦截,#7743 D 项) - 约束说明一句话收敛:「受框架约束,x的维度数最多支持25」 ### 检视意见闭环(9ef2d478b / 81654c645 / 8c890f3a8) EN 文档回退(走专用合入流程)、situ_glu 约束收敛、squared_relu tiling 补 rank≤8 对齐 L1 覆盖 graph 路径、op_api UT bf16 判据与实现对齐、README 补非连续 out 说明 ### 767c87e18 / 995f68e76 / cf6068d51 torchapi 资料同步 1-25、新增文件版权年份 2026、op_api 头文件重命名 ## 关联的Issue - 关联Issue [cann/ops-nn#7757](https://gitcode.com/cann/ops-nn/issues/7757)(非连续 out 静默错位) - 关联Issue [cann/ops-nn#7756](https://gitcode.com/cann/ops-nn/issues/7756)(out shape 不一致未拦截并越界写) - 关联Issue [cann/ops-nn#7741](https://gitcode.com/cann/ops-nn/issues/7741)(rank 上限资料与行为不一致) - 关联Issue [cann/ops-nn#7743](https://gitcode.com/cann/ops-nn/issues/7743)(错误码表子项与实测不符) ## 测试 - **UT**(全绿):op_api 14 例(含 strides/storageDims 构造的非连续 out 正向、shape 不一致、rank>8、dtype 不一致等负向);op_host 26 例(squared_relu 15 含 tiling rank-9/容量不足负向,situ_glu 11) - **ST**(ATK,Atlas A2 910B3,pyaclnn vs cpu golden):**201/201 全部通过**(3 条大 shape 用例在空卡 NPU3 单跑通过,设备 HBM 资源竞争与实现无关) - **真机**(CANN 9.3.0,按 issue 原版 repro 验证): | 用例 | 修复前 | 修复后 | |---|---|---| | #7757 非连续 out | ret=0,逻辑视图错值 4 | ret=0,**错值 0** | | #7756 out [4x4]/input [4x8] | ret=0,越界写 16 元素 | **ret=161002,越界写 0** | | squared_relu rank=26 | ret=0、ws=0 静默不执行 | **ret=161002** | | situ_glu rank=25 / dim 越界 / out dtype | 561001 声明不可达 / 561002 声明错误 | 资料对码 1-25 / **561002 / 161002** | | CTRL 合法形态回归 | — | 全部不受影响 | ## 文档更新 - activation/squared_relu/docs/aclnnSquaredRelu.md:out「非连续Tensor」× → √,错误码表补 161002 各行,约束说明同步;README.md 补非连续 out 说明(**EN 文档按检视意见回退,走专用合入流程**) - activation/situ_glu/docs/aclnnSituGlu.md:维度 1-25、错误码表对码(561001 删除、out dtype → 161002)、约束说明;torchapi_situ_glu.md 维度同步 1-25(**EN 文档同上回退**) ## 类型标签 - [x] Bug修复 - [x] 新特性 - [x] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: ## AI/Agent生成声明 - [x] AI辅助编写 See merge request: cann/ops-nn!13494 | 18 days ago | |
docs: update English translations for markdown files Co-authored-by: jenny_xiang<jenny.xiang@huawei.com> # message auto-generated for no-merge-commit merge: !13600 merge docs/update-english-translations into master docs: update English translations for markdown files Created-by: jenny_xiang Commit-by: jenny_xiang Merged-by: cann-robot Description: ## 描述 英文译稿合入后的增量同步与链接更新,共39个文件(37改2删): 1. 增量翻译(8篇):hard_shrink、squared_relu、foreach_lerp_list、foreach_maximum_scalar_list、quant_matmul_reduce_sum、deep_norm、apply_centered_rms_prop、torch_extension,同步最新中文源文档的变更内容。 2. 删除2篇译稿:rotate_quant/tests/st/arch35、grouped(上游已删除对应中文源文件)。 3. 链接改写(31篇):指向本仓已有英文版文档的链接统一改写为 _en 版本(含CONTRIBUTING/SECURITY/README、24处贡献流程链接、fast_kernel_launch_example等),并将残留的中文链接文字(贡献流程/贡献指南/安全声明等)译为英文。 ## 关联的Issue 无 ## 测试 文档类变更,无需算子测试。已通过:全量1135篇译稿链接有效性校验(全部指向master已有文件);残留中文/全角标点扫描(仅存数学公式内源文件原文、无英文版目标文档的中文锚点等允许例外)。 ## 文档更新 更新37个英文译稿文件、删除2个(对应源文件已上游删除),不修改任何中文源文件。 ## 类型标签 - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/ops-nn!13600 | 17 days ago |
SquaredRelu
English | 简体中文
Applicable Products
| Product | Support |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 products | √ |
| Atlas A2 products | √ |
| Atlas 200I/500 A2 inference products | × |
| Atlas inference products | × |
| Atlas training products | × |
| kirin X90 processor series products | √ |
| Kirin 9030 processor series products | √ |
Function
-
Description:
The SquaredRelu function is a variant based on the standard Relu function. Its main feature is squaring the output of the Relu function, and it is often used as the activation function of a model.
-
Formula:
yi=(Relu(xi))2y_i=(Relu(x_i))^2 yi=(Relu(xi))2
The formula of Relu is:
Relu(xi)=max(0,xi)Relu(x_i)=max(0,x_i) Relu(xi)=max(0,xi)
where x is the input tensor, y is the output tensor, and i is the position index of the element in the tensor.
Parameters
| Parameter name | Input/Output/Attribute | Description | Data type | Data format |
|---|---|---|---|---|
| x | Input | Input x in the formula. | BFLOAT16, FLOAT16, FLOAT | ND |
| y | Output | y in the formula. | BFLOAT16, FLOAT16, FLOAT | ND |
- kirin X90 processor series products and Kirin 9030 processor series products: BFLOAT16 is not supported.
Constraints
- If the input value is NaN, the output is also NaN. If the input is Inf, the output is also Inf.
- If the input is -Inf, the output is 0.
- The input shape supports only 1 to 8 dimensions. An error is reported when the value is out of the range.
- out supports non-contiguous tensors. The computation result is written to the logical view of out.
Invocation Description
| Invocation method | Invocation sample | Description |
|---|---|---|
| aclnn invocation | test_aclnn_squared_relu | Invoke the SquaredRelu operator through the aclnnSquaredRelu API. |
| Graph-mode invocation | - | Invoke the SquaredRelu operator by building a graph through the operator IR. |