diff --git a/examples/index/arithprogression/README.md b/examples/index/arange/README.md
similarity index 72%
rename from examples/index/arithprogression/README.md
rename to examples/index/arange/README.md
index 61cdcd5fa58142f157c474b23f5df3e669e93a83..ec83a5e5ac2d0af736fa06c0f5b0f991bf0e969d 100644
--- a/examples/index/arithprogression/README.md
+++ b/examples/index/arange/README.md
@@ -2,13 +2,13 @@
## 概述
-本样例介绍了调用ArithProgression高阶API实现arithprogression单算子,并按照不同的算子调用方式分别给出了对应的端到端实现。
+本样例介绍了调用Arange高阶API实现arange单算子,并按照不同的算子调用方式分别给出了对应的端到端实现。
-- 直调:使用核函数直调arithprogression自定义算子。
+- 直调:使用核函数直调arange自定义算子。
核函数的基础调用方式,开发者完成算子核函数的开发和Tiling实现后,即可通过AscendCL运行时接口,完成算子的调用。
-- 框架调用:使用框架调用arithprogression自定义算子。
+- 框架调用:使用框架调用arange自定义算子。
按照工程创建->算子实现->编译部署->算子调用的流程完成算子开发。整个过程都依赖于算子工程:基于工程代码框架完成算子核函数的开发和Tiling实现,通过工程编译脚本完成算子的编译部署,继而实现单算子调用或第三方框架中的算子调用。
@@ -17,7 +17,7 @@
| 调用方式 | 目录 | **描述** |
| --------- | ------------------------------------------------------------ | ---------------------------------------------------------- |
| 直调 | [kernel_launch_method_by_direct](./kernel_launch_method_by_direct) | host侧的核函数调用程序,包含CPU侧、NPU侧、仿真侧三种运行验证方法。 |
-| 框架调用 | [kernel_launch_method_by_framework](./kernel_launch_method_by_framework) | 通过aclnn调用的方式调用arithprogression算子。 |
+| 框架调用 | [kernel_launch_method_by_framework](./kernel_launch_method_by_framework) | 通过aclnn调用的方式调用arange算子。 |
## 样例支持的产品型号为:
- Atlas A2训练系列产品/Atlas 800I A2推理产品
@@ -34,12 +34,12 @@
## 算子描述
-arithprogression单算子,给定起始值,等差值和长度,返回一个等差数列。
+arange单算子,给定起始值,等差值和长度,返回一个等差数列。
-arithprogression算子规格:
+arange算子规格:
-| 算子类型(OpType) | ArithprogressionCustom |
+| 算子类型(OpType) | ArangeCustom |
| 算子输入 |
| name | shape | data type | format |
@@ -54,14 +54,14 @@ arithprogression算子规格:
## 算子实现介绍
-本样例中实现的是固定shape,输入firstGm[1],diffGm[1],输出outputGm[128]的arithprogression算子。
+本样例中实现的是固定shape,输入firstGm[1],diffGm[1],输出outputGm[128]的arange算子。
- kernel实现
- 计算逻辑是:Ascend C提供的矢量计算接口的操作元素都为LocalTensor,输入数据需要先搬运进片上存储,然后使用ArithProgression高阶API接口完成arithprogression计算,得到最终结果,再搬出到外部存储上。
+ 计算逻辑是:Ascend C提供的矢量计算接口的操作元素都为LocalTensor,输入数据需要先搬运进片上存储,然后使用Arange高阶API接口完成arange计算,得到最终结果,再搬出到外部存储上。
- arithprogression算子的实现流程分为3个基本任务:CopyIn,Compute,CopyOut。CopyIn任务负责将Global Memory上的输入搬运至LocalMemory,Compute任务负责根据输入信息执行arithprogression计算,计算结果存储在dstLocal中,CopyOut任务负责将输出数据从dstLocal搬运至Global Memory上的输出Tensor dst_global中。
+ arange算子的实现流程分为3个基本任务:CopyIn,Compute,CopyOut。CopyIn任务负责将Global Memory上的输入搬运至LocalMemory,Compute任务负责根据输入信息执行arange计算,计算结果存储在dstLocal中,CopyOut任务负责将输出数据从dstLocal搬运至Global Memory上的输出Tensor dst_global中。
- tiling实现
- arithprogression算子的tiling实现流程如下:设置输出shape信息。
\ No newline at end of file
+ arange算子的tiling实现流程如下:设置输出shape信息。
\ No newline at end of file
diff --git a/examples/index/arithprogression/host_tiling/arithprogression_custom_tiling.h b/examples/index/arange/host_tiling/arange_custom_tiling.h
similarity index 56%
rename from examples/index/arithprogression/host_tiling/arithprogression_custom_tiling.h
rename to examples/index/arange/host_tiling/arange_custom_tiling.h
index 1daa71c35dece4521b50b942b150077747639e6f..251a3d970bb67a1ecc0d941d8f24a91863eed26a 100644
--- a/examples/index/arithprogression/host_tiling/arithprogression_custom_tiling.h
+++ b/examples/index/arange/host_tiling/arange_custom_tiling.h
@@ -1,10 +1,11 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
@@ -14,14 +15,14 @@
#include "tiling/tiling_api.h"
namespace optiling {
-BEGIN_TILING_DATA_DEF(ArithprogressionCustomTilingData)
+BEGIN_TILING_DATA_DEF(ArangeCustomTilingData)
TILING_DATA_FIELD_DEF(uint32_t, outSize);
END_TILING_DATA_DEF;
-REGISTER_TILING_DATA_CLASS(ArithprogressionCustom, ArithprogressionCustomTilingData)
+REGISTER_TILING_DATA_CLASS(ArangeCustom, ArangeCustomTilingData)
} // namespace optiling
-void ComputeTiling(const uint32_t outSize, optiling::ArithprogressionCustomTilingData &tiling){
+void ComputeTiling(const uint32_t outSize, optiling::ArangeCustomTilingData &tiling){
tiling.set_outSize(outSize);
}
diff --git a/examples/index/arithprogression/kernel_impl/arithprogression_kernel.h b/examples/index/arange/kernel_impl/arange_kernel.h
similarity index 78%
rename from examples/index/arithprogression/kernel_impl/arithprogression_kernel.h
rename to examples/index/arange/kernel_impl/arange_kernel.h
index 5df32c0bbbb41cb6b4d93b04b5bc4eb3dad41ffa..394abfa0f2e129622524e1d4d0d63411f7f93c06 100644
--- a/examples/index/arithprogression/kernel_impl/arithprogression_kernel.h
+++ b/examples/index/arange/kernel_impl/arange_kernel.h
@@ -1,10 +1,11 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
@@ -19,9 +20,9 @@ struct VecTiling{
};
template
-class KernelArithProgression {
+class KernelArange {
public:
- __aicore__ inline KernelArithProgression()
+ __aicore__ inline KernelArange()
{}
__aicore__ inline void Init(GM_ADDR dstGm, float firstValue, float diffValue, uint32_t count)
{
@@ -44,7 +45,7 @@ private:
__aicore__ inline void Compute()
{
AscendC::LocalTensor dstLocal = outDst.AllocTensor();
- AscendC::ArithProgression(dstLocal, static_cast(firstValue_), static_cast(diffValue_), count_);
+ AscendC::Arange(dstLocal, static_cast(firstValue_), static_cast(diffValue_), count_);
outDst.EnQue(dstLocal);
}
__aicore__ inline void CopyOut()
diff --git a/examples/index/arithprogression/kernel_launch_method_by_direct/CMakeLists.txt b/examples/index/arange/kernel_launch_method_by_direct/CMakeLists.txt
similarity index 80%
rename from examples/index/arithprogression/kernel_launch_method_by_direct/CMakeLists.txt
rename to examples/index/arange/kernel_launch_method_by_direct/CMakeLists.txt
index 77743ac5d9a64187d5ae894a9b4666c41d34445a..65f74305c96da4b1e68d06b60a14fe51506a9619 100644
--- a/examples/index/arithprogression/kernel_launch_method_by_direct/CMakeLists.txt
+++ b/examples/index/arange/kernel_launch_method_by_direct/CMakeLists.txt
@@ -18,7 +18,7 @@ if(CMAKE_INSTALL_PREFIX STREQUAL /usr/local)
endif()
file(GLOB KERNEL_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/arithprogression_custom.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/arange_custom.cpp
)
set(CUSTOM_ASCEND310P_LIST "Ascend310P1" "Ascend310P3")
@@ -30,29 +30,29 @@ else()
message("invalid RUN_MODE: ${RUN_MODE}")
endif()
-add_executable(arithprogression_direct_kernel_op
+add_executable(arange_direct_kernel_op
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/arithprogression_custom_tiling.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/arange_custom_tiling.cpp
)
-target_compile_options(arithprogression_direct_kernel_op PRIVATE
+target_compile_options(arange_direct_kernel_op PRIVATE
$:-g>>
-O2
-std=c++17
-D_GLIBCXX_USE_CXX11_ABI=0
)
-target_compile_definitions(arithprogression_direct_kernel_op PRIVATE
+target_compile_definitions(arange_direct_kernel_op PRIVATE
$<$>:CUSTOM_ASCEND310P>
)
-target_include_directories(arithprogression_direct_kernel_op PRIVATE
+target_include_directories(arange_direct_kernel_op PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
$:${ASCEND_CANN_PACKAGE_PATH}/include>>
$:${ASCEND_CANN_PACKAGE_PATH}/runtime/include>>
)
-target_link_libraries(arithprogression_direct_kernel_op PRIVATE
+target_link_libraries(arange_direct_kernel_op PRIVATE
$,$>:host_intf_pub>>
$:tikicpulib::${SOC_VERSION}>>
$:ascendcl>>
@@ -66,7 +66,7 @@ target_link_libraries(arithprogression_direct_kernel_op PRIVATE
graph_base
)
-install(TARGETS arithprogression_direct_kernel_op
+install(TARGETS arange_direct_kernel_op
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
diff --git a/examples/index/arithprogression/kernel_launch_method_by_direct/README.md b/examples/index/arange/kernel_launch_method_by_direct/README.md
similarity index 87%
rename from examples/index/arithprogression/kernel_launch_method_by_direct/README.md
rename to examples/index/arange/kernel_launch_method_by_direct/README.md
index 3d1102c04b0c1f91758eb28c4e25621aa3b12047..2998b9424838c37f0f8014f29391325ae4515952 100644
--- a/examples/index/arithprogression/kernel_launch_method_by_direct/README.md
+++ b/examples/index/arange/kernel_launch_method_by_direct/README.md
@@ -2,7 +2,7 @@
## 概述
-本样例基于Kernel直调算子工程,介绍了调用ArithProgression高阶API实现arithprogression单算子,主要演示ArithProgression高阶API在Kernel直调工程中的调用。
+本样例基于Kernel直调算子工程,介绍了调用Arange高阶API实现arange单算子,主要演示Arange高阶API在Kernel直调工程中的调用。
## 目录结构介绍
| 目录及文件 | 描述 |
@@ -10,8 +10,8 @@
| [cmake](./cmake) | 编译工程文件 |
| [scripts](./scripts) | 包含输入数据和真值数据生成脚本文件 |
| main.cpp | 主函数,调用算子的应用程序,含CPU域及NPU域调用 |
-| arithprogression_custom.cpp | 算子kernel实现 |
-| arithprogression_custom_tiling.cpp | 算子tiling实现 |
+| arange_custom.cpp | 算子kernel实现 |
+| arange_custom_tiling.cpp | 算子tiling实现 |
| CMakeLists.txt | 编译工程文件 |
| run.sh | 编译执行脚本 |
diff --git a/examples/index/arithprogression/kernel_launch_method_by_direct/arithprogression_custom.cpp b/examples/index/arange/kernel_launch_method_by_direct/arange_custom.cpp
similarity index 77%
rename from examples/index/arithprogression/kernel_launch_method_by_direct/arithprogression_custom.cpp
rename to examples/index/arange/kernel_launch_method_by_direct/arange_custom.cpp
index cb4aa938df814a818b7f5df1dcee50a244110d33..b90764c036af51a42794361d22052fe898fa33f9 100644
--- a/examples/index/arithprogression/kernel_launch_method_by_direct/arithprogression_custom.cpp
+++ b/examples/index/arange/kernel_launch_method_by_direct/arange_custom.cpp
@@ -1,14 +1,15 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
#include "kernel_operator.h"
-#include "../kernel_impl/arithprogression_kernel.h"
+#include "../kernel_impl/arange_kernel.h"
__aicore__ inline void CopyTiling(MyCustomKernel::VecTiling* tiling, GM_ADDR tilingGM)
{
@@ -27,7 +28,7 @@ extern "C" __global__ __aicore__ void arith_progression_custom(GM_ADDR firstGm,
CopyTiling(&tilingData, tiling);
auto first = reinterpret_cast<__gm__ float*>(firstGm);
auto diff = reinterpret_cast<__gm__ float*>(diffGm);
- MyCustomKernel::KernelArithProgression op;
+ MyCustomKernel::KernelArange op;
op.Init(dstGm, *first, *diff, tilingData.outSize);
op.Process();
}
diff --git a/examples/index/arithprogression/kernel_launch_method_by_direct/arithprogression_custom_tiling.cpp b/examples/index/arange/kernel_launch_method_by_direct/arange_custom_tiling.cpp
similarity index 54%
rename from examples/index/arithprogression/kernel_launch_method_by_direct/arithprogression_custom_tiling.cpp
rename to examples/index/arange/kernel_launch_method_by_direct/arange_custom_tiling.cpp
index e16e6aebc469d775868f913164f6b3a3a2b5ff91..f319835b51444e363b22ba57ca5f1885010ba776 100644
--- a/examples/index/arithprogression/kernel_launch_method_by_direct/arithprogression_custom_tiling.cpp
+++ b/examples/index/arange/kernel_launch_method_by_direct/arange_custom_tiling.cpp
@@ -1,10 +1,11 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
@@ -14,17 +15,17 @@
#include
diff --git a/examples/select/selectwithbytesmask/README.md b/examples/select/README.md
similarity index 66%
rename from examples/select/selectwithbytesmask/README.md
rename to examples/select/README.md
index fd6958945bd4f1fcb6affca0e2e6b5b464df47a8..4aced00becb0647ece3abb2ea4fbda8d832ba7de 100644
--- a/examples/select/selectwithbytesmask/README.md
+++ b/examples/select/README.md
@@ -2,13 +2,13 @@
## 概述
-本样例介绍了调用SelectWithBytesMask高阶API实现SelectWithBytesMaskCustom单算子,并按照不同的算子调用方式分别给出了对应的端到端实现。
+本样例介绍了调用Select高阶API实现SelectCustom单算子,并按照不同的算子调用方式分别给出了对应的端到端实现。
-- 直调:使用核函数直调SelectWithBytesMaskCustom自定义算子。
+- 直调:使用核函数直调SelectCustom自定义算子。
核函数的基础调用方式,开发者完成算子核函数的开发和Tiling实现后,即可通过AscendCL运行时接口,完成算子的调用。
-- 框架调用:使用框架调用SelectWithBytesMaskCustom自定义算子。
+- 框架调用:使用框架调用SelectCustom自定义算子。
按照工程创建->算子实现->编译部署->算子调用的流程完成算子开发。整个过程都依赖于算子工程:基于工程代码框架完成算子核函数的开发和Tiling实现,通过工程编译脚本完成算子的编译部署,继而实现单算子调用或第三方框架中的算子调用。
@@ -17,7 +17,7 @@
| 调用方式 | 目录 | **描述** |
| --------- | ------------------------------------------------------------ | ---------------------------------------------------------- |
| 直调 | [kernel_launch_method_by_direct](./kernel_launch_method_by_direct) | host侧的核函数调用程序,包含CPU侧、NPU侧、仿真侧三种运行验证方法。 |
-| 框架调用 | [kernel_launch_method_by_framework](./kernel_launch_method_by_framework) | 通过aclnn调用的方式调用SelectWithBytesMaskCustom算子。 |
+| 框架调用 | [kernel_launch_method_by_framework](./kernel_launch_method_by_framework) | 通过aclnn调用的方式调用SelectCustom算子。 |
## 样例支持的产品型号为:
- Atlas A2训练系列产品/Atlas 800I A2推理产品
@@ -34,12 +34,12 @@
## 算子描述
-SelectWithBytesMaskCustom单算子,对输入src0Tensor和src1Scalar,根据maskTensor相应位置的值(非bit位)从二者中选取元素得到dstTensor。
+SelectCustom单算子,对输入src0Tensor和src1Scalar,根据maskTensor相应位置的值(非bit位)从二者中选取元素得到dstTensor。
-SelectWithBytesMaskCustom算子规格:
+SelectCustom算子规格:
-| 算子类型(OpType) | SelectWithBytesMaskCustom |
+| 算子类型(OpType) | SelectCustom |
| 算子输入 |
| name | shape | data type | format |
@@ -51,19 +51,19 @@ SelectWithBytesMaskCustom算子规格:
| dstGm | 2*32 | float | ND |
-| 核函数名 | select_with_bytes_mask_custom |
+| 核函数名 | select_custom |
## 算子实现介绍
-本样例中实现的是固定shape,输入src[2, 32],mask[2, 32],输出dst[2, 32]的SelectWithBytesMaskCustom算子。
+本样例中实现的是固定shape,输入src[2, 32],mask[2, 32],输出dst[2, 32]的SelectCustom算子。
- kernel实现
- 计算逻辑是:Ascend C提供的矢量计算接口的操作元素都为LocalTensor,输入数据需要先搬运进片上存储,然后使用SelectWithBytesMask高阶API接口完成计算,得到最终结果,再搬出到外部存储上。
+ 计算逻辑是:Ascend C提供的矢量计算接口的操作元素都为LocalTensor,输入数据需要先搬运进片上存储,然后使用Select高阶API接口完成计算,得到最终结果,再搬出到外部存储上。
- SelectWithBytesMaskCustom算子的实现流程分为3个基本任务:CopyIn,Compute,CopyOut。CopyIn任务负责将Global Memory上的输入Tensor srcGm存储在srcLocal中,Compute任务负责对srcLocal执行SelectWithBytesMask计算,计算结果存储在dstLocal中,CopyOut任务负责将输出数据从dstLocal搬运至Global Memory上的输出Tensor dstGm。
+ SelectCustom算子的实现流程分为3个基本任务:CopyIn,Compute,CopyOut。CopyIn任务负责将Global Memory上的输入Tensor srcGm存储在srcLocal中,Compute任务负责对srcLocal执行Select计算,计算结果存储在dstLocal中,CopyOut任务负责将输出数据从dstLocal搬运至Global Memory上的输出Tensor dstGm。
- tiling实现
- SelectWithBytesMaskCustom算子的tiling实现流程如下:首先获取SelectWithBytesMask接口能完成计算所需最大/最小临时空间大小,根据该范围结合实际的内存使用情况设置合适的空间大小,然后根据SrcTensor和maskTensor的shape信息,确定其余tiling参数,最后将scalar类型的源操作数也包含在tiling中传递到kernel侧。
\ No newline at end of file
+ SelectCustom算子的tiling实现流程如下:首先获取Select接口能完成计算所需最大/最小临时空间大小,根据该范围结合实际的内存使用情况设置合适的空间大小,然后根据SrcTensor和maskTensor的shape信息,确定其余tiling参数,最后将scalar类型的源操作数也包含在tiling中传递到kernel侧。
\ No newline at end of file
diff --git a/examples/select/selectwithbytesmask/host_tiling/select_with_bytes_mask_custom_tiling.h b/examples/select/host_tiling/select_custom_tiling.h
similarity index 76%
rename from examples/select/selectwithbytesmask/host_tiling/select_with_bytes_mask_custom_tiling.h
rename to examples/select/host_tiling/select_custom_tiling.h
index 4892a75d0a930164c2238ccf0f2c21597a64655b..846e869ab918944e07faa22d0fd512f0f4d8465d 100644
--- a/examples/select/selectwithbytesmask/host_tiling/select_with_bytes_mask_custom_tiling.h
+++ b/examples/select/host_tiling/select_custom_tiling.h
@@ -1,10 +1,11 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
@@ -22,7 +23,7 @@ BEGIN_TILING_DATA_DEF(SelectCustomTilingData)
TILING_DATA_FIELD_DEF(uint32_t, sharedTmpBufferSize);
END_TILING_DATA_DEF;
-REGISTER_TILING_DATA_CLASS(SelectWithBytesMaskCustom, SelectCustomTilingData)
+REGISTER_TILING_DATA_CLASS(SelectCustom, SelectCustomTilingData)
} // namespace optiling
void ComputeTiling(const uint32_t firstAxis, const uint32_t srcSize,
@@ -36,7 +37,7 @@ void ComputeTiling(const uint32_t firstAxis, const uint32_t srcSize,
uint32_t maxValue = 0;
uint32_t minValue = 0;
uint32_t srcTypeSize = sizeof(float);
- AscendC::GetSelectWithBytesMaskMaxMinTmpSize(src0Shape, src1Shape, srcTypeSize, maskShape, 1, false, maxValue, minValue);
+ AscendC::GetSelectMaxMinTmpSize(src0Shape, src1Shape, srcTypeSize, maskShape, 1, false, maxValue, minValue);
uint32_t sharedTmpBufferSize = minValue;
tiling.set_scalarValue(1.234f);
tiling.set_firstAxis(firstAxis);
diff --git a/examples/select/selectwithbytesmask/kernel_impl/select_with_bytes_mask_kernel.h b/examples/select/kernel_impl/select_kernel.h
similarity index 85%
rename from examples/select/selectwithbytesmask/kernel_impl/select_with_bytes_mask_kernel.h
rename to examples/select/kernel_impl/select_kernel.h
index b41749814d22b579770f15f2d9b6112ad32afa94..8c31c451d796e0180187071f49a31b212dae4b72 100644
--- a/examples/select/selectwithbytesmask/kernel_impl/select_with_bytes_mask_kernel.h
+++ b/examples/select/kernel_impl/select_kernel.h
@@ -1,15 +1,16 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
-#ifndef EXAMPLES_SELECT_WITH_BYTES_MASK_H
-#define EXAMPLES_SELECT_WITH_BYTES_MASK_H
+#ifndef EXAMPLES_SELECT_H
+#define EXAMPLES_SELECT_H
#include "kernel_operator.h"
namespace MyCustomKernel {
@@ -69,9 +70,9 @@ private:
AscendC::LocalTensor tmpBuffer = sharedTmpBuffer.Get();
dstLocal = outQueue.AllocTensor();
- AscendC::SelectWithBytesMask(dstLocal, srcLocal, scalar, maskLocal, tmpBuffer, info);
+ AscendC::Select(dstLocal, srcLocal, scalar, maskLocal, tmpBuffer, info);
// Reverse Select.
- // AscendC::SelectWithBytesMask(dstLocal, scalar, srcLocal, maskLocal, tmpBuffer, info);
+ // AscendC::Select(dstLocal, scalar, srcLocal, maskLocal, tmpBuffer, info);
outQueue.EnQue(dstLocal);
maskQueue.FreeTensor(maskLocal);
inQueueX.FreeTensor(srcLocal);
@@ -101,4 +102,4 @@ private:
srcType scalar = 0.0f;
};
}
-#endif // EXAMPLES_SELECT_WITH_BYTES_MASK_H
\ No newline at end of file
+#endif // EXAMPLES_SELECT_H
\ No newline at end of file
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/CMakeLists.txt b/examples/select/kernel_launch_method_by_direct/CMakeLists.txt
similarity index 100%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/CMakeLists.txt
rename to examples/select/kernel_launch_method_by_direct/CMakeLists.txt
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/README.md b/examples/select/kernel_launch_method_by_direct/README.md
similarity index 91%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/README.md
rename to examples/select/kernel_launch_method_by_direct/README.md
index 2768a7b3b254e572503a9f30b08c216cab26afe8..31056f50efc6a1306680e2178fd899018b88cfca 100644
--- a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/README.md
+++ b/examples/select/kernel_launch_method_by_direct/README.md
@@ -2,7 +2,7 @@
## 概述
-本样例基于Kernel直调算子工程,介绍了调用SelectWithBytesMask高阶API实现SelectWithBytesMaskCustom单算子,主要演示SelectWithBytesMask高阶API在Kernel直调工程中的调用。
+本样例基于Kernel直调算子工程,介绍了调用Select高阶API实现SelectCustom单算子,主要演示Select高阶API在Kernel直调工程中的调用。
## 目录结构介绍
| 目录及文件 | 描述 |
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/cmake/cpu_lib.cmake b/examples/select/kernel_launch_method_by_direct/cmake/cpu_lib.cmake
similarity index 100%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/cmake/cpu_lib.cmake
rename to examples/select/kernel_launch_method_by_direct/cmake/cpu_lib.cmake
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/cmake/npu_lib.cmake b/examples/select/kernel_launch_method_by_direct/cmake/npu_lib.cmake
similarity index 100%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/cmake/npu_lib.cmake
rename to examples/select/kernel_launch_method_by_direct/cmake/npu_lib.cmake
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/main.cpp b/examples/select/kernel_launch_method_by_direct/main.cpp
similarity index 89%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/main.cpp
rename to examples/select/kernel_launch_method_by_direct/main.cpp
index 261d17c2bc566677dcb941ab9710515fe0a89c37..02b59274518313fc0f8653b4601bad6fc335551e 100644
--- a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/main.cpp
+++ b/examples/select/kernel_launch_method_by_direct/main.cpp
@@ -1,21 +1,22 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
-#include "../../../common/data_utils.h"
+#include "../../common/data_utils.h"
#ifndef ASCENDC_CPU_DEBUG
#include "acl/acl.h"
-extern void select_with_bytes_mask_custom_do(uint32_t blockDim, void *l2ctrl, void *stream, uint8_t *srcGm,
+extern void select_custom_do(uint32_t blockDim, void *l2ctrl, void *stream, uint8_t *srcGm,
uint8_t *maskGm, uint8_t *dstGm, uint8_t *workspace, uint8_t *tiling);
#else
#include "tikicpulib.h"
-extern "C" __global__ __aicore__ void select_with_bytes_mask_custom(
+extern "C" __global__ __aicore__ void select_custom(
GM_ADDR srcGm, GM_ADDR maskGm, GM_ADDR dstGm, GM_ADDR workspace, GM_ADDR tiling);
#endif
@@ -91,7 +92,7 @@ int32_t main(int32_t argc, char *argv[])
memcpy_s(tiling, tilingFileSize, GenerateTiling(FIRSTAXIS, SRCLASTAXIS, MASKLASTAXIS), tilingFileSize);
AscendC::SetKernelMode(KernelMode::AIV_MODE);
- ICPU_RUN_KF(select_with_bytes_mask_custom, blockDim, srcInput, maskInput, output, workspace, tiling); // use this macro for cpu debug
+ ICPU_RUN_KF(select_custom, blockDim, srcInput, maskInput, output, workspace, tiling); // use this macro for cpu debug
WriteFile("../output/output.bin", output, srcSize);
bool goldenResult = CompareResult(output, srcSize);
@@ -138,7 +139,7 @@ int32_t main(int32_t argc, char *argv[])
CHECK_ACL(aclrtMemcpy(srcInputDevice, srcSize, srcInputHost, srcSize, ACL_MEMCPY_HOST_TO_DEVICE));
CHECK_ACL(aclrtMemcpy(maskInputDevice, maskSize, maskInputHost, maskSize, ACL_MEMCPY_HOST_TO_DEVICE));
- select_with_bytes_mask_custom_do(blockDim, nullptr, stream, srcInputDevice, maskInputDevice, outputDevice, workspaceDevice, tilingDevice);
+ select_custom_do(blockDim, nullptr, stream, srcInputDevice, maskInputDevice, outputDevice, workspaceDevice, tilingDevice);
CHECK_ACL(aclrtSynchronizeStream(stream));
CHECK_ACL(aclrtMemcpy(outputHost, srcSize, outputDevice, srcSize, ACL_MEMCPY_DEVICE_TO_HOST));
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/run.sh b/examples/select/kernel_launch_method_by_direct/run.sh
similarity index 50%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/run.sh
rename to examples/select/kernel_launch_method_by_direct/run.sh
index a375bdd197b1ce5d3b71f2bec33604cdae5a717d..8979690e6b0c379d4e4d01ae10c61a863783d0d6 100644
--- a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/run.sh
+++ b/examples/select/kernel_launch_method_by_direct/run.sh
@@ -26,6 +26,21 @@ rm -rf build
mkdir build
cd build
+# This program is free software, you can redistribute it and/or modify it.
+# 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 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.
+# ======================================================================================================================
+if [ "${RUN_MODE}" = "sim" ]; then
+ export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | sed 's/\/.*\/runtime\/lib64://g')
+ export LD_LIBRARY_PATH=$ASCEND_HOME_DIR/runtime/lib64/stub:$LD_LIBRARY_PATH
+fi
+
+source $ASCEND_HOME_DIR/bin/setenv.bash
export LD_LIBRARY_PATH=${ASCEND_HOME_DIR}/tools/simulator/${SOC_VERSION}/lib:$LD_LIBRARY_PATH
set -euo pipefail
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/scripts/gen_data.py b/examples/select/kernel_launch_method_by_direct/scripts/gen_data.py
similarity index 70%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/scripts/gen_data.py
rename to examples/select/kernel_launch_method_by_direct/scripts/gen_data.py
index a7ccf05826b831e7d3a3c754c3f3b1a54db79a72..0b96a50cefdf34f9ed24791ee8f2ace48f1bdf51 100644
--- a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/scripts/gen_data.py
+++ b/examples/select/kernel_launch_method_by_direct/scripts/gen_data.py
@@ -1,14 +1,14 @@
#!/usr/bin/python3
# coding=utf-8
-# Copyright (c) 2024 Huawei Technologies Co., Ltd.
+# This program is free software, you can redistribute it and/or modify it.
+# 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").
+# Licensed under 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.
+# 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.
-# ======================================================================================================================
import numpy as np
import os
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/select_custom.cpp b/examples/select/kernel_launch_method_by_direct/select_custom.cpp
similarity index 68%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/select_custom.cpp
rename to examples/select/kernel_launch_method_by_direct/select_custom.cpp
index 26573fdb2b586206478f858593fed517f3c467ed..5add81f1bb626b1c8146446cbdf2c6f42fb6fae7 100644
--- a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/select_custom.cpp
+++ b/examples/select/kernel_launch_method_by_direct/select_custom.cpp
@@ -1,14 +1,15 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
#include "kernel_operator.h"
-#include "../kernel_impl/select_with_bytes_mask_kernel.h"
+#include "../kernel_impl/select_kernel.h"
__aicore__ inline void CopyTiling(MyCustomKernel::VecTiling* tiling, GM_ADDR tilingGM)
{
@@ -21,7 +22,7 @@ __aicore__ inline void CopyTiling(MyCustomKernel::VecTiling* tiling, GM_ADDR til
return;
}
-extern "C" __global__ __aicore__ void select_with_bytes_mask_custom(
+extern "C" __global__ __aicore__ void select_custom(
GM_ADDR srcGm, GM_ADDR maskGm, GM_ADDR dstGm, GM_ADDR workspace, GM_ADDR tiling)
{
MyCustomKernel::VecTiling tilingData;
@@ -41,9 +42,9 @@ extern "C" __global__ __aicore__ void select_with_bytes_mask_custom(
#ifndef ASCENDC_CPU_DEBUG
// call of kernel function
-void select_with_bytes_mask_custom_do(uint32_t blockDim, void *l2ctrl, void *stream, uint8_t *srcGm,
+void select_custom_do(uint32_t blockDim, void *l2ctrl, void *stream, uint8_t *srcGm,
uint8_t *maskGm, uint8_t *dstGm, uint8_t *workspace, uint8_t *tiling)
{
- select_with_bytes_mask_custom<<>>(srcGm, maskGm, dstGm, workspace, tiling);
+ select_custom<<>>(srcGm, maskGm, dstGm, workspace, tiling);
}
#endif
\ No newline at end of file
diff --git a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/select_custom_tiling.cpp b/examples/select/kernel_launch_method_by_direct/select_custom_tiling.cpp
similarity index 70%
rename from examples/select/selectwithbytesmask/kernel_launch_method_by_direct/select_custom_tiling.cpp
rename to examples/select/kernel_launch_method_by_direct/select_custom_tiling.cpp
index f44349b287f58501c1cfde8411528e6014eb2762..94541cf474529e90c08e2e66ab5632abfb5ceec1 100644
--- a/examples/select/selectwithbytesmask/kernel_launch_method_by_direct/select_custom_tiling.cpp
+++ b/examples/select/kernel_launch_method_by_direct/select_custom_tiling.cpp
@@ -1,10 +1,11 @@
-/**
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
+/*
+ * This program is free software, you can redistribute it and/or modify it.
+ * 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").
+ * Licensed under 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.
+ * 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.
*/
@@ -14,7 +15,7 @@
#include