文件最后提交记录最后更新时间
add introduction example Co-authored-by: yxf-dev-ops<yexiaofeng4@huawei.com> Co-authored-by: gcw_atM8lhjZ<chenhangxin@huawei.com> # message auto-generated for no-merge-commit merge: !171 merge intro into master add introduction example Created-by: yxf-dev-ops Commit-by: gcw_atM8lhjZ;yxf-dev-ops Merged-by: cann-robot Description: ## 描述 新增introduction example 更新以下样例: 00_helloworld 01_add 02_matmul 03_matmulleakyrelu 04_simple_operator ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #123--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/asc-devkit!1714 个月前
add introduction example Co-authored-by: yxf-dev-ops<yexiaofeng4@huawei.com> Co-authored-by: gcw_atM8lhjZ<chenhangxin@huawei.com> # message auto-generated for no-merge-commit merge: !171 merge intro into master add introduction example Created-by: yxf-dev-ops Commit-by: gcw_atM8lhjZ;yxf-dev-ops Merged-by: cann-robot Description: ## 描述 新增introduction example 更新以下样例: 00_helloworld 01_add 02_matmul 03_matmulleakyrelu 04_simple_operator ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #123--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/asc-devkit!1714 个月前
updated the readme link Co-authored-by: gcw_atM8lhjZ<chenhangxin@huawei.com> # message auto-generated for no-merge-commit merge: !301 merge master into master updated the readme link Created-by: gcw_atM8lhjZ Commit-by: gcw_atM8lhjZ Merged-by: cann-robot Description: ## 描述 优化example中README的描述,更新链接 ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #123--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 不涉及 ## 文档更新 examples/00_introduction/00_helloworld/hello_world_aicpu/README.md examples/00_introduction/00_helloworld/hello_world_npu/README.md examples/00_introduction/03_matmulleakyrelu/matmul_leakyrelu/README.md examples/00_introduction/04_simple_operator/add_dynamic/README.md examples/00_introduction/04_simple_operator/broadcast/README.md examples/00_introduction/04_simple_operator/sub/README.md examples/02_features/00_framework_launch/README.md examples/02_features/04_micro_api/move_mask_reg/README.md examples/02_features/04_micro_api/move_successive_align/README.md examples/02_features/04_micro_api/move_successive_unalign/README.md examples/02_features/04_micro_api/move_unsuccessive_align/README.md examples/02_features/04_micro_api/read_write_sync/README.md examples/02_features/04_micro_api/vector_add/README.md examples/02_features/04_micro_api/write_write_sync/README.md examples/02_features/07_data_movement/data_copy_ub2l1/README.md examples/02_features/07_data_movement/data_copy_ub2l1_kfc/README.md examples/02_features/08_tiling/README.md examples/02_features/09_unalign/abs_duplicate/README.md examples/02_features/09_unalign/abs_gather_mask/README.md examples/02_features/09_unalign/reduce_min/README.md examples/02_features/09_unalign/whole_reduce_sum/README.md examples/03_libraries/02_activation/README.md examples/03_libraries/05_reduce/reduce_custom/README.md examples/04_best_practices/01_bank_conflict/01_bank_conflict_950/README.md examples/04_best_practices/01_bank_conflict/bank_conflict/README.md examples/04_best_practices/10_compatibility_cases/data_copy_l1togm_910B/README.md examples/04_best_practices/10_compatibility_cases/data_copy_l1togm_950/README.md examples/04_best_practices/10_compatibility_cases/init_const_value_910B/README.md examples/04_best_practices/10_compatibility_cases/init_const_value_950/README.md examples/04_best_practices/10_compatibility_cases/matmul_s4_910B/README.md examples/04_best_practices/10_compatibility_cases/matmul_s4_950/README.md examples/04_best_practices/10_compatibility_cases/set_loaddata_boundary_910B/README.md examples/04_best_practices/10_compatibility_cases/set_loaddata_boundary_950/README.md examples/04_best_practices/12_high_performance_vf/optimize_vf_continious_align/README.md examples/04_best_practices/12_high_performance_vf/optimize_vf_dual_instr/README.md examples/04_best_practices/12_high_performance_vf/optimize_vf_fusion/README.md examples/04_best_practices/12_high_performance_vf/optimize_vf_loop/README.md examples/04_best_practices/13_optimize_datacopy/optimize_datacopy_loop_mode/README.md examples/04_best_practices/13_optimize_datacopy/optimize_datacopy_nddma/README.md examples/04_best_practices/13_optimize_datacopy/optimize_reduce_invalid_datacopy/README.md ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [ ] 新特性 - [ ] 性能优化 - [x] 文档更新 - [ ] 其他,请描述: See merge request: cann/asc-devkit!3013 个月前
Replace blockDim with numBlocks Co-authored-by: 王旭<wangxu243@huawei.com> # message auto-generated for no-merge-commit merge: !237 merge master into master Replace blockDim with numBlocks Created-by: wx369 Commit-by: 王旭 Merged-by: cann-robot Description: ## 描述 修正blockDim命名,改为numBlocks ## 关联的Issue 不涉及 ## 测试 通过了样例的编译运行 ## 文档更新 不涉及 ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/asc-devkit!2373 个月前
add introduction example Co-authored-by: yxf-dev-ops<yexiaofeng4@huawei.com> Co-authored-by: gcw_atM8lhjZ<chenhangxin@huawei.com> # message auto-generated for no-merge-commit merge: !171 merge intro into master add introduction example Created-by: yxf-dev-ops Commit-by: gcw_atM8lhjZ;yxf-dev-ops Merged-by: cann-robot Description: ## 描述 新增introduction example 更新以下样例: 00_helloworld 01_add 02_matmul 03_matmulleakyrelu 04_simple_operator ## 关联的Issue <!-- 如果这个PR是为了解决特定的Issue,请在这里提供Issue链接。例如:关联Issue #123--> <!-- 如果这个PR是为了解决特定的问题单,请在这里描述问题单单号。--> ## 测试 <!--描述进行了哪些测试来验证你的改动。包括但不限于二级冒烟、算子泛化等。--> ## 文档更新 <!--如果这个PR包含文档的更新,请在这里指出。例如:更新了README.md文件。--> ## 类型标签 <!-- [x] 表示选中 --> - [ ] Bug修复 - [x] 新特性 - [ ] 性能优化 - [ ] 文档更新 - [ ] 其他,请描述: See merge request: cann/asc-devkit!1714 个月前
README.md

Broatcast算子直调样例

概述

本样例展示了一个支持多种数据类型(如bfloat,int8,float,half等)和多种形状(如(32, 1024),(8, 1023)等)的输入张量执行逐元素加法。本样例重点演示了:
1.多核并行计算:通过精细的Tiling策略,将计算任务动态分配到多个核上,并处理核间负载不均(整核与尾核)的场景。
2.输入广播支持:在计算阶段,可对输入进行指定轴上的维度扩展,使算子能处理形状不完全匹配的输入。
3.复杂数据切:定义了包含20个参数的Tiling结构,已管理数据总长、数据类型、广播系数、切分块大小、核间任务分配等复杂逻辑,确保计算高效与内存访问优化。

支持的产品

  • Atlas A3 训练系列产品/Atlas A3 推理系列产品
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品

目录结构介绍

├── broadcast  
│   ├── scripts
│   │   ├── gen_data.py         // 输入数据和真值数据生成脚本
│   │   └── verify_result.py    // 验证输出数据和真值数据是否一致的验证脚本
│   ├── CMakeLists.txt          // 编译工程文件
│   ├── data_utils.h            // 数据读入写出函数
│   └── broadcast_custom.asc    // Ascend C算子实现 & 调用样例

算子描述

  • 算子功能:
    Broadcast算子实现了将输入数据按照输出shape进行广播的功能,比如A的shape为(4096,1),广播的目标shape为(4096,3),则会将原来的一列扩展为相同的3列, A的shape变为(4096,3)。

  • 算子规格:

    算子类型(OpType)Broadcast
    算子输入nameshape_rangedata typeformat
    x4096 * 1floatND
    算子输出z4096 * 3floatND
    核函数名broadcast_custom

编译运行

在本样例根目录下执行如下步骤,编译并执行算子。

  • 配置环境变量
    请根据当前环境上CANN开发套件包的安装方式,选择对应配置环境变量的命令。

    • 默认路径,root用户安装CANN软件包

      source /usr/local/Ascend/cann/set_env.sh
      
    • 默认路径,非root用户安装CANN软件包

      source $HOME/Ascend/cann/set_env.sh
      
    • 指定路径install_path,安装CANN软件包

      source ${install_path}/cann/set_env.sh
      
  • 样例执行

    mkdir -p build && cd build;   # 创建并进入build目录
    cmake ..;make -j;             # 编译工程
    python3 ../scripts/gen_data.py   # 生成测试输入数据
    ./demo                        # 执行编译生成的可执行程序,执行样例
    python3 ../scripts/verify_result.py output/output.bin output/golden.bin   # 验证输出结果是否正确,确认算法逻辑正确
    

    执行结果如下,说明精度对比成功。

    test pass!