Pull Request has been successfully merged by CANN-robot.
(Thank you for wenqi_wu's contribution.)变更摘要
本 PR 为 TransData、Tanh 两个算子补齐 ascend350 平台适配。核心思路是将 op_api 层原本基于 SocVersion 的平台判断统一改为基于 NpuArch(ASCEND910B/ASCEND910_93 → DAV_2201,ASCEND310P → DAV_2002),并让 IsRegBase() 接受 arch 参数,使 ascend350(复用 ascend950 的 tiling 与二进制配置)能够落入正确的 dtype 支持列表与参数校验分支;同时在 op_host 侧为 ascend350 注册 AICore 配置并新增对应的二进制算子配置文件。
主要改动
- op_api 平台判断迁移到 NpuArch(
aclnn_trans_matmul_weight.cpp):GetDtypeSupportList、CheckShapeDim、CheckSocValid将SocVersion::ASCEND910B/ASCEND910_93/ASCEND310P判断改为NpuArch::DAV_2201/DAV_2002,IsRegBase()改为传入curArch,使 ascend350 复用ASCEND910B_DTYPE_DTYPE_SUPPORT_LIST分支。 - 卷积权重转换平台校验改造(
aclnn_trans_convolution_weight.cpp):CheckParams中将SocVersion::ASCEND310P校验改为NpuArch::DAV_2002,错误日志仍保留SocVersion输出,确保 350 平台不再被误判为不支持。 - 注册 ascend350 AICore 配置(
trans_data_def.cpp): 在已有AddConfig("ascend950", aicore_config)基础上新增this->AICore().AddConfig("ascend350", aicore_config),复用trans_data_apt算子配置。 - 新增 ascend350 二进制算子配置(
config/ascend350/trans_data_binary.json): 新增文件,内容与 ascend950 一致,覆盖int8/float16/float32/int4/float4_e2m1/hifloat8/uint8等 dtype 在ND与FRACTAL_NZ/FRACTAL_NZ_C0_16/FRACTAL_NZ_C0_32等格式间的转换场景。 - Tanh dtype 支持判断适配(
aclnn_tanh.cpp):GetOutDtypeSupportList与CheckDtypeValid将 SocVersion 判断(含ASCEND910B~ASCEND910E区间判断)改为curArch == NpuArch::DAV_2201 || IsRegBase(curArch),使 350 平台走ASCEND910B_DTYPE_OUT_LIST/ASCEND910B_DTYPE_SUPPORT_LIST分支。
此外,按 PR 描述,conversion/trans_data/CMakeLists.txt 中 SUPPORT_COMPUTE_UNIT 新增 ascend350、SUPPORT_TILING_DIR 新增 arch35(与 ascend950 共用 tiling 目录),并将许可证头规范化为标准 CANN 格式。


Hi @wenqi_wu, welcome to submitting your first PR to ops-math!
PR Merge Steps
1. CLA Signing
If the current PR label includes cann-cla/yes, it means you have signed the CLA and can proceed to the next step. If the label includes cann-cla/no, please sign the CLA first. If you have any questions, please refer to the FAQ.
2. CI Check
Please comment /compile to trigger the CI pipeline check. If the CI run is successful, the PR will be tagged with ci-pipeline-passed and you can proceed to the next step. If the CI run fails, the PR will be tagged with ci-pipeline-failed, please check the CI logs to fix the issues in the PR. If you have any questions, please refer to the FAQ.
3. Code Review
After CI passes, please refer to the PR Approval Progress and proactively @ the committers in the table to review the code. After approval, committers will comment /lgtm and /approve. Once the lgtm and approved labels are successfully added, the PR will be merged automatically.


描述
为 TransData、Tanh 两个算子补齐 ascend350 平台适配:
TransData(5 处改动)
conversion/trans_data/CMakeLists.txt:SUPPORT_COMPUTE_UNIT新增ascend350,SUPPORT_TILING_DIR对应新增arch35(与 ascend950 共用同一 tiling 目录);同时将许可证头规范化为标准 CANN 格式。conversion/trans_data/op_host/trans_data_def.cpp:新增this->AICore().AddConfig("ascend350", aicore_config),为 ascend350 注册 AICore 算子配置(与 ascend950 配置一致,复用 trans_data_apt)。conversion/trans_data/op_host/config/ascend350/trans_data_binary.json(新增):ascend350 平台的二进制算子配置,内容与 ascend950 的 trans_data_binary.json 一致。conversion/trans_data/op_api/aclnn_trans_matmul_weight.cpp与aclnn_trans_convolution_weight.cpp:将 SocVersion 平台判断改为 NpuArch 判断(ASCEND910B/ASCEND910_93 → DAV_2201,ASCEND310P → DAV_2002),IsRegBase()改为传入 arch 参数,错误日志仍使用 SocVersion。scripts/kernel/binary_config/ascendc_config.json:TransData 条目的compute_units与compile_options新增ascend350(编译选项-mllvm -cce-aicore-dcci-before-kernel-end=false),为 ascend350 补齐内核编译配置。Tanh(1 处改动)
math/tanh/op_api/aclnn_tanh.cpp:GetOutDtypeSupportList与CheckDtypeValid中 SocVersion 判断改为 NpuArch 判断(ASCEND910B/ASCEND910_93 及 ASCEND910B~ASCEND910E 区间判断 →DAV_2201 || IsRegBase(curArch)),使 350 平台走正确的 dtype 支持列表分支。op_host 侧(def.cpp 的 ascend350 AddConfig、config/ascend350/tanh_binary.json、CMakeLists)此前已具备,无需改动。关联的Issue
https://gitcode.com/cann/ops-math/issues/3132
测试
文档更新
无需更新文档
类型标签