SHL is a C and C++ neural-network operator library. This public distribution contains the portable reference backend and its test programs.
Included:
- Backend-neutral C API and data types.
- Portable reference implementations.
- Unit, performance, bare-metal, smoke, and conformance test sources.
- CMake package installation and small examples.
Architecture-specific optimized backend implementations are intentionally not part of this distribution. Backend-oriented test sources are retained so an external backend SDK can run the same conformance cases without exposing its implementation.
- CMake 3.21 or newer.
- A C++17 compiler.
- GoogleTest for unit tests; CMake can fetch the public upstream project.
- Google Benchmark for benchmarks; CMake can fetch the public upstream project.
- LibTorch when unit tests are enabled. Pass its extracted root as
LIBTORCH_PATH. - For RISC-V execution tests: a
riscv64-linux-gnu-*orriscv64-unknown-linux-gnu-*GCC toolchain,qemu-riscv64, and a matching RISC-V LibTorch distribution for the full unit suite.
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DSHL_BUILD_TESTS=OFF \
-DSHL_BUILD_BENCHMARKS=OFF \
-DSHL_BUILD_EXAMPLES=ON \
-DSHL_INSTALL=ON
cmake --build build -jThe reference backend is always selected in this distribution. The generated libraries are libshl_ref.so and libshl_ref.a.
The full RISC-V suite uses the same portable GoogleTest sources as x86 and a
matching RISC-V LibTorch distribution. The public toolchain auto-detects the compiler,
sysroot, and qemu-riscv64:
cmake -S . -B build-riscv \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/riscv64-linux-gnu.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DSHL_BUILD_TESTS=ON \
-DSHL_BUILD_QEMU_TESTS=OFF \
-DSHL_BUILD_BENCHMARKS=OFF \
-DSHL_BUILD_EXAMPLES=OFF \
-DLIBTORCH_PATH=/path/to/riscv64/libtorch
cmake --build build-riscv --target shl_qemu_unit_tests -jIn this snapshot, CTest discovers the same 1824 named tests on x86 and RISC-V. The aggregate target above runs all tests in one QEMU process to avoid loading LibTorch 1824 times. CTest still exposes every case for filtering and reruns:
ctest --test-dir build-riscv -N -L riscv
ctest --test-dir build-riscv -L riscv -R ReLU --output-on-failureThe Makefile shortcut is:
make test_riscv_qemu RISCV_LIBTORCH_PATH=/path/to/riscv64/libtorchA lightweight test without LibTorch remains available as
make test_riscv_qemu_smoke. For tools outside PATH, set
SHL_RISCV_TOOLCHAIN_PREFIX, SHL_QEMU_RISCV64, and SHL_RISCV_SYSROOT.
cmake -S . -B build-test \
-DCMAKE_BUILD_TYPE=Release \
-DSHL_BUILD_TESTS=ON \
-DSHL_BUILD_BENCHMARKS=OFF \
-DLIBTORCH_PATH=/path/to/libtorch
cmake --build build-test -j
ctest --test-dir build-test --output-on-failureSee docs/testing.md for the public test tiers and optional conformance sources.
cmake --install build --prefix /tmp/shl-installA consuming project can use:
find_package(shl REQUIRED)
target_link_libraries(my_target PRIVATE shl::shl)This branch is a history-free public snapshot derived from an immutable internal release. See OPEN_SOURCE_PROVENANCE.md for the exact source commit and filtering policy.
Licensed under the Apache License, Version 2.0. See LICENSE.