### Install Protobuf for Operator Compilation Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Ensures the correct protobuf version (<=3.20.x) is installed for operator compilation. This command installs version 3.20.0, which is critical for compatibility. Use `--user` for non-root installations. ```bash pip3 install protobuf==3.20.0 # For non-root users: pip3 install protobuf==3.20.0 --user ``` -------------------------------- ### Custom Operator Package Installation Parameters Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Details the command-line arguments for installing the custom operator .run package. Supports quiet installation and specifying a custom installation path. ```APIDOC Custom Operator Package Installation: Usage: ./CANN-custom_ops--linux..run [OPTIONS] Options: --quiet Description: Performs a quiet installation without user prompts. --install-path= Description: Specifies a custom directory to install the operator package. Example: ./build_out/CANN-custom_ops--linux..run --quiet --install-path=/opt/my_operators --help Description: Displays help information for the installation command. ``` -------------------------------- ### Install CANN Development Toolkit (Default Path) Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Command to install the CANN development toolkit and operator binary packages using default installation paths. The toolkit is installed in `/usr/local/Ascend/ascend-toolkit/latest` for root users or `$HOME/Ascend/ascend-toolkit/latest` for non-root users. ```bash # CANN development toolkit installation: ./Ascend-cann-toolkit__linux-.run --install # Operator binary package installation: ./Ascend-cann-kernels-__linux.run --install ``` -------------------------------- ### AclNN Interface Verification Example Structure Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Illustrates the directory structure and key files for verifying operator functionality using the AclNN interface. Includes scripts for data generation, compilation, execution, and result verification. ```plain text AclNNInvocationNaive ├── CMakeLists.txt ├── gen_data.py ├── main.cpp ├── README.md ├── run.sh └── verify_result.py ``` -------------------------------- ### Install CANN Development Toolkit (Custom Path) Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Command to install the CANN development toolkit and operator binary packages to a specified installation path. This allows flexibility in choosing the installation directory for the toolkit and its associated kernel packages. ```bash # CANN development toolkit installation: ./Ascend-cann-toolkit__linux-.run --install --install-path=${install_path} # Operator binary package installation: ./Ascend-cann-kernels-__linux.run --install --install-path=${install_path} ``` -------------------------------- ### Compile and Install Googletest Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Provides instructions to compile and install the googletest framework from source, specifically checking out the release-1.11.0 tag. This is required for running Unit Tests (UT). The CMake command includes flags for ABI compatibility. ```bash git checkout release-1.11.0 mkdir temp && cd temp cmake .. -DCMAKE_CXX_FLAGS="-fPIC -D_GLIBCXX_USE_CXX11_ABI=0" make make install # For non-root users: # sudo make install ``` -------------------------------- ### ST Test Verification Example Structure Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Shows the typical directory structure for System Test (ST) verification of custom operators. It includes JSON test case definitions, configuration files, and optional benchmark scripts. ```plain text st ├── AddCustom_case_all_type.json ├── msopst.ini ├── README.md └── test_add_custom.py ``` -------------------------------- ### Compile and Install nlohmann_json Library Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Details the process for compiling and installing the nlohmann_json library from source, targeting version v3.11.3. This is recommended for JSON handling. Tests are disabled to speed up the build. ```bash git checkout v3.11.3 mkdir build && cd build cmake .. -DJSON_BuildTests=OFF cmake --install . # For non-root users: # sudo cmake --install . ``` -------------------------------- ### CANN Toolkit Environment Variables Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Details the environment variables that need to be set for using the CANN toolkit, including DDK_PATH and NPU_HOST_LIB, which point to the toolkit's installation directory and libraries. ```APIDOC Environment Variables: - DDK_PATH: Specifies the root directory of the Ascend CANN toolkit installation. Example: export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest - NPU_HOST_LIB: Specifies the path to the host library directory within the CANN toolkit. Example: export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/lib64 - LD_LIBRARY_PATH: Should be updated to include the operator API library path after installing custom operators. Example: export LD_LIBRARY_PATH=/usr/local/Ascend/ascend-toolkit/latest/opp/vendors/customize/op_api/lib:${LD_LIBRARY_PATH} ``` -------------------------------- ### Install Files Configuration Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/sub_frameworklaunch/CMakeLists.txt Defines files to be installed as part of the build process. This example installs 'sub_frameworklaunch.cpp' to a specific destination directory. ```cmake install(FILES op_kernel/sub_frameworklaunch.cpp DESTINATION ${ASCEND_IMPL_OUT_DIR}/dynamic) ``` -------------------------------- ### Installing Custom Operator Run Package Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Installs the compiled custom operator package (a .run file). It can be installed quietly to the default CANN package directory or to a specified custom path using the --install-path argument. ```bash ./build_out/CANN-custom_ops--linux..run --quiet ./build_out/CANN-custom_ops--linux..run --quiet --install-path=${install_path} ``` -------------------------------- ### Environment Configuration for Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/pooling/adaptive_max_pool3d_grad/examples/AclNNInvocationNaive/README.md Sets necessary environment variables for running the example, specifically DDK_PATH and NPU_HOST_LIB, which point to the Ascend toolkit installation. ```bash export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib ``` -------------------------------- ### Setting Environment Variables for CANN Toolkit Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Sets up the necessary environment variables for the Ascend CANN toolkit, depending on the installation path (root, non-root, or custom). Also includes exporting DDK_PATH and NPU_HOST_LIB for custom paths. ```bash source /usr/local/Ascend/ascend-toolkit/set_env.sh ``` ```bash source $HOME/Ascend/ascend-toolkit/set_env.sh ``` ```bash source ${install_path}/ascend-toolkit/set_env.sh ``` ```bash export DDK_PATH=${install_path}/ascend-toolkit/latest ``` ```bash export NPU_HOST_LIB=${install_path}/ascend-toolkit/latest/lib64 ``` -------------------------------- ### Configuring CMake for Custom Operator Compilation Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Shows example configurations within the CMakePresets.json file for setting the ASCEND_COMPUTE_UNIT and ASCEND_CANN_PACKAGE_PATH variables, which are crucial for custom operator compilation. ```json { "ASCEND_COMPUTE_UNIT": { "type": "STRING", "value": "ascendxxxy" }, "ASCEND_CANN_PACKAGE_PATH": { "type": "PATH", "value": "/usr/local/Ascend/ascend-toolkit/latest" } } ``` -------------------------------- ### Compile and Run AclNN Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/conv/conv2d_backprop_input_v2/examples/AclNNInvocationNaive/README.md Steps to compile and run the AclNN single-operator invocation example. This involves navigating to the example directory, setting environment variables, and then building and executing the test. ```bash cd ${git_clone_path}/cann-ops/src/conv/conv2d_backprop_input_v2/examples/AclNNInvocationNaive # Environment variable configuration (example for arm) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # Build and run mkdir -p build cd build cmake .. && make ./execute_test_op ``` -------------------------------- ### Cloning cann-ops Repository Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Clones the cann-ops project source code from Gitee using the git command-line tool. ```bash git clone https://gitee.com/ascend/cann-ops.git ``` -------------------------------- ### ST Test Configuration File Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/xlogy/tests/st/README.md Example configuration file (msopst.ini) used for ST testing, specifying parameters like atc_singleop_advance_option and HOST_ARCH. ```ini # Example msopst.ini content # atc_singleop_advance_option = ... # HOST_ARCH = ... ``` -------------------------------- ### Run AclNN Example Operator Source: https://github.com/seelevolle/cann-ops/blob/master/src/conversion/pad_v3_grad_replication/examples/AclNNInvocationNaive/README.md Instructions to compile and run the AclNN operator example. This involves creating a build directory, configuring with CMake, compiling with make, and executing the generated binary. ```bash mkdir -p build cd build cmake .. && make ./execute_test_op ``` -------------------------------- ### Example Execution: Build and Run AngleV2 Operator Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/angle_v2/examples/AclNNInvocationNaive/README.md Steps to compile and run the AngleV2 operator example application. This involves navigating to the example directory, setting environment variables, generating test data, compiling the C++ code using CMake and Make, and executing the compiled application. ```bash cd ${git_clone_path}/cann-ops/src/math/angle_v2/examples/AclNNInvocationNaive # Environment variable configuration (example for arm) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/lib64 # Example execution python gen_data.py mkdir -p build cd build cmake .. && make ./execute_angle_v2_op cd .. ``` -------------------------------- ### Run Operator Example with run.sh Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/angle_v2/examples/AclNNInvocationNaive/README.md A convenience script to automate the compilation and execution process for the AngleV2 operator example. It encapsulates the build and run commands for a streamlined workflow. ```bash bash run.sh ``` -------------------------------- ### msopst.ini Configuration Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/fill/tests/st/README.md An example configuration file for msOpST, specifying parameters like `atc_singleop_advance_option` and `HOST_ARCH`. These settings are used to tailor the test execution to the specific hardware environment. ```ini ; Example configuration for msopst.ini ; Modify atc_singleop_advance_option and HOST_ARCH based on your execution machine's architecture. [common] ; ... other common configurations ... [msopst] atc_singleop_advance_option = "" HOST_ARCH = "" ; ... other msopst specific configurations ... ``` -------------------------------- ### Compile and Deploy Operator Package Source: https://github.com/seelevolle/cann-ops/blob/master/src/quant/dynamic_quant/README.md Provides shell commands to navigate to the repository, build the custom operator package, and deploy the generated installer. ```bash cd ${git_clone_path}/cann-ops ``` ```bash bash build.sh ``` ```bash bash build_out/CANN-custom_ops--linux..run ``` -------------------------------- ### Execute Example via Script Source: https://github.com/seelevolle/cann-ops/blob/master/src/index/feeds_repeat/examples/AclNNInvocationNaive/README.md Run the example application using the provided run.sh script, which automates the build and execution process. ```bash bash run.sh ``` -------------------------------- ### AclNNInvocationNaive Example Execution Source: https://github.com/seelevolle/cann-ops/blob/master/src/conversion/pad_v4_grad/examples/AclNNInvocationNaive/README.md Steps to compile and run the AclNNInvocationNaive example. This includes navigating to the example directory, setting necessary environment variables, and executing the build and run commands. ```bash cd ${git_clone_path}/cann-ops/src/math/pad_v4_grad/examples/AclNNInvocationNaive # Environment variable configuration (example for arm) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # Build and run mkdir -p build cd build cmake .. && make ./execute_add_op ``` -------------------------------- ### Example Execution Commands Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/fast_gelu_grad/examples/AclNNInvocationNaive/README.md Commands to navigate to the example directory, configure environment variables, and build/run the FastGeluGrad operator example. ```Bash cd ${git_clone_path}/cann-ops/src/math/fast_gelu_grad/examples/AclNNInvocationNaive export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib mkdir -p build cd build cmake .. && make ./execute_fast_gelu_grad_op ``` -------------------------------- ### Build and Deploy Cross Operator Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/cross/README.md Commands to compile the CANN custom operator and deploy the operator package. Requires the CANN software installation guide for environment setup. ```bash cd ${git_clone_path}/cann-ops bash build.sh bash build_out/CANN-custom_ops--linux..run ``` -------------------------------- ### ST Test Execution Environment Setup Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/clip_by_value_v2/tests/st/README.md Configures essential environment variables required for running System Tests (ST) with the msOpST tool. These variables point to the installation directory and host library. ```bash export DDK_PATH=${INSTALL_DIR} export NPU_HOST_LIB=${INSTALL_DIR}/{arch-os}/devlib ``` -------------------------------- ### build.sh Script Parameters Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Lists the available parameters for the build.sh script, used for compiling custom operator packages. Includes options for specifying operator names and enabling unit tests. ```APIDOC build.sh Script Usage: - build.sh Description: Compiles all custom operator packages. - build.sh -n Description: Compiles and packages a specific custom operator by its name. Example: bash build.sh -n add_custom - build.sh -t Description: Compiles and executes unit tests for the operators. - build.sh --help Description: Displays all available parameters and usage information for the build script. ``` -------------------------------- ### Compile and Run Operator Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/select_reduce_max_d_sub_exp_reduce_sum_d_real_div/examples/AclNNInvocationNaive/README.md Steps to compile and run the operator example application. This involves navigating to the example directory, setting environment variables, and then building and executing the application. ```bash cd ${git_clone_path}/cann-ops/src/math/select_reduce_max_d_sub_exp_reduce_sum_d_real_div/examples/AclNNInvocationNaive # Environment variable configuration (example for arm) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # Example execution mkdir -p build cd build cmake .. && make ./execute_select_reduce_max_d_sub_exp_reduce_sum_d_real_div_op ``` -------------------------------- ### ST Test Execution Environment Setup Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/triu/tests/st/README.md Configures essential environment variables required for running System Tests (ST) with the msOpST tool. These variables point to the installation directory and NPU host libraries. ```bash export DDK_PATH=${INSTALL_DIR} export NPU_HOST_LIB=${INSTALL_DIR}/{arch-os}/devlib ``` -------------------------------- ### Build and Run Example Application Source: https://github.com/seelevolle/cann-ops/blob/master/src/index/feeds_repeat/examples/AclNNInvocationNaive/README.md Compile the example application using CMake and Make, then execute the compiled binary. This process automatically generates test data, compiles, and runs the AclNN example. ```bash mkdir -p build cd build cmake .. && make ./execute_add_op ``` -------------------------------- ### Run ForeachAtan Operator Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/foreach/foreach_atan/examples/AclNNInvocationNaive/README.md Executes the ForeachAtan operator example. This script automatically generates test data, compiles and runs the aclnn example, and prints the results. ```Bash cd ${git_clone_path}/cann-ops/src/foreach/foreach_atan/examples/AclNNInvocationNaive bash run.sh ``` -------------------------------- ### Compile and Run Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/conversion/strided_slice_assign_v2/examples/AclNNInvocationNaive/README.md Instructions for compiling and running the AclNNInvocationNaive example, including setting environment variables and executing the build and run commands. ```bash # Navigate to the example directory cd ${git_clone_path}/cann-ops/src/math/add_custom/examples/AclNNInvocationNaive # Set environment variables (example for ARM) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # Build and run the example mkdir -p build cd build cmake .. && make ./execute_add_op # Alternatively, use the provided run.sh script # bash run.sh ``` -------------------------------- ### Execute UpsampleTrilinear3dBackward Example via run.sh Source: https://github.com/seelevolle/cann-ops/blob/master/src/image/upsample_trilinear3d_backward/examples/AclNNInvocationNaive/README.md This script executes the `AclNNInvocationNaive` example for the UpsampleTrilinear3dBackward operator. It guides users to navigate to the example directory and then run the `run.sh` script, which automatically generates test data, compiles, runs the aclnn example, and prints the results. ```bash cd ${git_clone_path}/cann-ops/src/image/upsample_trilinear3d_backward/examples/AclNNInvocationNaive bash run.sh ``` -------------------------------- ### CMakePresets.json Configuration Options Source: https://github.com/seelevolle/cann-ops/blob/master/QuickStart.md Describes key configuration options within the CMakePresets.json file used for building custom operators. These include specifying the target compute unit and the path to the CANN package. ```APIDOC CMakePresets.json Configuration: - ASCEND_COMPUTE_UNIT: Type: STRING Description: Specifies the Ascend compute unit (chip type) for compilation. This value can be queried using the 'npu-smi info' command (Name column). Example Value: "ascendxxxy" - ASCEND_CANN_PACKAGE_PATH: Type: PATH Description: Specifies the installation path of the Ascend CANN development toolkit. This value can be queried using 'echo ${ASCEND_HOME_PATH}'. Example Value: "/usr/local/Ascend/ascend-toolkit/latest" ``` -------------------------------- ### Deploy Operator Package Source: https://github.com/seelevolle/cann-ops/blob/master/src/image/upsample_nearest_exact3d_grad/README.md Command to install the compiled custom operator package onto the system. This typically involves running a generated installer script. ```bash bash build_out/CANN-custom_ops--linux..run ``` -------------------------------- ### Build and Execute Example Operator Source: https://github.com/seelevolle/cann-ops/blob/master/src/quant/dynamic_quant/examples/AclNNInvocationNaive/README.md Commands to compile and run the AclNNInvocationNaive example. This involves creating a build directory, configuring the build with CMake, compiling the project using make, and then executing the compiled application. ```bash mkdir -p build cd build cmake .. && make ./execute_test_op ``` -------------------------------- ### Configure Environment Variables for Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/index/feeds_repeat/examples/AclNNInvocationNaive/README.md Set necessary environment variables for the example execution, specifically DDK_PATH and NPU_HOST_LIB, which are required for Ascend toolkit components. ```bash export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib ``` -------------------------------- ### Compiling and Running the Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/conv/conv3d_backprop_input_v2/examples/AclNNInvocationNaive/README.md Steps to compile and execute the Conv3DBackpropInputV2 operator example. This includes navigating to the example directory, setting necessary environment variables (DDK_PATH, NPU_HOST_LIB), building the project using CMake and Make, and running the compiled executable. ```bash cd ${git_clone_path}/cann-ops/src/conv/conv3d_backprop_input_v2/examples/AclNNInvocationNaive export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/lib64 mkdir -p build cd build cmake .. && make ./execute_conv3d_backprop_input_v2_op cd .. bash run.sh ``` -------------------------------- ### Compile and Run Operator Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/eye_fp64/examples/AclNNInvocationNaive/README.md Shell script to compile and run the EyeFp64 operator example. It handles environment setup and execution for testing the operator's functionality. ```bash run.sh ``` -------------------------------- ### Compile and Run AclNN Naive Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/conversion/pad_v3_grad_replicate/examples/AclNNInvocationNaive/README.md Steps to compile and execute the naive AclNN invocation example. This includes navigating to the example directory, setting necessary environment variables for the Ascend toolkit, building the project using CMake and Make, and running the compiled executable. ```bash cd ${git_clone_path}/cann-ops/src/math/reflection_pad_3d_grad/examples/AclNNInvocationNaive export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib mkdir -p build cd build cmake .. && make ./execute_test_op ``` -------------------------------- ### Install PyTorch and Torch-NPU Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/add_custom/examples/CppExtensions/README.md Installs specific versions of PyTorch and the torch-npu package, which are prerequisites for running the provided examples. These commands ensure compatibility with the CANN framework. ```bash pip3 install torch==2.1.0 pip3 install torch-npu==2.1.0.post10 ``` -------------------------------- ### Example Execution Steps Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/inplace_fused_matmul_softmax_grad/examples/AclNNInvocationNaive/README.md Instructions for compiling and running the aclnn example. This includes navigating to the example directory, setting environment variables, and executing the build and run commands. ```bash # Navigate to example directory cd ${git_clone_path}/cann-ops/src/math/inplace_fused_matmul_softmax_grad/examples/AclNNInvocationNaive # Environment variable configuration (example for ARM) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # Build and run mkdir -p build cd build cmake .. && make ./execute_inplace_fused_matmul_softmax_op # Alternatively, use the provided script # bash run.sh ``` -------------------------------- ### Example Test Case Definition File Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/rsqrt/tests/st/README.md An example JSON file structure for defining test cases, including various data types and scenarios for operator testing. ```json { "test_cases": [ { "input": { "data": [1.0, 4.0, 9.0, 16.0] }, "expected_output": { "data": [1.0, 0.5, 0.3333333333333333, 0.25] }, "type": "float32" } ] } ``` -------------------------------- ### Compile and Run KlDivTargetBackward Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/kl_div_target_backward/examples/AclNNInvocationNaive/README.md Shell script to compile and run the aclnn example for the KlDivTargetBackward operator. It includes steps for setting up environment variables and executing the compiled binary. ```bash cd ${git_clone_path}/cann-ops/src/math/kl_div_target_backward/examples/AclNNInvocationNaive export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/lib64 mkdir -p build cd build cmake .. && make ./execute_add_op ``` -------------------------------- ### Build and Run Example Operator Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/is_finite/examples/AclNNInvocationNaive/README.md Provides instructions to compile and run the IsFinite operator example. It involves navigating to the example directory, creating a build folder, configuring with CMake, compiling, and executing the generated binary. ```bash cd ${git_clone_path}/cann-ops/src/math/is_finite/examples/AclNNInvocationNaive mkdir -p build cd build cmake .. && make ./execute_is_finite_op ``` -------------------------------- ### Build and Run Example Script Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/bev_pool/examples/AclNNInvocationNaive/README.md Provides instructions and commands to compile and run the BevPool operator example. It includes setting environment variables, building the project using CMake and Make, and executing the compiled application. ```bash cd ${git_clone_path}/cann-ops/src/math/bev_pool/examples/AclNNInvocationNaive export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib mkdir -p build cd build cmake .. && make ./execute_add_op ``` -------------------------------- ### Build and Install PyTorch NPU Plugin Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/add_custom/examples/PytorchInvocation/README.md Copies custom kernel files, sets environment variables, builds the PyTorch NPU plugin, and installs it via pip. ```bash cp -rf op_plugin_patch/*.cpp ${PYTORCH_DIR}/third_party/op-plugin/op_plugin/ops/v2r1/opapi export DISABLE_INSTALL_TORCHAIR=FALSE cd ${PYTORCH_DIR} (bash ci/build.sh --python=${PYTHON_VERSION} --disable_rpc ; pip uninstall torch-npu -y ; pip3 install dist/*.whl) ``` -------------------------------- ### Run UpsampleBicubic2dGrad Example Script Source: https://github.com/seelevolle/cann-ops/blob/master/src/image/upsample_bicubic2d_grad/examples/AclNNInvocationNaive/README.md This bash script guides users through navigating to the example code directory and executing the `run.sh` script. The `run.sh` script handles the compilation and execution of the aclnn example for the UpsampleBicubic2dGrad operator, automatically generating test data and printing the results. ```bash cd ${git_clone_path}/cann-ops/src/image/upsample_bicubic2d_grad/examples/AclNNInvocationNaive bash run.sh ``` -------------------------------- ### Install ATK Dependencies Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/cast/tests/atk/README.md Installs the necessary ATK wheel package, which is a prerequisite for running the tests. Ensure all required dependencies are met before execution. ```bash pip3 install ATK*.whl ``` -------------------------------- ### CMakeLists.txt Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/kl_div_target_backward/examples/AclNNInvocationNaive/README.md CMake build script for compiling the KlDivTargetBackward operator example. ```cmake CMakeLists.txt ``` -------------------------------- ### Run ForeachMaximumScalar Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/foreach/foreach_maximum_scalar/examples/AclNNInvocationNaive/README.md Instructions to compile and run the ForeachMaximumScalar example. This involves navigating to the example directory and executing a shell script that handles data generation, compilation, and execution. ```bash cd ${git_clone_path}/cann-ops/src/foreach/foreach_maximum_scalar/examples/AclNNInvocationNaive bash run.sh ``` -------------------------------- ### ST Test Case Definition Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/xlogy/tests/st/README.md Example JSON file (Xlogy_case_alltype.json) defining test cases for operator testing, including input data, expected output, and boundary conditions. ```json { "test_cases": [ { "input": { "x": [1.0, 2.0, 3.0], "y": [2.0, 3.0, 4.0] }, "expected_output": { "z": [2.0, 6.0, 12.0] }, "description": "Basic xlogy test" } // ... other test cases ] } ``` -------------------------------- ### Example Execution Commands Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/histogram_v2/examples/AclNNInvocationNaive/README.md Steps to compile and run the aclnn example for the HistogramV2 operator. This includes navigating to the example directory, setting necessary environment variables (DDK_PATH, NPU_HOST_LIB), building the project using CMake and Make, and executing the compiled application. ```bash cd ${git_clone_path}/cann-ops/src/math/histogram_v2/examples/AclNNInvocationNaive export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib mkdir -p build cd build cmake .. && make ./execute_test_op ``` -------------------------------- ### AclNNInvocationNaive Directory Structure Source: https://github.com/seelevolle/cann-ops/blob/master/src/quant/dynamic_quant/examples/AclNNInvocationNaive/README.md Overview of the directory structure for the AclNNInvocationNaive example, highlighting key files such as CMakeLists.txt for compilation, gen_data.py for data generation, main.cpp for the application entry point, run.sh for script execution, and verify_result.py for result comparison. ```text ├── AclNNInvocationNaive │ ├── CMakeLists.txt // 编译规则文件 │ ├── gen_data.py // 算子期望数据生成脚本 │ ├── main.cpp // 单算子调用应用的入口 │ ├── run.sh // 编译运行算子的脚本 │ └── verify_result.py // 计算结果精度比对脚本 ``` -------------------------------- ### ST Test Configuration Example (msopst.ini) Source: https://github.com/seelevolle/cann-ops/blob/master/src/index/scatter_add_with_sorted/tests/st/README.md An example INI configuration file for msOpST, used to specify parameters like atc_singleop_advance_option and HOST_ARCH based on the execution machine's architecture. ```ini ; Example msopst.ini content ; atc_singleop_advance_option = "--enable_small_batch=1 --disable_fusion=1" ; HOST_ARCH = "aarch64" ``` -------------------------------- ### Navigate to Example Code Directory Source: https://github.com/seelevolle/cann-ops/blob/master/src/index/feeds_repeat/examples/AclNNInvocationNaive/README.md Change the current directory to the location of the example code for the AclNNInvocationNaive application. ```bash cd ${git_clone_path}/cann-ops/src/math/add_custom/examples/AclNNInvocationNaive ``` -------------------------------- ### Compile PyTorch Plugin and Install Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/kl_div_target_backward/examples/PytorchInvocation/README.md Compiles the PyTorch NPU plugin, installs it, and prepares the environment for running custom operators. This involves copying kernel files and building the wheel package. ```bash cp -rf op_plugin_patch/*.cpp ${PYTORCH_DIR}/third_party/op-plugin/op_plugin/ops/v2r1/opapi export DISABLE_INSTALL_TORCHAIR=FALSE cd ${PYTORCH_DIR} (bash ci/build.sh --python=${PYTHON_VERSION} --disable_rpc ; pip uninstall torch-npu -y ; pip3 install dist/*.whl) ``` -------------------------------- ### ST Test Case Definition Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/norm/add_rms_norm_cast/tests/st/README.md An example JSON file structure for defining ST test cases, including input data, expected outputs, and boundary conditions for operator testing. ```json { "AddRmsNormCast_case.json": "// Test case definition file example (generated by 8.0.RC3.alpha003 version)" } ``` -------------------------------- ### Compile and Run Example (Bash) Source: https://github.com/seelevolle/cann-ops/blob/master/src/conversion/reflection_pad3d_grad/examples/AclNNInvocationNaive/README.md Shell script commands to compile and execute the AclNNInvocationNaive example for the ReflectionPad3dGrad operator. This includes setting environment variables, building the project with CMake, and running the compiled executable. ```bash # Navigate to the example directory cd ${git_clone_path}/cann-ops/src/math/reflection_pad_3d_grad/examples/AclNNInvocationNaive # Set environment variables (example for arm) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # Build the project mkdir -p build cd build cmake .. && make # Execute the compiled test ./execute_test_op ``` -------------------------------- ### Compile and Run Operator Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/pre_layer_norm/examples/AclNNInvocationNaive/README.md Shell script and commands to compile the example application and run the operator test cases. ```Bash cd ${git_clone_path}/cann-ops/src/math/pre_layer_norm/examples/AclNNInvocationNaive mkdir -p build cd build cmake .. && make ./execute_add_op {case-id} ``` ```Bash bash run.sh {case-id} ``` -------------------------------- ### Test Case Definition Example (JSON) Source: https://github.com/seelevolle/cann-ops/blob/master/src/index/scatter_add_with_sorted/tests/st/README.md An example JSON file defining test cases for the scatter_add_with_sorted operator, typically used by the msOpST tool to specify inputs, outputs, and test scenarios. ```json { "test_cases": [ { "input_data": [ { "name": "input_tensor", "data_type": "float32", "shape": [1, 3, 224, 224] }, { "name": "indices", "data_type": "int32", "shape": [100], "value": "range(100)" }, { "name": "updates", "data_type": "float32", "shape": [100], "value": "random" } ], "expected_output": { "name": "output_tensor", "data_type": "float32", "shape": [1, 3, 224, 224] } } ] } ``` -------------------------------- ### Build and Deploy Operator Package Source: https://github.com/seelevolle/cann-ops/blob/master/src/foreach/foreach_mul_list/README.md Provides the necessary bash commands to compile the custom operator package and deploy it to the system. This includes navigating to the project directory, executing the build script, and running the deployment installer. ```bash cd ${git_clone_path}/cann-ops bash build.sh -n foreach_mul_list bash build_out/CANN-custom_ops--linux..run ``` -------------------------------- ### Get Soc Version Source: https://github.com/seelevolle/cann-ops/blob/master/src/conversion/pad_v4_grad/tests/st/README.md Retrieves the Soc Version by querying the NPU device information. ```bash npu-smi info ``` -------------------------------- ### Operator Package Compilation and Deployment Source: https://github.com/seelevolle/cann-ops/blob/master/src/foreach/foreach_sigmoid/README.md Instructions for compiling and deploying the custom operator package. This involves navigating to the repository, executing a build script, and running the deployment package. ```bash cd ${git_clone_path}/cann-ops bash build.sh -n foreach_sigmoid bash build_out/CANN-custom_ops--linux..run ``` -------------------------------- ### ST Test Case Definition Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/norm/inplace_add_rms_norm/tests/st/README.md An example JSON file structure for defining ST test cases. This file typically includes input data, expected outputs, and configuration for operator tests. ```json { "test_cases": [ { "case_name": "positive_case_1", "input": { "data": "[[1.0, 2.0], [3.0, 4.0]]", "axis": 0 }, "expected_output": { "output_data": "[[1.0, 2.0], [3.0, 4.0]]" }, "params": { "dtype": "float32" } } ] } ``` -------------------------------- ### Build and Deploy Isamin Operator Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/isamin/README.md Provides the necessary bash commands to compile the custom Isamin operator and deploy the generated operator package onto the target system. This includes navigating to the repository and executing build scripts. ```bash cd ${git_clone_path}/cann-ops bash build.sh -n isamin bash build_out/CANN-custom_ops--linux..run ``` -------------------------------- ### msopst.ini Configuration Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/matmul/gemm_v2/tests/st/README.md Example configuration file for msOpST, used to define test parameters and environment settings. Key parameters like atc_singleop_advance_option and HOST_ARCH may need adjustment based on the execution machine. ```ini ; st测试配置文件 ; ... other configurations ... atc_singleop_advance_option = HOST_ARCH = ``` -------------------------------- ### Test Case File Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/triu/tests/st/README.md An example of a test case definition file (JSON format) used for System Tests (ST). This file specifies inputs, expected outputs, and boundary conditions for operator testing. ```json { "test_cases": [ { "case_name": "triu_basic_test", "input": { "x": [[1, 2, 3], [4, 5, 6], [7, 8, 9]], "k": 0 }, "expected_output": { "y": [[1, 0, 0], [4, 5, 0], [7, 8, 9]] } } ] } ``` -------------------------------- ### Compile and Deploy Operator Package Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/isamax/README.md Commands to compile the custom operator package and deploy it. This involves navigating to the repository, executing the build script, and running the deployment package. ```bash cd ${git_clone_path}/cann-ops ``` ```bash bash build.sh -n isamax ``` ```bash bash build_out/CANN-custom_ops--linux..run ``` -------------------------------- ### Compile and Run Matmul Operator Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/matmul_api_constant/examples/AclNNInvocationNaive/README.md Instructions to compile and run the matmul_api_constant operator example. This involves setting up environment variables, creating a build directory, configuring with CMake, compiling with Make, and executing the compiled binary. ```bash cd ${git_clone_path}/cann-ops/src/math/matmul_api_constant/examples/AclNNInvocationNaive # Environment variable configuration (example for arm) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # Compilation and execution mkdir -p build cd build cmake .. && make ./execute_matmul_api_constant_op ``` ```bash bash run.sh ``` -------------------------------- ### Run Operator Script Source: https://github.com/seelevolle/cann-ops/blob/master/src/conv/conv2d_backprop_input_v2/examples/AclNNInvocationNaive/README.md A shell script that automates the compilation and execution process for the operator example. ```bash # run.sh # Script for compiling and running the operator ``` -------------------------------- ### Bash Script for Running GreaterEqual Operator Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/greater_equal/examples/AclNNInvocationNaive/README.md Provides instructions and commands to compile and run the aclnnGreaterEqual operator example. It includes navigating to the example directory, setting environment variables for Ascend toolkit, building the project using CMake and Make, and executing the compiled binary. ```bash cd ${git_clone_path}/cann-ops/src/math/greater_equal/examples/AclNNInvocationNaive # 环境变量配置 (以arm为例) export DDK_PATH=/usr/local/Ascend/ascend-toolkit/latest export NPU_HOST_LIB=/usr/local/Ascend/ascend-toolkit/latest/aarch64-linux/devlib # 样例执行 mkdir -p build cd build cmake .. && make ./execute_greater_equal_op # 或者使用run.sh脚本 bash run.sh ``` -------------------------------- ### ST Test Case Definition Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/norm/dua_quantize_add_layer_norm/tests/st/README.md An example JSON file structure for defining System Test (ST) cases. This file typically includes various input data, expected outputs, and boundary conditions for operator testing. ```json { "version": "1.0", "test_cases": [ { "name": "basic_add_layer_norm", "description": "Test with typical input values.", "input": { "x": [1.0, 2.0, 3.0, 4.0], "gamma": 1.0, "beta": 0.0, "epsilon": 1e-5 }, "expected_output": { "y": [0.4472135954999579, 0.8944271909999159, 1.3416407864998738, 1.7888543819998317] }, "type": "normal" } ] } ``` -------------------------------- ### Example Directory Structure Source: https://github.com/seelevolle/cann-ops/blob/master/src/math/clip_by_value_v2/examples/AclNNInvocationNaive/README.md Overview of the directory structure for the AclNNInvocationNaive example, highlighting key files like CMakeLists.txt, data generation scripts, main application entry point, run script, and verification script. ```text ├── AclNNInvocationNaive │ ├── CMakeLists.txt // 编译规则文件 │ ├── gen_data.py // 算子期望数据生成脚本 │ ├── main.cpp // 单算子调用应用的入口 │ ├── run.sh // 编译运行算子的脚本 │ └── verify_result.py // 计算结果精度比对脚本 ``` -------------------------------- ### GemmV2 Test Case Definition Example Source: https://github.com/seelevolle/cann-ops/blob/master/src/matmul/gemm_v2/tests/st/README.md Example JSON file defining test cases for the GemmV2 operator. This file typically includes various input data types, expected outputs, and boundary conditions for comprehensive testing. ```json // GemmV2_case_all_type.json // { // "test_cases": [ // { // "input_data": { // "input_x": "...", // "input_y": "..." // }, // "expected_output": "...", // "boundary_conditions": "..." // } // ] // } ```