From e236e2de8031a6e8003feffbd6929877ad0f1c37 Mon Sep 17 00:00:00 2001 From: lishangfan Date: Thu, 7 Aug 2025 15:42:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=96=99=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- atvc/README.md | 2 +- atvc/examples/aclnn/README.md | 2 +- .../aclnn/add/AclNNInvocationNaive/README.md | 6 ------ .../aclnn/add/AclNNInvocationNaive/run.sh | 9 +++++++++ atvc/examples/aclnn/add/README.md | 6 +++--- atvc/examples/aclnn/add/install.sh | 9 +++++++++ .../reduce_sum/AclNNInvocationNaive/README.md | 6 ------ .../reduce_sum/AclNNInvocationNaive/run.sh | 9 +++++++++ atvc/examples/aclnn/reduce_sum/README.md | 4 ++-- atvc/examples/aclnn/reduce_sum/install.sh | 9 +++++++++ atvc/examples/pytorch/add/README.md | 18 +++--------------- atvc/examples/pytorch/reduce_sum/README.md | 18 +++--------------- 12 files changed, 49 insertions(+), 49 deletions(-) diff --git a/atvc/README.md b/atvc/README.md index 620e28c1..854dd6e7 100644 --- a/atvc/README.md +++ b/atvc/README.md @@ -82,7 +82,7 @@ Accuracy verification passed. | [ops_aclnn](./examples/aclnn) | 使用ATVC基于自定义工程算子的实现以及调用样例 | 自定义工程算子 | | [ops_pytorch](./examples/pytorch) | 使用ATVC基于[pytorch](https://gitee.com/ascend/pytorch)算子的实现以及调用样例 | pytorch算子 | -更多算子类型介绍和如何选取模板参见参阅[快速入门](./docs/1_quick_start.md),其中add、sinh_custom、add_with_scalar、reduce_sum、broadcast_to是ATVC的直调样例,ops_aclnn为基于ATVC对接aclnn工程的算子目录,ops_pytorch为基于ATVC对接pytorch工程的算子目录。 +更多算子类型介绍和如何选取模板参见参阅[快速入门](./docs/1_quick_start.md),其中add、sinh_custom、add_with_scalar、reduce_sum、broadcast_to是ATVC的直调样例,ops_aclnn为基于ATVC对接aclnn工程的算子目录,ops_pytorch为基于ATVC对接pytorch工程的算子目录。其中,ops_aclnn和ops_pytorch样例需要进入到example路径下按照README.md描述执行。 diff --git a/atvc/examples/aclnn/README.md b/atvc/examples/aclnn/README.md index 35df784f..3bfe4acf 100644 --- a/atvc/examples/aclnn/README.md +++ b/atvc/examples/aclnn/README.md @@ -33,7 +33,7 @@ $ cd CustomOp/build_out $ ./custom_opp*.run # 样例运行 - $ cd ./atvc/examples/aclnn/add/AclNNInvocationNaive + $ cd ../../AclNNInvocationNaive $ bash run.sh ... test pass diff --git a/atvc/examples/aclnn/add/AclNNInvocationNaive/README.md b/atvc/examples/aclnn/add/AclNNInvocationNaive/README.md index e826fd57..65acddde 100644 --- a/atvc/examples/aclnn/add/AclNNInvocationNaive/README.md +++ b/atvc/examples/aclnn/add/AclNNInvocationNaive/README.md @@ -33,12 +33,6 @@ 将CMakeLists.txt文件内"/usr/local/Ascend/ascend-toolkit/latest"替换为CANN软件包安装后的实际路径。 eg:/home/HwHiAiUser/Ascend/ascend-toolkit/latest - - 环境变量配置 - - 需要设置NPU_HOST_LIB环境变量,以x86为例 - ```bash - export NPU_HOST_LIB=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/x86_64-linux/lib64 - ``` - 样例执行 用户参考run.sh脚本进行编译与运行。 diff --git a/atvc/examples/aclnn/add/AclNNInvocationNaive/run.sh b/atvc/examples/aclnn/add/AclNNInvocationNaive/run.sh index 7abad744..b085a061 100644 --- a/atvc/examples/aclnn/add/AclNNInvocationNaive/run.sh +++ b/atvc/examples/aclnn/add/AclNNInvocationNaive/run.sh @@ -1,4 +1,13 @@ #!/bin/bash +# Copyright (c) 2025 Huawei Technologies Co., Ltd. +# This file is a part of the CANN Open Software. +# Licensed under CANN Open Software License Agreement Version 1.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. +# ====================================================================================================================== + if [ -n "$ASCEND_INSTALL_PATH" ]; then _ASCEND_INSTALL_PATH=$ASCEND_INSTALL_PATH elif [ -n "$ASCEND_HOME_PATH" ]; then diff --git a/atvc/examples/aclnn/add/README.md b/atvc/examples/aclnn/add/README.md index 5eb359d0..358d7b11 100644 --- a/atvc/examples/aclnn/add/README.md +++ b/atvc/examples/aclnn/add/README.md @@ -20,11 +20,11 @@ z = x + y 算子类型(OpType)Add 算子输入nameshapedata typeformat -x8 * 2048float,intND -y8 * 2048float,intND +x8 * 2048floatND +y8 * 2048floatND -算子输出z8 * 2048float,intND +算子输出z8 * 2048floatND 核函数名add_custom diff --git a/atvc/examples/aclnn/add/install.sh b/atvc/examples/aclnn/add/install.sh index 5ca57e7e..2e41482d 100644 --- a/atvc/examples/aclnn/add/install.sh +++ b/atvc/examples/aclnn/add/install.sh @@ -1,4 +1,13 @@ #!/bin/bash +# Copyright (c) 2025 Huawei Technologies Co., Ltd. +# This file is a part of the CANN Open Software. +# Licensed under CANN Open Software License Agreement Version 1.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. +# ====================================================================================================================== + SHORT=v:,i:, LONG=soc-version:,install-path:, OPTS=$(getopt -a --options $SHORT --longoptions $LONG -- "$@") diff --git a/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/README.md b/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/README.md index 4bc6770f..3fd20f3c 100644 --- a/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/README.md +++ b/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/README.md @@ -33,12 +33,6 @@ 将CMakeLists.txt文件内"/usr/local/Ascend/ascend-toolkit/latest"替换为CANN软件包安装后的实际路径。 eg:/home/HwHiAiUser/Ascend/ascend-toolkit/latest - - 环境变量配置 - - 需要设置NPU_HOST_LIB环境变量,以x86为例 - ```bash - export NPU_HOST_LIB=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/x86_64-linux/lib64 - ``` - 样例执行 用户参考run.sh脚本进行编译与运行。 diff --git a/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/run.sh b/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/run.sh index 9bb88021..a950a390 100644 --- a/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/run.sh +++ b/atvc/examples/aclnn/reduce_sum/AclNNInvocationNaive/run.sh @@ -1,4 +1,13 @@ #!/bin/bash +# Copyright (c) 2025 Huawei Technologies Co., Ltd. +# This file is a part of the CANN Open Software. +# Licensed under CANN Open Software License Agreement Version 1.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. +# ====================================================================================================================== + if [ -n "$ASCEND_INSTALL_PATH" ]; then _ASCEND_INSTALL_PATH=$ASCEND_INSTALL_PATH elif [ -n "$ASCEND_HOME_PATH" ]; then diff --git a/atvc/examples/aclnn/reduce_sum/README.md b/atvc/examples/aclnn/reduce_sum/README.md index 69375381..3503c46e 100644 --- a/atvc/examples/aclnn/reduce_sum/README.md +++ b/atvc/examples/aclnn/reduce_sum/README.md @@ -18,10 +18,10 @@ ReduceSum是对输入tensor的指定轴进行规约累加的计算并输出结 算子类型(OpType)ReduceSum 算子输入nameshapedata typeformat -x8 * 2048float,intND +x8 * 2048floatND -算子输出y1 * 2048float,intND +算子输出y1 * 2048floatND 核函数名reduce_sum_custom diff --git a/atvc/examples/aclnn/reduce_sum/install.sh b/atvc/examples/aclnn/reduce_sum/install.sh index afe455ad..a3a01bc8 100644 --- a/atvc/examples/aclnn/reduce_sum/install.sh +++ b/atvc/examples/aclnn/reduce_sum/install.sh @@ -1,4 +1,13 @@ #!/bin/bash +# Copyright (c) 2025 Huawei Technologies Co., Ltd. +# This file is a part of the CANN Open Software. +# Licensed under CANN Open Software License Agreement Version 1.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. +# ====================================================================================================================== + SHORT=v:,i:, LONG=soc-version:,install-path:, OPTS=$(getopt -a --options $SHORT --longoptions $LONG -- "$@") diff --git a/atvc/examples/pytorch/add/README.md b/atvc/examples/pytorch/add/README.md index 5df331b3..bbd61f30 100644 --- a/atvc/examples/pytorch/add/README.md +++ b/atvc/examples/pytorch/add/README.md @@ -33,18 +33,6 @@ z = x + y 本样例支持如下产品型号: - Atlas A2训练系列产品 -## 算子工程介绍 -其中,算子工程目录AddCustom包含算子的实现文件,如下所示: -``` -├── add -│ ├── add_custom_impl.h // 通过pytroch调用的方式调用Add算子 -│ ├── pytorch_ascendc_extension.cpp // pytorch调用入口 -│ ├── run_op.py // pytorch的测试用例 -│ └── run.sh // 脚本,编译需要的二进制文件,并测试 -``` - -run.sh脚本编译pytorch所需要的算子依赖,并将执行测试用例。 - ## 编译运行样例算子 针对自定义算子工程,编译运行包含如下步骤: - 完成算子pytorch入口和impl文件的实现; @@ -54,10 +42,10 @@ run.sh脚本编译pytorch所需要的算子依赖,并将执行测试用例。 详细操作如下所示。 ### 1. 获取源码包及环境配置 编译运行此样例前,请参考[准备:获取样例代码](../README.md#codeready)获取源码包及环境变量的准备。 -### 1. 安装pytorch环境 +### 2. 安装pytorch环境 参考[torch的安装](https://gitee.com/ascend/pytorch)进行安装torch、torch_npu环境 -### 2. 基于ATVC编写pytorch算子的实现 +### 3. 基于ATVC编写pytorch算子的实现 - 编写kernel侧函数,参考[add_custom_impl.h](./add_custom_impl.h) ```cpp // 引入头文件 @@ -138,7 +126,7 @@ run.sh脚本编译pytorch所需要的算子依赖,并将执行测试用例。 run_tests() ``` -### 3. 基于ATVC编写pytorch算子的调用验证 +### 4. 基于ATVC编写pytorch算子的调用验证 - 调用脚本,生成pytorch算子,并运行测试用例 ```bash $ cd ./atvc/examples/pytorch/add diff --git a/atvc/examples/pytorch/reduce_sum/README.md b/atvc/examples/pytorch/reduce_sum/README.md index e5115295..b951656b 100644 --- a/atvc/examples/pytorch/reduce_sum/README.md +++ b/atvc/examples/pytorch/reduce_sum/README.md @@ -32,18 +32,6 @@ z = x + y 本样例支持如下产品型号: - Atlas A2训练系列产品 -## 算子工程介绍 -其中,算子工程目录ReduceSum包含算子的实现文件,如下所示: -``` -├── reduce_sum -│ ├── reduce_sum_impl.h // 通过pytroch调用的方式调用ReduceSum算子 -│ ├── pytorch_ascendc_extension.cpp // pytorch调用入口 -│ ├── run_op.py // pytorch的测试用例 -│ └── run.sh // 脚本,编译需要的二进制文件,并测试 -``` - -run.sh脚本编译pytorch所需要的算子依赖,并将执行测试用例。 - ## 编译运行样例算子 针对自定义算子工程,编译运行包含如下步骤: - 完成算子pytorch入口和impl文件的实现; @@ -53,10 +41,10 @@ run.sh脚本编译pytorch所需要的算子依赖,并将执行测试用例。 详细操作如下所示。 ### 1. 获取源码包及环境配置 编译运行此样例前,请参考[准备:获取样例代码](../README.md#codeready)获取源码包及环境变量的准备。 -### 1. 安装pytorch环境 +### 2. 安装pytorch环境 参考[torch的安装](https://gitee.com/ascend/pytorch)进行安装torch、torch_npu环境 -### 2. 基于ATVC编写pytorch算子的实现 +### 3. 基于ATVC编写pytorch算子的实现 - 编写kernel侧函数,参考[reduce_sum_impl.h](./reduce_sum_impl.h) ```cpp // 引入头文件 @@ -162,7 +150,7 @@ run.sh脚本编译pytorch所需要的算子依赖,并将执行测试用例。 run_tests() ``` -### 3. 基于ATVC编写pytorch算子的调用验证 +### 4. 基于ATVC编写pytorch算子的调用验证 - 调用脚本,生成pytorch算子,并运行测试用例 ```bash $ cd ./atvc/examples/pytorch/reduce_sum -- Gitee