| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
fix moe and posembling Co-authored-by: caiwenwen<caiwenwen6@h-partners.com> # message auto-generated for no-merge-commit merge: !9719 merge master into master fix moe and posembling Created-by: caiwenwen Commit-by: caiwenwen Merged-by: cann-robot Description: ## 描述 修改moe and posembling两个文件夹标签 ## 关联的Issue 关联Issue [#4040](https://gitcode.com/cann/ops-transformer/issues/4040) <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [x] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!9719 | 1 个月前 | |
feat(inplace_partial_rotary_mul): add torch interface migration Co-authored-by: wangxun21<wangxun21@huawei.com> # message auto-generated for no-merge-commit merge: !7202 merge torch_api_add into master feat(inplace_partial_rotary_mul): add torch interface migration Created-by: wangxun21 Commit-by: wangxun21 Merged-by: cann-robot Description: ## 描述 为 inplace_partial_rotary_mul 算子新增 PyTorch 接口迁移,使其可通过 cann_ops_transformer 包在 NPU 上直接调用。 具体改动内容: 1. **Python 封装层** (inplace_partial_rotary_mul.py):使用 OpBuilder 模式实现 JIT 编译 + dispatcher 注册,提供 Python 调用接口 - OpBuilder 定义 schema、sources、meta 注册 - PrivateUse1 dispatcher 实现 NPU 调用 - 公开函数 inplace_partial_rotary_mul(x, r1, r2, rotary_mode, partial_slice) 2. **C++ 绑定层** (inplace_partial_rotary_mul.cpp):通过 ACLNN_CMD 宏调用底层 aclnnInplacePartialRotaryMul 算子 - 参数校验:x dim=4、rotary_mode 合法性、当前仅支持 interleave 模式 - rotary_mode 映射:half=0, interleave=1, quarter=2, interleave-half=3 3. **图模式转换器** (graph_convert_inplace_partial_rotary_mul.py):实现 torchair GE converter,支持图模式下调用 - 定义 InplacePartialRotaryMul GE op - 注册 torch.ops.cann_ops_transformer.inplace_partial_rotary_mul.default 转换器 4. **算子文档** (npu_inplace_partial_rotary_mul.md):新增接口说明文档,包含参数说明和使用示例 5. **导出注册** (__init__.py):注册 inplace_partial_rotary_mul 及 convert_inplace_partial_rotary_mul 到包导出 6. **.gitignore**:添加本地测试文件排除规则 ## 关联的Issue 关联Issue #3239 ## 测试 - Python eager 模式基本功能验证 - 参数校验覆盖:dim 检查、rotary_mode 检查、partial_slice 检查 - 图模式转换器注册验证 ## 文档更新 新增 torch_extension/cann_ops_transformer/doc/npu_inplace_partial_rotary_mul.md 算子接口文档 ## 类型标签 - [ ] 🐛 Bug修复 - [x] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧠 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!7202 | 2 个月前 | |
feat: 新增 inplace_partial_rotary_mul 算子 Co-authored-by: wangxun21<wangxun21@huawei.com> Co-authored-by: zhu-lei0614<zhulei113@huawei.com> # message auto-generated for no-merge-commit merge: !6085 merge feat/inplace_partial_rotary_mul into master feat: 新增 inplace_partial_rotary_mul 算子 Created-by: wangxun21 Commit-by: wangxun21;zhu-lei0614 Merged-by: cann-robot Description: ## 描述 新增 posembedding/inplace_partial_rotary_mul 算子,支持原地部分旋转乘法操作。 该算子用于 RoPE(旋转位置编码)场景,支持 ascend910b、ascend910_93、ascend950 三个平台,包含 regbase 和 membase 两种 kernel 实现方式。 共新增 50 个文件,11257 行代码,包括: - op_host: tiling 定义、infershape、op_api 接口 - op_kernel: regbase (arch35) 和 membase kernel 实现 - op_graph: proto 定义 - docs: aclnn 接口文档 - examples: 测试示例代码 ## 关联的Issue #2752 ## 测试 - 已提供 examples 测试示例代码 - 需编译验证和精度测试 ## 文档更新 - 新增 aclnnInplacePartialRotaryMul.md 接口文档 - 新增 README.md 算子说明文档 ## 类型标签 - [x] ✨ 新特性 See merge request: cann/ops-transformer!6085 | 2 个月前 | |
pre-commit修复posembedding、mhc、ffn等目录.h/.hpp历史格式问题 Co-authored-by: gitcode_lijd<lijiandong20@huawei.com> # message auto-generated for no-merge-commit merge: !11021 merge fix_3 into master pre-commit修复posembedding、mhc、ffn等目录.h/.hpp历史格式问题 Created-by: gitcode_lijd Commit-by: gitcode_lijd Merged-by: cann-robot Description: ## 关联的Issue 关联Issue https://gitcode.com/cann/ops-transformer/issues/4850 ## 描述 对仓内算子源码提前做 pre-commit 历史格式问题清理,为后续功能改动(如 Regbase API 替换等)扫清钩子障碍,避免后续 PR 因格式问题被大面积格式化污染 diff。 处理方式: find <目录> -type f \( -name '*.h' -o -name '*.hpp' \) | xargs pre-commit run --files,多轮执行直到所有 hook 收敛(无 Failed / 无自动修复)。 修复内容(仅格式,不改任何代码语义): - 尾随空白(trailing whitespace) - 文件末尾换行(end of file) - clang-format 代码重排(换行、缩进、对齐,遵循仓内 .clang-format) ### 排除范围(不做格式化) - *_def.cpp 算子定义文件(排版由开发者自行维护,另见 PR #11041) - */op_api/aclnn*.h、*/op_graph/*_proto.h、*/op_host/op_api/aclnn*.h 接口/原型头文件(排版由开发者自行维护) - mamba/ 目录(该目录 causal_conv1d 算子 UT 上游基线存在失败,见 Issue #4840,本批不涉及) - examples/、experimental/ 目录 ### PR 拆分说明 全仓 .h/.hpp 清理共 2362 个文件,按场景目录拆分为 6 个 PR(分支不同、内容互不重叠,可独立 review 合入): | PR | 分支 | 范围 | |---|---|---| | #4878 | compile | attention 第1批(按算子字母序前段) | | #10422 | graph | attention 第2批(按算子字母序中段) | | #9331 | test | attention 第3批(按算子字母序后段) | | #10991 | fix | mc2 | | #11020 | fix_2 | moe、gmm | | #11021 | fix_3 | posembedding、mhc、ffn、common、tests、torch_extension | ## 测试 - 纯格式化改动:不改变任何代码语义,逐文件 diff 均为空白/换行/clang-format 重排 - pre-commit 全量 hook 收敛验证:多轮执行后 trailing-whitespace / end-of-file-fixer / clang-format 均 Passed - 建议合入前对相关算子做一次编译验证 See merge request: cann/ops-transformer!11021 | 5 天前 | |
pre-commit修复posembedding、mhc、ffn等目录.h/.hpp历史格式问题 Co-authored-by: gitcode_lijd<lijiandong20@huawei.com> # message auto-generated for no-merge-commit merge: !11021 merge fix_3 into master pre-commit修复posembedding、mhc、ffn等目录.h/.hpp历史格式问题 Created-by: gitcode_lijd Commit-by: gitcode_lijd Merged-by: cann-robot Description: ## 关联的Issue 关联Issue https://gitcode.com/cann/ops-transformer/issues/4850 ## 描述 对仓内算子源码提前做 pre-commit 历史格式问题清理,为后续功能改动(如 Regbase API 替换等)扫清钩子障碍,避免后续 PR 因格式问题被大面积格式化污染 diff。 处理方式: find <目录> -type f \( -name '*.h' -o -name '*.hpp' \) | xargs pre-commit run --files,多轮执行直到所有 hook 收敛(无 Failed / 无自动修复)。 修复内容(仅格式,不改任何代码语义): - 尾随空白(trailing whitespace) - 文件末尾换行(end of file) - clang-format 代码重排(换行、缩进、对齐,遵循仓内 .clang-format) ### 排除范围(不做格式化) - *_def.cpp 算子定义文件(排版由开发者自行维护,另见 PR #11041) - */op_api/aclnn*.h、*/op_graph/*_proto.h、*/op_host/op_api/aclnn*.h 接口/原型头文件(排版由开发者自行维护) - mamba/ 目录(该目录 causal_conv1d 算子 UT 上游基线存在失败,见 Issue #4840,本批不涉及) - examples/、experimental/ 目录 ### PR 拆分说明 全仓 .h/.hpp 清理共 2362 个文件,按场景目录拆分为 6 个 PR(分支不同、内容互不重叠,可独立 review 合入): | PR | 分支 | 范围 | |---|---|---| | #4878 | compile | attention 第1批(按算子字母序前段) | | #10422 | graph | attention 第2批(按算子字母序中段) | | #9331 | test | attention 第3批(按算子字母序后段) | | #10991 | fix | mc2 | | #11020 | fix_2 | moe、gmm | | #11021 | fix_3 | posembedding、mhc、ffn、common、tests、torch_extension | ## 测试 - 纯格式化改动:不改变任何代码语义,逐文件 diff 均为空白/换行/clang-format 重排 - pre-commit 全量 hook 收敛验证:多轮执行后 trailing-whitespace / end-of-file-fixer / clang-format 均 Passed - 建议合入前对相关算子做一次编译验证 See merge request: cann/ops-transformer!11021 | 5 天前 | |
pre-commit 补充license Co-authored-by: gitcode_lijd<lijiandong20@huawei.com> # message auto-generated for no-merge-commit merge: !5437 merge err_msg into master pre-commit 补充license Created-by: gitcode_lijd Commit-by: gitcode_lijd Merged-by: cann-robot Description: # ops-transformer 仓库 License 合规整改总结 ## 背景 ops-transformer 仓库在 pre-commit 流程中引入了 OAT(Open Source Audit Tool)合规性检查,用于扫描提交文件是否包含合规的 CANN License 头。在实际提交过程中,OAT 检查发现多个文件缺少 License 头,导致 commit 被阻断。为此进行了两笔提交来完成整改。 ## 提交记录 | 序号 | Commit | 提交信息 | 修改文件数 | 变更量 | |------|--------|----------|-----------|--------| | 1 | 7ad5476c9 | pre-commit 规则修改 | 1 | +10 / -1 | | 2 | 84b25cd9d | 补充license | 94 | +4399 / -3521 | ## 提交一:pre-commit 规则修改 ### 修改内容 对 .pre-commit-config.yaml 做了两处修改: 1. **补充 CANN License 头** — 该文件本身缺少 License,导致 OAT 检查报错 License Header Invalid 2. **codespell 排除范围扩展** — 在 --skip 参数中新增 *.md,避免对 Markdown 文档进行拼写检查(文档中包含大量技术术语和中文内容,误报率高) ### 触发原因 首次提交时 OAT 扫描结果: [OAT] Found 1 compliance issue(s): - Invalid File Type: 0 - License Header Invalid: 1 → .pre-commit-config.yaml (NoLicenseHeader) ## 提交二:补充 License ### 统计概览 - **涉及文件**: 94 个 - **文件类型分布**: | 类型 | 数量 | License 格式 | |------|------|-------------| | .py | 62 | # 注释风格 | | .sh | 14 | # 注释风格 | | .cpp | 8 | /**/ 注释风格 | | .h | 5 | /**/ 注释风格 | | .yml | 4 | # 注释风格 | | .yaml | 1 | # 注释风格 | - **模块分布**: | 模块 | 文件数 | |------|--------| | attention | 37 | | experimental | 31 | | examples | 7 | | .gitcode | 5 | | tests | 3 | | posembedding | 3 | | mc2 | 3 | | mhc | 2 | | torch_extension | 1 | | scripts | 1 | | ffn | 1 | ### License 头格式 #### Hash 风格(.sh / .py / .yaml / .yml) # ----------------------------------------------------------------------------------------------------------- # Copyright (c) 2025 Huawei Technologies Co., Ltd. # This program is free software, you can redistribute it and/or modify it under the terms and conditions of # CANN Open Software License Agreement Version 2.0 (the "License"). # Please refer to the License for details. You may not use this file except in compliance with the License. # THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. # See LICENSE in the root of the software repository for the full text of the License. # ----------------------------------------------------------------------------------------------------------- #### C 风格(.cpp / .c / .h / .hpp) c /** * Copyright (c) 2025 Huawei Technologies Co., Ltd. * This program is free software, you can redistribute it and/or modify it under the terms and conditions of * CANN Open Software License Agreement Version 2.0 (the "License"). * Please refer to the License for details. You may not use this file except in compliance with the License. * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. * See LICENSE in the root of the software repository for the full text of the License. */ ### 处理规则 | 场景 | 处理方式 | |------|---------| | 普通文件无 License | 在文件顶部添加 License 头 | | 文件有 shebang(#!/bin/bash) | License 插入在 shebang 之后 | | 文件有编码声明(# -*- coding: utf-8 -*-) | License 插入在编码声明之后 | | License 最后一行与代码之间 | 保留一个空行分隔 | | C 风格 */ 后 | 保留一个空行分隔 | | 空 __init__.py(0 字节) | 不添加 License,保持原样 | | 已有小写 copyright 的文件 | 不重复添加(识别为已有 License) | ### 额外修复 #### 1. 双 License 清理 以下 3 个文件原本同时包含 CANN License 和 Apache 2.0 License,删除了 Apache 2.0 部分: - scripts/util/insert_op_info.py - examples/add_example/op_kernel_aicpu/add_example_aicpu.cpp - examples/add_example/op_kernel_aicpu/add_example_aicpu.h #### 2. 格式规范化 - 所有 C 风格文件 */ 后确保有空行 - 所有 Hash 风格文件 License 块 # --- 后确保有空行 - 修复了 2 个文件(golden.py、golden_src.py)License 后的空格行替换为真正的空行 ### 排除范围 以下目录/文件未做修改: - build/ — 构建产物 - .git/ — Git 内部文件 - third_party/ — 第三方依赖 - */3rd/ — 第三方子模块 - oat_reports/ — OAT 扫描报告 - torch_extension/build/ — 构建产物 - 空 __init__.py(0 字节)— Python 包标识文件,无需 License ## 验证结果 整改完成后,对提交中所有 94 个文件进行了 5 项检查: | 检查项 | 结果 | |--------|------| | 1. 是否包含 Copyright Huawei 标识 | 全部通过 | | 2. 是否存在重复 Copyright | 全部通过 | | 3. C 风格 */ 后是否有空行 | 全部通过 | | 4. Hash 风格 # --- 后是否有空行 | 全部通过 | | 5. shebang/encoding 是否保持在第 1 行 | 全部通过 | See merge request: cann/ops-transformer!5437 | 1 个月前 | |
torch extension整改成分布式 Co-authored-by: hblnb<huangbolin3@huawei.com> # message auto-generated for no-merge-commit merge: !9712 merge torch_extension_split into master torch extension整改成分布式 Created-by: hblnb Commit-by: hblnb Merged-by: cann-robot Description: ## 描述 ops-transformer仓支持各个算子独立编译torch_extention,并将torch_extension从集中式改成分布式(算子的文件分布到算子源码目录下新建的torch_extension文件夹) ## 关联的Issue https://gitcode.com/cann/ops-transformer/issues/4502 ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] 🐛 Bug修复 - [ ] ✨ 新特性 - [ ] ⚡ 性能优化 - [x] ♻️ 重构 - [ ] 🧪 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!9712 | 14 天前 | |
feat: 新增 inplace_partial_rotary_mul 算子 Co-authored-by: wangxun21<wangxun21@huawei.com> Co-authored-by: zhu-lei0614<zhulei113@huawei.com> # message auto-generated for no-merge-commit merge: !6085 merge feat/inplace_partial_rotary_mul into master feat: 新增 inplace_partial_rotary_mul 算子 Created-by: wangxun21 Commit-by: wangxun21;zhu-lei0614 Merged-by: cann-robot Description: ## 描述 新增 posembedding/inplace_partial_rotary_mul 算子,支持原地部分旋转乘法操作。 该算子用于 RoPE(旋转位置编码)场景,支持 ascend910b、ascend910_93、ascend950 三个平台,包含 regbase 和 membase 两种 kernel 实现方式。 共新增 50 个文件,11257 行代码,包括: - op_host: tiling 定义、infershape、op_api 接口 - op_kernel: regbase (arch35) 和 membase kernel 实现 - op_graph: proto 定义 - docs: aclnn 接口文档 - examples: 测试示例代码 ## 关联的Issue #2752 ## 测试 - 已提供 examples 测试示例代码 - 需编译验证和精度测试 ## 文档更新 - 新增 aclnnInplacePartialRotaryMul.md 接口文档 - 新增 README.md 算子说明文档 ## 类型标签 - [x] ✨ 新特性 See merge request: cann/ops-transformer!6085 | 2 个月前 | |
feat(inplace_partial_rotary_mul): add torch interface migration Co-authored-by: wangxun21<wangxun21@huawei.com> # message auto-generated for no-merge-commit merge: !7202 merge torch_api_add into master feat(inplace_partial_rotary_mul): add torch interface migration Created-by: wangxun21 Commit-by: wangxun21 Merged-by: cann-robot Description: ## 描述 为 inplace_partial_rotary_mul 算子新增 PyTorch 接口迁移,使其可通过 cann_ops_transformer 包在 NPU 上直接调用。 具体改动内容: 1. **Python 封装层** (inplace_partial_rotary_mul.py):使用 OpBuilder 模式实现 JIT 编译 + dispatcher 注册,提供 Python 调用接口 - OpBuilder 定义 schema、sources、meta 注册 - PrivateUse1 dispatcher 实现 NPU 调用 - 公开函数 inplace_partial_rotary_mul(x, r1, r2, rotary_mode, partial_slice) 2. **C++ 绑定层** (inplace_partial_rotary_mul.cpp):通过 ACLNN_CMD 宏调用底层 aclnnInplacePartialRotaryMul 算子 - 参数校验:x dim=4、rotary_mode 合法性、当前仅支持 interleave 模式 - rotary_mode 映射:half=0, interleave=1, quarter=2, interleave-half=3 3. **图模式转换器** (graph_convert_inplace_partial_rotary_mul.py):实现 torchair GE converter,支持图模式下调用 - 定义 InplacePartialRotaryMul GE op - 注册 torch.ops.cann_ops_transformer.inplace_partial_rotary_mul.default 转换器 4. **算子文档** (npu_inplace_partial_rotary_mul.md):新增接口说明文档,包含参数说明和使用示例 5. **导出注册** (__init__.py):注册 inplace_partial_rotary_mul 及 convert_inplace_partial_rotary_mul 到包导出 6. **.gitignore**:添加本地测试文件排除规则 ## 关联的Issue 关联Issue #3239 ## 测试 - Python eager 模式基本功能验证 - 参数校验覆盖:dim 检查、rotary_mode 检查、partial_slice 检查 - 图模式转换器注册验证 ## 文档更新 新增 torch_extension/cann_ops_transformer/doc/npu_inplace_partial_rotary_mul.md 算子接口文档 ## 类型标签 - [ ] 🐛 Bug修复 - [x] ✨ 新特性 - [ ] ⚡ 性能优化 - [ ] ♻️ 重构 - [ ] 🧠 测试 - [ ] 📦 构建/CI - [ ] 🔧 配置变更 - [ ] 📝 文档更新 - [ ] ⬆️ 依赖升级 - [ ] 🔒 安全修复 - [ ] 🧹 代码清理 - [ ] ❓ 其他,请描述: See merge request: cann/ops-transformer!7202 | 2 个月前 |
InplacePartialRotaryMul
产品支持情况
| 产品 | 是否支持 |
|---|---|
| Ascend 950PR/Ascend 950DT | √ |
| Atlas A3 训练系列产品/Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品/Atlas A2 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | × |
| Atlas 推理系列产品 | × |
| Atlas 训练系列产品 | × |
功能说明
-
算子功能:执行单路旋转位置编码的Inplace计算,直接修改输入张量,不产生新的输出张量。支持通过
partial_slice参数对输入张量的最后一维进行部分旋转位置编码计算,仅对指定范围内的数据进行旋转位置编码。 -
计算公式:
interleave模式(rotary_mode等于1):
x1=x[...,::2]x1 = x[..., ::2] x1=x[...,::2]
x2=x[...,1::2]x2 = x[..., 1::2] x2=x[...,1::2]
x_rotate=torch.cat((−x2,x1),dim=−1)x\_rotate = torch.cat((-x2, x1), dim=-1) x_rotate=torch.cat((−x2,x1),dim=−1)
x=x∗cos+x_rotate∗sinx = x * cos + x\_rotate * sin x=x∗cos+x_rotate∗sin
参数说明
| 参数名 | 输入/输出/属性 | 描述 | 数据类型 | 数据格式 |
|---|---|---|---|---|
| xRef | 输入 | 公式中的x,待执行旋转位置编码的张量。Inplace模式,xRef同时作为输出写入结果。 | BFLOAT16、FLOAT16、FLOAT32 | ND |
| cos | 输入 | 公式中的cos,参与计算的位置编码张量。 | BFLOAT16、FLOAT16、FLOAT32 | ND |
| sin | 输入 | 公式中的sin,参与计算的位置编码张量。 | BFLOAT16、FLOAT16、FLOAT32 | ND |
| rotary_mode | 输入 | 公式中的旋转模式,当前仅支持interleave模式(rotary_mode=1)。 | INT64 | - |
| partial_slice | 输入 | 部分旋转的切片范围[start, end),作用于最后一维。默认值为[0, 0]。 | INT64数组 | - |
约束说明
-
不支持非连续。
-
输入张量xRef最后一维(D)大小不超过1024。
-
interleave模式(rotary_mode = 1)下,xRef最后一维(D)大小必须为2的倍数。
-
输入张量cos、sin最后一维大小必须相同,且必须等于partialSlice的切片长度(即partialSlice[1] - partialSlice[0])。
-
partialSlice约束:sliceStart ≥ 0,sliceEnd ≥ 0,sliceEnd ≤ xRef最后一维(D)大小,sliceLength = sliceEnd - sliceStart >= 0,当sliceEnd和sliceStart相同时,不做旋转位置编码,直接返回。
-
仅支持interleave模式(rotary_mode = 1)。
-
Inplace执行:输入xRef和输出共享同一个Tensor,计算结果直接写回输入xRef。
-
xRef的shape为BSND。
-
cos/sin的shape必须与xRef满足广播关系,且存在如下约束:
-
Ascend 950PR/Ascend 950DT: cos/sin的shape当前只支持BSND、B1ND、B11D、111D排布。
-
Atlas A3 训练系列产品/Atlas A3 推理系列产品、Atlas A2 训练系列产品/Atlas A2 推理系列产品: cos/sin的shape当前只支持BS1D、B11D排布。
-
调用说明
| 调用方式 | 调用样例 | 说明 |
|---|---|---|
| aclnn调用 | test_aclnn_inplace_partial_rotary_mul | 通过aclnnInplacePartialRotaryMul接口方式调用InplacePartialRotaryMul算子。 |
| PyTorch API | inplace_partial_rotary_mul | 通过cann_ops_transformer.inplace_partial_rotary_mul接口方式调用InplacePartialRotaryMul算子。 |
| 图模式调用 | test_geir_inplace_partial_rotary_mul | 通过算子IR构图方式调用InplacePartialRotaryMul算子。 |