### Get Example Help on Android Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Runs an example executable on the Android device with the --help argument to display its available options and arguments. ```bash adb shell /data/local/tmp/graph_lenet --help ``` -------------------------------- ### Build Examples with Bazel Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox This Bazel command builds all example executables provided with the Compute Library. ```bash bazel build //examples:all ``` -------------------------------- ### Build ResNet50 Example with Bazel Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Build a specific example, 'graph_resnet50', using Bazel. ```bash bazel build //examples:graph_resnet50 ``` -------------------------------- ### Build Libraries, Examples, and Tests with CMake Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Configure and build the Compute Library with support for libraries, examples, and tests using CMake. This example enables OpenMP, builds examples, and builds tests. ```bash cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DARM_COMPUTE_ENABLE_OPENMP=1 -DARM_COMPUTE_BUILD_EXAMPLES=1 -DARM_COMPUTE_BUILD_TESTING=1 cmake --build build -j32 ``` -------------------------------- ### Display Help for graph_lenet Example Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Run the graph_lenet example with the --help argument to view its specific command-line parameters. ```bash LD_LIBRARY_PATH=. ./graph_lenet --help ``` -------------------------------- ### Gemm Config File Example Source: https://github.com/arm-software/computelibrary/blob/main/examples/gemm_tuner/README.md An example of the format for a Gemm configuration file. This file specifies parameters for tuning GEMM operations. ```text 4,4,4,1,3,1,1,1,0 4,4,4,3,3,1,1,0,1 ... ``` -------------------------------- ### Transfer and Run Examples on Android Device (64-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Uses ADB to push compiled 64-bit example executables and shared libraries to the Android device, sets execute permissions, and runs them. ```bash adb push neon_cnn_aarch64 /data/local/tmp/ adb push cl_sgemm_aarch64 /data/local/tmp/ adb push gc_absdiff_aarch64 /data/local/tmp/ adb shell chmod 777 -R /data/local/tmp/ adb shell /data/local/tmp/neon_cnn_aarch64 adb shell /data/local/tmp/cl_sgemm_aarch64 adb shell /data/local/tmp/gc_absdiff_aarch64 ``` -------------------------------- ### Quick Examples for Matmul and iMatmul Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/benchmark/README.md Run both matmul and imatmul benchmarks with example dimensions. The default operator is matmul if none is specified. ```sh ./kleidiai_benchmark matmul -m 32 -n 32 -k 32 ./kleidiai_benchmark imatmul -m 32 -n 32 -c 4 -l 8 ``` -------------------------------- ### Transfer and Run Examples on Android Device (32-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Uses ADB to push compiled 32-bit example executables and shared libraries to the Android device, sets execute permissions, and runs them. ```bash adb push neon_cnn_arm /data/local/tmp/ adb push cl_sgemm_arm /data/local/tmp/ adb push gc_absdiff_arm /data/local/tmp/ adb shell chmod 777 -R /data/local/tmp/ adb shell /data/local/tmp/neon_cnn_arm adb shell /data/local/tmp/cl_sgemm_arm adb shell /data/local/tmp/gc_absdiff_arm ``` -------------------------------- ### iMatmul Benchmark Example Output Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/benchmark/README.md Example output from the imatmul benchmark, detailing various configurations and their performance metrics. ```text ./kleidiai_benchmark imatmul -m 32 -n 32 -c 4 -l 16 Run on (12 X 24 MHz CPU s) Load Average: 4.59, 3.95, 3.95 --------------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------------------------------------------------- imatmul_clamp_f16_f16p2vlx2_f16p2vlx2_2vlx2vl_sme2_mopa 123 ns 123 ns 1234567 imatmul_clamp_f16_f16p2vlx2_f16p2vlx2b_2vlx2vl_sme_mopa 123 ns 123 ns 1234567 imatmul_clamp_f32_f32p2vlx1_f32p2vlx1b_2vlx2vl_sme2_mopa 123 ns 123 ns 1234567 imatmul_clamp_f32_f32p2vlx1_f32p2vlx1b_2vlx2vl_sme_mopa 123 ns 123 ns 1234567 imatmul_clamp_qai8_qai8p2vlx4_qsi8cxp2vlx4sb_2vlx2vl_sme_mopa 123 ns 123 ns 1234567 imatmul_clamp_qai8_qai8p2vlx4_qsi8cxpsb2vlx4_2vlx2vl_sme2_mopa 123 ns 123 ns 1234567 ``` -------------------------------- ### Cross-compile Neon Example for Android Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compile a Neon example for Android, linking against the static Arm Compute library. ```bash #32 bit: arm-linux-androideabi-clang++ examples/neon_cnn.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -larm_compute-static -L. -o neon_cnn_arm -static-libstdc++ -pie ``` ```bash #64 bit: aarch64-linux-android-clang++ examples/neon_cnn.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -larm_compute-static -L. -o neon_cnn_aarch64 -static-libstdc++ -pie ``` -------------------------------- ### Compile Example for Android (64-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compiles the graph_lenet example for a 64-bit Android target using clang++. Ensure Arm Compute Library is built with OpenCL support. ```bash aarch64-linux-android-clang++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp utils/CommonGraphOptions.cpp -I. -Iinclude -std=c++14 -Wl,--whole-archive -larm_compute_graph-static -Wl,--no-whole-archive -larm_compute-static -L. -o graph_lenet_aarch64 -static-libstdc++ -pie -DARM_COMPUTE_CL ``` -------------------------------- ### Compile Example for Android (32-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compiles the graph_lenet example for a 32-bit Android target using clang++. Ensure Arm Compute Library is built with OpenCL support. ```bash arm-linux-androideabi-clang++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp utils/CommonGraphOptions.cpp -I. -Iinclude -std=c++14 -Wl,--whole-archive -larm_compute_graph-static -Wl,--no-whole-archive -larm_compute-static -L. -o graph_lenet_arm -static-libstdc++ -pie -DARM_COMPUTE_CL ``` -------------------------------- ### Build Everything with Bazel Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Use this command to build all components of the Compute Library, including libraries, examples, and tests, using Bazel. ```bash bazel build //... ``` -------------------------------- ### Define a Data Fixture Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/tests.dox Create a parameterized fixture by making the setup method a template. This allows passing arguments to the setup method at runtime. ```cpp class CustomFixture : public framework::Fixture { #ifdef ALTERNATIVE_DECLARATION template void setup(size_t size) { _ptr = malloc(size); } #else template void setup(T size) { _ptr = malloc(size); } #endif void run() { ARM_COMPUTE_ASSERT(_ptr != nullptr); } void teardown() { free(_ptr); } void *_ptr; }; ``` -------------------------------- ### GEMM Config File Example (native strategy) Source: https://github.com/arm-software/computelibrary/blob/main/examples/gemm_tuner/README.md A CSV file for the 'native' strategy, listing GEMMConfigs as . ```csv 1,4,4 2,3,8 ... ``` -------------------------------- ### Cross-compile Neon Example for Linux (64-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compiles a Neon C++ example for Linux 64-bit, linking against the Arm Compute Library. ```bash aarch64-linux-gnu-g++ examples/neon_cnn.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -L. -larm_compute -o neon_cnn ``` -------------------------------- ### Matmul Benchmark Example Output Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/benchmark/README.md Example output from the matmul benchmark, showing various configurations and their performance metrics. ```text $ ./kleidiai_benchmark matmul -m 13 -n 17 -k 18 Run on (8 X 1800 MHz CPU s) Load Average: 10.01, 10.06, 10.06 ----------------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations ----------------------------------------------------------------------------------------------------- matmul_clamp_f32_qai8dxp1x8_qsi4cxp4x8_1x4x32_neon_dotprod 123 ns 123 ns 1234567 matmul_clamp_f32_qai8dxp1x8_qsi4cxp8x8_1x8x32_neon_dotprod 123 ns 123 ns 1234567 matmul_clamp_f32_qai8dxp4x8_qsi4cxp4x8_4x4x32_neon_i8mm 123 ns 123 ns 1234567 matmul_clamp_f32_qai8dxp4x8_qsi4cxp4x8_8x4x32_neon_i8mm 123 ns 123 ns 1234567 matmul_clamp_f32_qai8dxp4x8_qsi4cxp8x8_4x8x32_neon_i8mm 123 ns 123 ns 1234567 matmul_clamp_f32_qai8dxp4x8_qsi4cxp8x8_8x8x32_neon_i8mm 123 ns 123 ns 1234567 ``` -------------------------------- ### Run Built Executable Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Execute a compiled Compute Library example. Ensure the library path is correctly set using LD_LIBRARY_PATH. ```bash LD_LIBRARY_PATH=build ./neon_cnn ``` ```bash LD_LIBRARY_PATH=build ./cl_sgemm ``` -------------------------------- ### Experimental CMake Build with LLVM+Clang Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Example of building the Compute Library using CMake with LLVM/Clang as the compiler. This command enables OpenMP, examples, and testing. ```bash CC=clang CXX=clang++ cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DARM_COMPUTE_ENABLE_OPENMP=1 -DARM_COMPUTE_BUILD_EXAMPLES=1 -DARM_COMPUTE_BUILD_TESTING=1 -DCMAKE_INSTALL_LIBDIR=. ``` ```bash CC=clang CXX=clang++ cmake --build build -j32 ``` -------------------------------- ### Setup Memory Manager with CLBufferAllocator Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/library.dox Demonstrates setting up a Memory Manager using a CLBufferAllocator for backing memory allocation. This is an alternative to the generic Allocator. ```cpp // Setup Memory Manager CLBufferAllocator allocator{}; // Create an allocator to use for the backing memory allocation ``` -------------------------------- ### CMake Build Script Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/docs/matmul_qsi4cx/README.md Example CMakeLists.txt for compiling the matrix multiplication example. It sets C++ standard, defines paths to KleidiAI components, and lists required source files. ```cmake cmake_minimum_required(VERSION 3.16) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") set(KLEIDIAI_PATH ../../) set(MATMUL_PACK_PATH ${KLEIDIAI_PATH}/kai/ukernels/matmul/pack/) set(MATMUL_PATH ${KLEIDIAI_PATH}/kai/ukernels/matmul/matmul_clamp_f32_qai8dxp_qsi4cxp/) # KleidiAI include directories include_directories( ${KLEIDIAI_PATH} ${MATMUL_PACK_PATH} ${MATMUL_PATH}) # Files requires to build the executable add_executable(matmul_clamp_f32_qai8dxp_qsi4cxp matmul_clamp_f32_qai8dxp_qsi4cxp.cpp ${MATMUL_PACK_PATH}/kai_rhs_pack_nxk_qsi4cxp_qs4cxs1s0.c ${MATMUL_PACK_PATH}/kai_rhs_pack_kxn_qsi4cxp_qs4cxs1s0.c ${MATMUL_PACK_PATH}/kai_lhs_quant_pack_qai8dxp_f32.c ${MATMUL_PATH}/kai_matmul_clamp_f32_qai8dxp4x8_qsi4cxp8x8_8x8x32_neon_i8mm.c) ``` -------------------------------- ### Code Formatting Example Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/contribution_guidelines.dox This snippet demonstrates correct code formatting, including indentation with spaces, pointer/reference placement, and brace style. ```cpp for(int i = 0; i < width * height; ++i) { void *d = foo(ptr, i, &addr); static_cast(data)[i] = static_cast(d)[0]; } ``` -------------------------------- ### Select Test Mode Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/tests.dox Choose which datasets to use with the --mode option. It is recommended to start with --mode=precommit. ```bash ./arm_compute_benchmark --mode=precommit ``` -------------------------------- ### Initialize and Use Weights Manager Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/library.dox Demonstrates the basic setup and usage of the IWeightsManager for managing and transforming weight tensors to reduce memory requirements. ```cpp auto wm = std::make_shared(); // Create a weights manager ``` ```cpp wm->manage(weights); // Manage the weights wm->acquire(weights, &_reshape_weights_managed_function); // Acquire the address of the transformed weights based on the transform function wm->run(weights, &_reshape_weights_managed_function); // Run the transpose function ``` -------------------------------- ### Install Pre-commit Hooks Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/contribution_guidelines.dox Install pre-commit hooks to automatically format code and check for issues before committing. This command should be run in the root directory of the repository. ```bash pre-commit install ``` -------------------------------- ### Run Matmul Clamp Example Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/examples/matmul_clamp_f32_qsi8d32p_qsi4c32p/README.md Execute the compiled example, specifying the number of worker threads for the matmul operation. Use --help for a full list of arguments. ```bash $ ./matmul_clamp_f32_qsi8d32p_qsi4c32p --threads ``` -------------------------------- ### Cross-compile Neon Example for Linux (32-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compiles a Neon C++ example for Linux 32-bit, linking against the Arm Compute Library. ```bash arm-linux-gnueabihf-g++ examples/neon_cnn.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -mfpu=neon -L. -larm_compute -o neon_cnn ``` -------------------------------- ### Example: Differentiating Matrix Multiply Configurations Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/advanced.dox This example demonstrates how to configure two distinct Matrix Multiply (GEMM) operations, each representing a unique kernel configuration with different tensor shapes. These configurations would be assigned different 'config_id's by the CLTuner. ```cpp TensorShape a0 = TensorShape(32,32); TensorShape b0 = TensorShape(32,32); TensorShape c0 = TensorShape(32,32); TensorShape a1 = TensorShape(64,64); TensorShape b1 = TensorShape(64,64); TensorShape c1 = TensorShape(64,64); Tensor a0_tensor; Tensor b0_tensor; Tensor c0_tensor; Tensor a1_tensor; Tensor b1_tensor; Tensor c1_tensor; a0_tensor.allocator()->init(TensorInfo(a0, 1, DataType::F32)); b0_tensor.allocator()->init(TensorInfo(b0, 1, DataType::F32)); c0_tensor.allocator()->init(TensorInfo(c0, 1, DataType::F32)); a1_tensor.allocator()->init(TensorInfo(a1, 1, DataType::F32)); b1_tensor.allocator()->init(TensorInfo(b1, 1, DataType::F32)); c1_tensor.allocator()->init(TensorInfo(c1, 1, DataType::F32)); CLGEMM gemm0; CLGEMM gemm1; // Configuration 0 gemm0.configure(&a0, &b0, nullptr, &c0, 1.0f, 0.0f); // Configuration 1 gemm1.configure(&a1, &b1, nullptr, &c1, 1.0f, 0.0f); ``` -------------------------------- ### Setup Memory Manager Components Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/library.dox Initializes the necessary components for the Memory Manager: an allocator, a Lifetime Manager, a Pool Manager, and the Memory Manager itself. This setup is required before registering memory groups. ```cpp Allocator allocator{}; // Create an allocator to use for the backing memory allocation auto lifetime_mgr = std::make_shared(); // Create Lifetime Manager auto pool_mgr = std::make_shared(); // Create Pool Manager auto mm = std::make_shared(lifetime_mgr, pool_mgr); // Create Memory Manager ``` -------------------------------- ### Cross-compile Graph API Example for Linux (32-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compiles a Graph API C++ example for Linux 32-bit, linking against Arm Compute Library and Arm Compute Graph libraries. ```bash arm-linux-gnueabihf-g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp utils/CommonGraphOptions.cpp -I. -Iinclude -std=c++14 -mfpu=neon -L. -larm_compute_graph -larm_compute -Wl,--allow-shlib-undefined -o graph_lenet ``` -------------------------------- ### OpenCL Kernel Implementation Example Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/adding_operator.dox This snippet shows the structure of an OpenCL kernel implementation, focusing on the 'ClReshapeKernel' and its associated .cl file for defining the actual computation. ```cpp ClReshapeKernel Kernel ``` -------------------------------- ### ReshapeLayerFixture Example Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/adding_operator.dox Example of a ReshapeLayer fixture class for validation tests, including setup, run, and teardown methods. ```cpp #include #include #include #include namespace arm_compute { namespace test { namespace validation { namespace fixtures { class CLReshapeLayerFixture : public ReshapeLayerFixture { public: void setup() { ReshapeLayerFixture::setup(); CLScheduler::get().set_as_default(); } }; class NEReshapeLayerFixture : public ReshapeLayerFixture { public: void setup() { ReshapeLayerFixture::setup(); NEScheduler::get().set_as_default(); } }; } } } } ``` -------------------------------- ### Create a new C project Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/docs/matmul_qsi4cx/README.md Initialize a C project with an empty main function to begin. ```c int main(int argc, char** argv) { return 0; } ``` -------------------------------- ### Bazel Build System Example Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/AGENTS.md In BUILD.bazel files, file lists are named using a pattern like '[_]*_KERNELS[_ASM]'. Ensure new kernels are added to the appropriate list based on their technology and features. ```bazel [_]*_KERNELS[_ASM] ``` -------------------------------- ### ReshapeLayerDataset Example Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/adding_operator.dox Example of a dataset class for ReshapeLayer, dynamically creating datasets using iterators. ```cpp #include #include namespace arm_compute { namespace test { namespace datasets { class ReshapeLayerDataset { public: std::vector> reshape_shapes() const { return { { TensorShape(20, 30, 10), TensorShape(30, 20, 10) }, { TensorShape(10, 20, 30), TensorShape(20, 30, 10) }, { TensorShape(5, 5, 5), TensorShape(5, 25) }, { TensorShape(10), TensorShape(5, 2) } }; } }; } } } ``` -------------------------------- ### PoolingTypesDataset Example Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/adding_operator.dox Example of a dataset class for pooling types, returning tuples for test cases. ```cpp #include #include namespace arm_compute { namespace test { namespace datasets { class PoolingTypesDataset { public: std::vector pooling_types() const { return { PoolingType::MAX, PoolingType::AVG }; } }; } } } ``` -------------------------------- ### Configure and Run CPP Kernel Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/implementation_topics.dox Initializes a CPP kernel with input/output and options, then runs it on the full window. ```cpp //Create a kernel object: MyKernel kernel; // Initialize the kernel with the input/output and options you want to use: kernel.configure( input, output, option0, option1); // Retrieve the execution window of the kernel: const Window& max_window = kernel.window(); // Run the whole kernel in the current thread: kernel.run( max_window ); // Run the kernel on the full window ``` -------------------------------- ### Build KleidiAI Benchmark Tool Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/benchmark/README.md Instructions to build the KleidiAI benchmark tool from the root directory. Ensure to set KLEIDIAI_BUILD_BENCHMARK to ON. ```bash mkdir -p build && cd build cmake -DKLEIDIAI_BUILD_BENCHMARK=ON -DCMAKE_BUILD_TYPE=Release ../ make -j ``` -------------------------------- ### Cross-compile OpenCL Example for Android Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compile an OpenCL example for Android, linking against the static Arm Compute library and defining ARM_COMPUTE_CL. ```bash #32 bit: arm-linux-androideabi-clang++ examples/cl_sgemm.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -larm_compute-static -L. -o cl_sgemm_arm -static-libstdc++ -pie -DARM_COMPUTE_CL ``` ```bash #64 bit: aarch64-linux-android-clang++ examples/cl_sgemm.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -larm_compute-static -L. -o cl_sgemm_aarch64 -static-libstdc++ -pie -DARM_COMPUTE_CL ``` -------------------------------- ### Cross-compile OpenCL Example for Linux (64-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compiles an OpenCL C++ example for Linux 64-bit, linking against the Arm Compute Library and defining ARM_COMPUTE_CL. ```bash aarch64-linux-gnu-g++ examples/cl_sgemm.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -L. -larm_compute -o cl_sgemm -DARM_COMPUTE_CL ``` -------------------------------- ### Cross-compile OpenCL Example for Linux (32-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Compiles an OpenCL C++ example for Linux 32-bit, linking against the Arm Compute Library and defining ARM_COMPUTE_CL. ```bash arm-linux-gnueabihf-g++ examples/cl_sgemm.cpp utils/Utils.cpp -I. -Iinclude -std=c++14 -mfpu=neon -L. -larm_compute -o cl_sgemm -DARM_COMPUTE_CL ``` -------------------------------- ### Configure and Run NEScale Operation Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/library.dox Demonstrates how to configure and run a scale operation using Arm Compute Library. Ensure allocation happens after configuration to avoid shrinking the execution window. ```cpp Image src{}, dst{}; NEScale scale{}; // Create an empty grayscale 640x480 image src.allocator()->init(TensorInfo(640, 480, Format::U8)); constexpr int scale_factor = 2; TensorInfo dst_tensor_info(src.info()->dimension(0) / scale_factor, src.info()->dimension(1) / scale_factor, Format::U8); // Configure the destination image dst.allocator()->init(dst_tensor_info); // Configure Scale function object: scale.configure(&src, &dst, ScaleKernelInfo{ InterpolationPolicy::NEAREST_NEIGHBOR, BorderMode::UNDEFINED, PixelValue(), SamplingPolicy::CENTER, false }); // Allocate all the images src.allocator()->allocate(); dst.allocator()->allocate(); // Fill the input image with the content of the PPM image if a filename was provided: fill_image(src); // Run the scale operation: scale.run(); ``` -------------------------------- ### Initialize OpenCL Scheduler and Kernel Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/implementation_topics.dox This C++ code demonstrates the initialization of the OpenCL scheduler and the creation and configuration of a custom kernel. It sets up the default OpenCL context, command queue, and kernel library location. ```cpp // Initialize the CLScheduler with the default context and default command queue // Implicitly initializes the CLKernelLibrary to use ./cl_kernels as location for OpenCL kernels files and sets a default device for which OpenCL programs are built. CLScheduler::get().default_init(); cl::CommandQueue q = CLScheduler::get().queue(); //Create a kernel object: MyKernel kernel; // Initialize the kernel with the input/output and options you want to use: kernel.configure( input, output, option0, option1); ``` -------------------------------- ### List All Available Benchmarks Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/benchmark/README.md Run the benchmark tool with the --benchmark_list_tests flag to see all available benchmark tests. ```bash ./kleidiai_benchmark --benchmark_list_tests ``` -------------------------------- ### CLAddReshapeLayer Constructor and Configure Method Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/adding_operator.dox Demonstrates the constructor and configure method for an OpenCL function that involves multiple kernels and intermediate tensor management. It shows memory allocation, intermediate buffer management, and kernel configuration. ```cpp using namespace arm_compute; CLAddReshapeLayer:: CLAddReshapeLayer(std::shared_ptr memory_manager) : _memory_group(std::move(memory_manager)) { } void CLAddReshapeLayer::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output) { // Allocate memory TensorInfo info(); add_output.allocator()->init(info); // Manage intermediate buffers memory_group.manage(&_addOutput); // Initialise kernel _add_kernel.configure(input1, input2, &add_output); _reshape_kernel.configure(&add_output, output); // Allocate intermediate tensors add_output.allocator()->allocate(); } ``` -------------------------------- ### Per-Operator Build Configuration Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/library.dox Example JSON configuration for building Compute Library with a user-defined list of operators and data types. This allows for smaller, more specialized library binaries. ```json { "operators": [ "Activation", "DepthwiseConv2d", "Conv2d", "Permute", "Pool2d", "Reshape" ], "data_types": [ "NHWC" ] } ``` -------------------------------- ### Install Pre-push Hook for Commit Message Validation Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/contribution_guidelines.dox Install a pre-push hook using Commitizen to validate commit message format before pushing to the remote repository. This ensures adherence to conventional commit standards. ```bash pre-commit install --hook-type pre-push ``` -------------------------------- ### Configure Target Include Directories Source: https://github.com/arm-software/computelibrary/blob/main/third_party/kleidiai/CMakeLists.txt Configures public include directories for the 'kleidiai' target. It specifies that include paths should be relative to the build interface and the installation directory, ensuring headers are accessible during build and after installation. ```cmake target_include_directories(kleidiai PUBLIC $ $) ``` -------------------------------- ### Include GNUInstallDirs Module in CMake Source: https://github.com/arm-software/computelibrary/blob/main/CMakeLists.txt Includes the GNUInstallDirs module to define standard installation directory variables like CMAKE_INSTALL_BINDIR, CMAKE_INSTALL_LIBDIR, and CMAKE_INSTALL_INCLUDEDIR. This promotes consistent installation practices across different systems. ```cmake include(GNUInstallDirs) ``` -------------------------------- ### NEActivationLayer Snippet Example Source: https://github.com/arm-software/computelibrary/blob/main/docs/contributor_guide/contribution_guidelines.dox This snippet demonstrates the usage of NEActivationLayer within the ARM Compute Library. ```cpp /** * @brief Performs activation function on a tensor. * * @param[in] src The input tensor. * @param[out] dst The output tensor. * @param[in] activation The activation function to use. */ void NEActivationLayer::run(const ITensor &src, ITensor &dst, const ActivationLayerInfo &activation) { // Implementation details... } ``` -------------------------------- ### Build Arm Compute Library Natively for Linux (Neon, 32-bit) Source: https://github.com/arm-software/computelibrary/blob/main/docs/user_guide/how_to_build_and_run_examples.dox Builds the library natively on an Arm device with Neon support for Linux 32-bit. ```bash scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux arch=armv7a build=native ```