tensoracle 2.2.3__tar.gz → 2.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tensoracle-2.2.3 → tensoracle-2.3.0}/CMakeLists.txt +1 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/PKG-INFO +1 -1
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/CMakeLists.txt +31 -5
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/README.md +32 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/cmake/tensoracleConfig.cmake.in +2 -2
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/tensoracle.h +5 -3
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/CMakeLists.txt +5 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/installed.cmake +9 -1
- tensoracle-2.3.0/cpp/tests/static_consumer/CMakeLists.txt +20 -0
- tensoracle-2.3.0/cpp/tests/static_consumer/fixture.cpp +69 -0
- tensoracle-2.3.0/cpp/tests/static_consumer/fixture.h +24 -0
- tensoracle-2.3.0/cpp/tests/static_consumer/main.c +52 -0
- tensoracle-2.3.0/cpp/tests/static_consumer/main.cpp +39 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/cpp-sdk.md +50 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/_version.py +2 -2
- tensoracle-2.3.0/tests/test_static_sdk.py +147 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/.gitignore +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/LICENSE +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/README.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/bindings.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/build_backend.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/cmake/TensoracleCubinPlugin.cmake +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/cmake/TensoracleCuda.cmake +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/cmake/TensoracleDependencies.cmake +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/bootstrap.cmake +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/install.cmake +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/prepare-tests.cmake +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/profiles/linux-gcc13 +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/profiles/linux-gcc14 +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes/cuda-toolkit/conanfile.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes/cuda-toolkit/redist.json +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes/tensorrt/LICENSE.NVIDIA +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes/tensorrt/LICENSE.OSS +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes/tensorrt/conandata.yml +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes/tensorrt/conanfile.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes.json +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan/recipes.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conan.lock +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/conanfile.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/builder.h +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/builder.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/cache.h +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/cache.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/cubin.h +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/cubin.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/cubin_plugin.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/engine.h +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/engine.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/plugins.h +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/plugins.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/include/tensoracle/tensoracle.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/abi.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/builder.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/builder_internal.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/bundle.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/bundle_internal.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/cache.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/cache.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/cache_management.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/cache_management_internal.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/cache_management_internal.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/cache_open.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/comparison.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/cubin_plugin.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/engine.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/engine_internal.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/error.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/error.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/native_exports.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/plugins.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/producer.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/safetensors.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/safetensors.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/sha256.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/structure.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/src/tensoracle.map +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/abi.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/builder.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/builder_fixture.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/builder_probe.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/c_consumer.c +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/cache.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/cache_management.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/cache_probe.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/comparison.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/concurrent_builder.hpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/consumer/CMakeLists.txt +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/consumer/main.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/core.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/cubin.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/driver_failures.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/execution.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/native_exports.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/native_exports_fixture.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/plugin_fixture.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/plugins.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/precision.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/runtime.cmake +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/utilities.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cpp/tests/weights.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/cubin_bindings.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/api/bundle.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/api/index.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/api/producer.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/cpp-python-repositories.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/index.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/migration.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/optimization.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/precision.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/docs/tensorrt-sdk.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/CMakeLists.txt +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/README.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bindings.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/bundle.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/bundle.json +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm120/bias.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm120/dot.specialized.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm120/dot.tf32-control.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm120/dot.unspecialized.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm120/scale.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm86/bias.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm86/dot.specialized.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm86/dot.tf32-control.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm86/dot.unspecialized.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm86/scale.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm89/bias.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm89/dot.specialized.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm89/dot.tf32-control.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm89/dot.unspecialized.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/bundle/cubins/sm89/scale.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/example_cubin_plugin/__init__.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/example_cubin_plugin/weights.safetensors +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/kernels.cu +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/kernels.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/plugin.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/cubin_plugin/pyproject.toml +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/wheel_consumer/CMakeLists.txt +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/wheel_consumer/README.md +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/wheel_consumer/bindings.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/wheel_consumer/pyproject.toml +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/examples/wheel_consumer/src/tensoracle_consumer/__init__.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/mkdocs.yml +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/pyproject.toml +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/__init__.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/_cli.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/_comparison.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/bundle.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/convert.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/producer.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/src/tensoracle/py.typed +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/cubin_io/check.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/cubins/ptxas-12.9.86/sm120.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/cubins/ptxas-12.9.86/sm86.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/cubins/ptxas-12.9.86/sm89.cubin +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/native/CMakeLists.txt +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/native/cache/CMakeLists.txt +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/native/cache/writer.cpp +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/native/export.h +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/native_build.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_build_distributions.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_bundle.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_cache_cli.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_cmake_cuda.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_cmake_plugin.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_comparison.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_comparison_binding.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_conan.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_convert.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_cpp_core.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_cpp_test_runtime.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_distribution.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_example_plugin.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_native.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_plugin_io.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_producer.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_public_api.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_recipe_acquisition.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/tests/test_tensorrt_recipe.py +0 -0
- {tensoracle-2.2.3 → tensoracle-2.3.0}/uv.lock +0 -0
|
@@ -21,6 +21,7 @@ set(TENSORACLE_INSTALL_RPATH "$ORIGIN/../../../tensorrt_libs" CACHE STRING "Tens
|
|
|
21
21
|
set(CMAKE_INSTALL_LIBDIR lib CACHE STRING "Wheel library directory" FORCE)
|
|
22
22
|
set(BUILD_TESTING OFF CACHE BOOL "Tests are built separately" FORCE)
|
|
23
23
|
set(TENSORACLE_BUILD_CUBIN_HELPER OFF CACHE BOOL "Ship the source-based helper" FORCE)
|
|
24
|
+
set(BUILD_SHARED_LIBS ON CACHE BOOL "Wheels ship the shared library" FORCE)
|
|
24
25
|
|
|
25
26
|
add_subdirectory("${_cpp}" cpp)
|
|
26
27
|
nanobind_add_module(_native STABLE_ABI bindings.cpp cubin_bindings.cpp)
|
|
@@ -16,8 +16,9 @@ project(tensoracle VERSION ${_tensoracle_MAJOR}.${_tensoracle_MINOR}.${_tensorac
|
|
|
16
16
|
include(GNUInstallDirs)
|
|
17
17
|
include(CMakePackageConfigHelpers)
|
|
18
18
|
include(cmake/TensoracleCuda.cmake)
|
|
19
|
+
option(BUILD_SHARED_LIBS "Build the shared tensoracle library" ON)
|
|
19
20
|
option(TENSORACLE_BUILD_CUBIN_HELPER "Build the standalone cubin helper archive" ON)
|
|
20
|
-
if(TENSORACLE_BUILD_CUBIN_HELPER)
|
|
21
|
+
if(TENSORACLE_BUILD_CUBIN_HELPER OR NOT BUILD_SHARED_LIBS)
|
|
21
22
|
# Preserve the existing helper's discovery and diagnostics for native builds.
|
|
22
23
|
_tensoracle_find_cuda()
|
|
23
24
|
get_target_property(TENSORACLE_CUDA_INCLUDE tensoracle_cuda_driver INTERFACE_INCLUDE_DIRECTORIES)
|
|
@@ -34,7 +35,7 @@ get_filename_component(_tensoracle_tensorrt_root "${TENSORACLE_TENSORRT_INCLUDE}
|
|
|
34
35
|
set(TENSORACLE_TENSORRT_LIBRARY "${_tensoracle_tensorrt_root}/lib/libnvinfer.so.11")
|
|
35
36
|
message(STATUS "TensorRT SDK from Conan: ${TENSORACLE_TENSORRT_INCLUDE}; ${TENSORACLE_TENSORRT_LIBRARY}")
|
|
36
37
|
|
|
37
|
-
add_library(tensoracle
|
|
38
|
+
add_library(tensoracle src/abi.cpp src/error.cpp src/bundle.cpp src/producer.cpp src/comparison.cpp)
|
|
38
39
|
target_sources(tensoracle PRIVATE src/engine.cpp src/cache.cpp src/plugins.cpp src/cache_open.cpp)
|
|
39
40
|
target_sources(tensoracle PRIVATE src/cache_management.cpp src/cache_management_internal.cpp)
|
|
40
41
|
target_sources(tensoracle PRIVATE src/builder.cpp src/safetensors.cpp)
|
|
@@ -44,18 +45,33 @@ if(NOT WIN32)
|
|
|
44
45
|
endif()
|
|
45
46
|
add_library(tensoracle::tensoracle ALIAS tensoracle)
|
|
46
47
|
target_compile_features(tensoracle PUBLIC cxx_std_17)
|
|
47
|
-
|
|
48
|
+
if(BUILD_SHARED_LIBS)
|
|
49
|
+
target_compile_definitions(tensoracle PRIVATE TENSORACLE_BUILDING_LIBRARY)
|
|
50
|
+
else()
|
|
51
|
+
target_compile_definitions(tensoracle PUBLIC TENSORACLE_STATIC_LIBRARY)
|
|
52
|
+
set_target_properties(tensoracle PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
|
53
|
+
endif()
|
|
48
54
|
target_include_directories(tensoracle PUBLIC
|
|
49
55
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
|
|
50
56
|
PRIVATE "${TENSORACLE_TENSORRT_INCLUDE}" "${TENSORACLE_CUDA_INCLUDE}")
|
|
51
|
-
|
|
57
|
+
if(BUILD_SHARED_LIBS)
|
|
58
|
+
target_link_libraries(tensoracle PRIVATE "${TENSORACLE_TENSORRT_LIBRARY}" tensoracle_json tensoracle_miniz ${CMAKE_DL_LIBS})
|
|
59
|
+
else()
|
|
60
|
+
# Keep third-party objects out of the archive and resolve their targets in
|
|
61
|
+
# the consumer's toolchain, without exporting this build's Conan paths.
|
|
62
|
+
target_link_libraries(tensoracle PRIVATE
|
|
63
|
+
"$<BUILD_INTERFACE:${TENSORACLE_TENSORRT_LIBRARY}>"
|
|
64
|
+
"$<BUILD_INTERFACE:tensoracle_json>" miniz::miniz
|
|
65
|
+
"$<BUILD_INTERFACE:tensoracle_internal_cuda_driver>"
|
|
66
|
+
"$<INSTALL_INTERFACE:tensoracle_cuda_driver>" ${CMAKE_DL_LIBS})
|
|
67
|
+
endif()
|
|
52
68
|
set(TENSORACLE_INSTALL_RPATH "$ORIGIN" CACHE STRING "Relative runtime lookup paths for the installed library")
|
|
53
69
|
set_target_properties(tensoracle PROPERTIES
|
|
54
70
|
VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}
|
|
55
71
|
CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES
|
|
56
72
|
BUILD_RPATH_USE_ORIGIN YES
|
|
57
73
|
INSTALL_RPATH "${TENSORACLE_INSTALL_RPATH}")
|
|
58
|
-
if(UNIX AND NOT APPLE)
|
|
74
|
+
if(BUILD_SHARED_LIBS AND UNIX AND NOT APPLE)
|
|
59
75
|
target_link_options(tensoracle PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/tensoracle.map")
|
|
60
76
|
set_property(TARGET tensoracle APPEND PROPERTY LINK_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/tensoracle.map")
|
|
61
77
|
endif()
|
|
@@ -99,6 +115,16 @@ install(FILES "${TENSORACLE_MINIZ_LICENSE}"
|
|
|
99
115
|
install(FILES src/cubin_plugin.cpp src/sha256.hpp DESTINATION "${_tensoracle_root}src")
|
|
100
116
|
install(FILES cmake/TensoracleCuda.cmake cmake/TensoracleCubinPlugin.cmake
|
|
101
117
|
DESTINATION "${TENSORACLE_HELPER_DIR}")
|
|
118
|
+
set(TENSORACLE_STATIC_DEPENDENCIES "")
|
|
119
|
+
if(NOT BUILD_SHARED_LIBS)
|
|
120
|
+
set(TENSORACLE_STATIC_DEPENDENCIES [=[ include(CMakeFindDependencyMacro)
|
|
121
|
+
find_dependency(miniz 3.1.1 EXACT CONFIG)
|
|
122
|
+
if(NOT WIN32)
|
|
123
|
+
find_dependency(Threads)
|
|
124
|
+
endif()
|
|
125
|
+
_tensoracle_find_cuda()
|
|
126
|
+
]=])
|
|
127
|
+
endif()
|
|
102
128
|
configure_package_config_file(cmake/tensoracleConfig.cmake.in
|
|
103
129
|
"${CMAKE_CURRENT_BINARY_DIR}/tensoracleConfig.cmake"
|
|
104
130
|
INSTALL_DESTINATION "${TENSORACLE_PACKAGE_DIR}" PATH_VARS TENSORACLE_HELPER_DIR)
|
|
@@ -6,6 +6,38 @@ GitHub Release: verify the archive's SHA256, extract it, and configure CMake wit
|
|
|
6
6
|
recipe is maintained separately and is not included in this repository.
|
|
7
7
|
The following commands build tensoracle from source.
|
|
8
8
|
|
|
9
|
+
The default is a shared library (`BUILD_SHARED_LIBS=ON`). To embed tensoracle
|
|
10
|
+
statically, build from source with `-DBUILD_SHARED_LIBS=OFF` and install the result:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
cmake -S cpp -B build/static -G Ninja -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF
|
|
14
|
+
cmake --build build/static --parallel 8
|
|
15
|
+
cmake --install build/static --prefix /path/to/prefix
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Both forms provide the same headers and CMake target, `tensoracle::tensoracle`.
|
|
19
|
+
The static archive contains only tensoracle's objects. Its installed CMake
|
|
20
|
+
package resolves miniz, the CUDA driver link stub, TensorRT, and the platform
|
|
21
|
+
thread and dynamic-loader libraries in the consumer's build environment. Use
|
|
22
|
+
the prepared Conan toolchain for those dependencies, as described in the
|
|
23
|
+
[SDK guide](../docs/cpp-sdk.md#embed-tensoracle-from-source). The static target
|
|
24
|
+
supplies `TENSORACLE_STATIC_LIBRARY` so public declarations do not import or
|
|
25
|
+
export a DLL. The standalone `tensoracle_cubin` archive and source-based cubin
|
|
26
|
+
plugin helpers remain available in source builds.
|
|
27
|
+
|
|
28
|
+
Release SDK archives and Python wheels contain the shared library only; static
|
|
29
|
+
libraries are not distributed. A source-building Conan recipe selects static
|
|
30
|
+
embedding with `from_source=True` and `shared=False`. TensorRT stays a shared
|
|
31
|
+
library supplied by the execution host. The current library uses the CUDA
|
|
32
|
+
Driver API and does not require the CUDA runtime.
|
|
33
|
+
|
|
34
|
+
A process must contain one tensoracle implementation shared by all its code.
|
|
35
|
+
If an application or library embeds tensoracle, that artifact must be the only
|
|
36
|
+
owner in the process: do not load another artifact embedding tensoracle or a
|
|
37
|
+
tensoracle shared library there. Python processes use the wheel's shared
|
|
38
|
+
library. Relink an artifact that embeds tensoracle whenever its embedded
|
|
39
|
+
tensoracle version is updated.
|
|
40
|
+
|
|
9
41
|
C++ builds require CMake 3.26 or later, Ninja, GCC 13 on Linux x86_64, the pinned
|
|
10
42
|
Conan dependencies. CUDA headers and the driver link stub come from the locked
|
|
11
43
|
`cuda-toolkit/13.2.2` recipe (`compiler=False`), as described in the
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
@PACKAGE_INIT@
|
|
2
2
|
include("@PACKAGE_TENSORACLE_HELPER_DIR@/TensoracleCubinPlugin.cmake")
|
|
3
3
|
if(NOT TARGET tensoracle::tensoracle)
|
|
4
|
-
if(NOT TARGET TensorRT::nvinfer)
|
|
4
|
+
@TENSORACLE_STATIC_DEPENDENCIES@ if(NOT TARGET TensorRT::nvinfer)
|
|
5
5
|
find_package(TensorRT QUIET CONFIG)
|
|
6
6
|
endif()
|
|
7
7
|
if(TARGET TensorRT::nvinfer)
|
|
@@ -31,7 +31,7 @@ if(NOT TARGET tensoracle::tensoracle)
|
|
|
31
31
|
get_filename_component(_tensoracle_nvinfer_dirs "${TENSORACLE_TENSORRT_LIBRARY}" DIRECTORY)
|
|
32
32
|
endif()
|
|
33
33
|
include("${CMAKE_CURRENT_LIST_DIR}/tensoracleTargets.cmake")
|
|
34
|
-
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
34
|
+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND @BUILD_SHARED_LIBS@)
|
|
35
35
|
# Resolve libtensoracle's DT_NEEDED at link time without adding a direct
|
|
36
36
|
# TensorRT dependency to consumers that already rely on its RUNPATH.
|
|
37
37
|
set_property(TARGET tensoracle::tensoracle APPEND PROPERTY
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
#include <stdint.h>
|
|
6
6
|
|
|
7
7
|
#define TENSORACLE_VERSION_MAJOR 2
|
|
8
|
-
#define TENSORACLE_VERSION_MINOR
|
|
9
|
-
#define TENSORACLE_VERSION_PATCH
|
|
8
|
+
#define TENSORACLE_VERSION_MINOR 3
|
|
9
|
+
#define TENSORACLE_VERSION_PATCH 0
|
|
10
10
|
|
|
11
|
-
#if defined(
|
|
11
|
+
#if defined(TENSORACLE_STATIC_LIBRARY)
|
|
12
|
+
# define TENSORACLE_API
|
|
13
|
+
#elif defined(_WIN32)
|
|
12
14
|
# if defined(TENSORACLE_BUILDING_LIBRARY)
|
|
13
15
|
# define TENSORACLE_API __declspec(dllexport)
|
|
14
16
|
# else
|
|
@@ -23,11 +23,16 @@ add_test(NAME "Installed SDK builds a separate C++ application"
|
|
|
23
23
|
"-DCONSUMER_SOURCE=${CMAKE_CURRENT_SOURCE_DIR}/consumer"
|
|
24
24
|
"-DCONFIG=$<CONFIG>"
|
|
25
25
|
"-DCXX=${CMAKE_CXX_COMPILER}"
|
|
26
|
+
"-DSHARED=${BUILD_SHARED_LIBS}"
|
|
26
27
|
"-DTENSORRT_LIBRARY=${TENSORACLE_TENSORRT_LIBRARY}"
|
|
27
28
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/installed.cmake")
|
|
28
29
|
set_tests_properties("Installed SDK builds a separate C++ application" PROPERTIES
|
|
29
30
|
ENVIRONMENT "${_tensoracle_test_environment}"
|
|
30
31
|
LABELS "SP-TENSORACLE-014;SP-TENSORACLE-021;SP-TENSORACLE-055;SP-TENSORACLE-057;SP-TENSORACLE-065" TIMEOUT 60)
|
|
32
|
+
if(NOT BUILD_SHARED_LIBS)
|
|
33
|
+
set_tests_properties("Installed SDK builds a separate C++ application" PROPERTIES
|
|
34
|
+
LABELS "SP-TENSORACLE-014;SP-TENSORACLE-021;SP-TENSORACLE-055;SP-TENSORACLE-073;SP-TENSORACLE-074")
|
|
35
|
+
endif()
|
|
31
36
|
|
|
32
37
|
add_executable(tensoracle_execution_test execution.cpp)
|
|
33
38
|
target_link_options(tensoracle_execution_test PRIVATE "LINKER:--export-dynamic-symbol=utimensat")
|
|
@@ -2,14 +2,22 @@ file(REMOVE_RECURSE "${WORK_DIR}")
|
|
|
2
2
|
set(prefix "${WORK_DIR}/prefix")
|
|
3
3
|
execute_process(COMMAND "${CMAKE_COMMAND}" --install "${BUILD_DIR}" --prefix "${prefix}" --config "${CONFIG}"
|
|
4
4
|
COMMAND_ERROR_IS_FATAL ANY)
|
|
5
|
-
#
|
|
5
|
+
# Shared installs need only the TensorRT link library; static installs also
|
|
6
|
+
# resolve their external link dependencies in the consumer's toolchain.
|
|
6
7
|
file(RENAME "${prefix}" "${WORK_DIR}/relocated")
|
|
7
8
|
set(prefix "${WORK_DIR}/relocated")
|
|
8
9
|
file(COPY "${CONSUMER_SOURCE}/" DESTINATION "${WORK_DIR}/source")
|
|
10
|
+
set(_dependency_options)
|
|
11
|
+
if(NOT SHARED)
|
|
12
|
+
list(APPEND _dependency_options
|
|
13
|
+
"-DCMAKE_TOOLCHAIN_FILE=${BUILD_DIR}/conan/conan_toolchain.cmake"
|
|
14
|
+
"-DCMAKE_BUILD_TYPE=${CONFIG}")
|
|
15
|
+
endif()
|
|
9
16
|
execute_process(COMMAND "${CMAKE_COMMAND}" -E env --unset=LD_LIBRARY_PATH --unset=LD_PRELOAD
|
|
10
17
|
"${CMAKE_COMMAND}" -S "${WORK_DIR}/source" -B "${WORK_DIR}/build"
|
|
11
18
|
"-DCMAKE_PREFIX_PATH=${prefix}" "-DCMAKE_CXX_COMPILER=${CXX}"
|
|
12
19
|
"-DTENSORACLE_TENSORRT_LIBRARY=${TENSORRT_LIBRARY}"
|
|
20
|
+
${_dependency_options}
|
|
13
21
|
COMMAND_ERROR_IS_FATAL ANY)
|
|
14
22
|
execute_process(COMMAND "${CMAKE_COMMAND}" -E env --unset=LD_LIBRARY_PATH --unset=LD_PRELOAD
|
|
15
23
|
"${CMAKE_COMMAND}" --build "${WORK_DIR}/build" --config "${CONFIG}" --parallel 2
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.26)
|
|
2
|
+
project(static_tensoracle_consumer LANGUAGES C CXX)
|
|
3
|
+
find_package(tensoracle 2 CONFIG REQUIRED)
|
|
4
|
+
find_package(tensoracle 2 CONFIG REQUIRED)
|
|
5
|
+
get_target_property(_type tensoracle::tensoracle TYPE)
|
|
6
|
+
if(NOT _type STREQUAL "STATIC_LIBRARY")
|
|
7
|
+
message(FATAL_ERROR "The source build must install a static tensoracle target")
|
|
8
|
+
endif()
|
|
9
|
+
if(NOT COMMAND tensoracle_add_cubin_plugin OR NOT COMMAND tensoracle_find_cuda)
|
|
10
|
+
message(FATAL_ERROR "Static installs must retain the public cubin helpers")
|
|
11
|
+
endif()
|
|
12
|
+
add_library(fixture OBJECT fixture.cpp)
|
|
13
|
+
target_link_libraries(fixture PRIVATE tensoracle::tensoracle TensorRT::nvinfer tensoracle_cuda_driver)
|
|
14
|
+
foreach(_language IN ITEMS c cpp)
|
|
15
|
+
add_executable(consumer_${_language} main.${_language} $<TARGET_OBJECTS:fixture>)
|
|
16
|
+
target_compile_features(consumer_${_language} PRIVATE c_std_11 cxx_std_17)
|
|
17
|
+
target_link_libraries(consumer_${_language} PRIVATE tensoracle::tensoracle)
|
|
18
|
+
target_compile_options(consumer_${_language} PRIVATE
|
|
19
|
+
$<$<C_COMPILER_ID:GNU,Clang>:-Wall;-Wextra;-Werror>)
|
|
20
|
+
endforeach()
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#include "fixture.h"
|
|
2
|
+
#include <NvInfer.h>
|
|
3
|
+
#include <cuda.h>
|
|
4
|
+
#include <cmath>
|
|
5
|
+
#include <cstdio>
|
|
6
|
+
|
|
7
|
+
extern "C" int fixture_start(gpu_fixture* fixture) {
|
|
8
|
+
CUdevice device{};
|
|
9
|
+
CUcontext context{};
|
|
10
|
+
CUdeviceptr input{}, output{};
|
|
11
|
+
CUstream stream{};
|
|
12
|
+
if (cuInit(0) != CUDA_SUCCESS || cuDeviceGet(&device, 0) != CUDA_SUCCESS ||
|
|
13
|
+
cuDevicePrimaryCtxRetain(&context, device) != CUDA_SUCCESS) return 1;
|
|
14
|
+
fixture->context = context;
|
|
15
|
+
if (cuCtxPushCurrent(context) != CUDA_SUCCESS) return 1;
|
|
16
|
+
if (cuMemAlloc(&input, 4 * sizeof(float)) != CUDA_SUCCESS) return 1;
|
|
17
|
+
fixture->input = reinterpret_cast<void*>(input);
|
|
18
|
+
if (cuMemAlloc(&output, 4 * sizeof(float)) != CUDA_SUCCESS) return 1;
|
|
19
|
+
fixture->output = reinterpret_cast<void*>(output);
|
|
20
|
+
if (cuStreamCreate(&stream, CU_STREAM_NON_BLOCKING) != CUDA_SUCCESS) return 1;
|
|
21
|
+
fixture->stream = stream;
|
|
22
|
+
const float values[]{1, 2, 3, 4};
|
|
23
|
+
return cuMemcpyHtoD(input, values, sizeof(values)) != CUDA_SUCCESS;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
extern "C" int fixture_check(gpu_fixture* fixture) {
|
|
27
|
+
const float expected[]{1.5f, 0, 6.25f, 3.25f};
|
|
28
|
+
float actual[4]{};
|
|
29
|
+
if (cuStreamSynchronize(fixture->stream) != CUDA_SUCCESS ||
|
|
30
|
+
cuMemcpyDtoH(actual, reinterpret_cast<CUdeviceptr>(fixture->output), sizeof(actual)) != CUDA_SUCCESS)
|
|
31
|
+
return 1;
|
|
32
|
+
for (int i = 0; i < 4; ++i) {
|
|
33
|
+
if (!std::isfinite(actual[i]) || std::abs(actual[i] - expected[i]) > 1e-5f) return 1;
|
|
34
|
+
}
|
|
35
|
+
std::puts("OUTPUT 1.5 0 6.25 3.25");
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
extern "C" void fixture_destroy(gpu_fixture* fixture) {
|
|
40
|
+
if (fixture->stream) { cuStreamSynchronize(fixture->stream); cuStreamDestroy(fixture->stream); }
|
|
41
|
+
if (fixture->input) cuMemFree(reinterpret_cast<CUdeviceptr>(fixture->input));
|
|
42
|
+
if (fixture->output) cuMemFree(reinterpret_cast<CUdeviceptr>(fixture->output));
|
|
43
|
+
if (fixture->context) { CUcontext previous{}; cuCtxPopCurrent(&previous); cuDevicePrimaryCtxRelease(0); }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
extern "C" tensoracle_status fixture_graph(void* context, void* opaque,
|
|
47
|
+
const tensoracle_weights* weights, const char** message) noexcept {
|
|
48
|
+
++*static_cast<int*>(context);
|
|
49
|
+
tensoracle_weight bias{}; bias.struct_size = sizeof(bias);
|
|
50
|
+
if (tensoracle_weights_find(weights, "bias", &bias, nullptr) != TENSORACLE_SUCCESS ||
|
|
51
|
+
bias.dtype != TENSORACLE_FLOAT32 || bias.element_count != 4) {
|
|
52
|
+
*message = "Expected four float32 bias values"; return TENSORACLE_INVALID_ARGUMENT;
|
|
53
|
+
}
|
|
54
|
+
auto status = fixture_add(opaque, &bias);
|
|
55
|
+
if (status != TENSORACLE_SUCCESS) *message = "Network addition failed";
|
|
56
|
+
return status;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
extern "C" tensoracle_status fixture_add(void* opaque, const tensoracle_weight* bias) noexcept {
|
|
60
|
+
auto& network = *static_cast<nvinfer1::INetworkDefinition*>(opaque);
|
|
61
|
+
nvinfer1::Dims shape{}; shape.nbDims = 1; shape.d[0] = 4;
|
|
62
|
+
auto* input = network.addInput("input", nvinfer1::DataType::kFLOAT, shape);
|
|
63
|
+
auto* constant = network.addConstant(shape, {nvinfer1::DataType::kFLOAT, bias->data, 4});
|
|
64
|
+
if (!input || !constant) return TENSORACLE_INTERNAL_ERROR;
|
|
65
|
+
auto* sum = network.addElementWise(*input, *constant->getOutput(0), nvinfer1::ElementWiseOperation::kSUM);
|
|
66
|
+
if (!sum) return TENSORACLE_INTERNAL_ERROR;
|
|
67
|
+
sum->getOutput(0)->setName("output"); network.markOutput(*sum->getOutput(0));
|
|
68
|
+
return TENSORACLE_SUCCESS;
|
|
69
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#ifndef STATIC_CONSUMER_FIXTURE_H
|
|
2
|
+
#define STATIC_CONSUMER_FIXTURE_H
|
|
3
|
+
#include <tensoracle/builder.h>
|
|
4
|
+
#ifndef TENSORACLE_STATIC_LIBRARY
|
|
5
|
+
#error "The installed static target must supply its public export definition"
|
|
6
|
+
#endif
|
|
7
|
+
#ifdef __cplusplus
|
|
8
|
+
extern "C" {
|
|
9
|
+
#endif
|
|
10
|
+
typedef struct gpu_fixture {
|
|
11
|
+
void* context;
|
|
12
|
+
void* input;
|
|
13
|
+
void* output;
|
|
14
|
+
tensoracle_cuda_stream stream;
|
|
15
|
+
} gpu_fixture;
|
|
16
|
+
int fixture_start(gpu_fixture*);
|
|
17
|
+
int fixture_check(gpu_fixture*);
|
|
18
|
+
void fixture_destroy(gpu_fixture*);
|
|
19
|
+
tensoracle_status fixture_add(void*, const tensoracle_weight*) TENSORACLE_NOEXCEPT;
|
|
20
|
+
tensoracle_status fixture_graph(void*, void*, const tensoracle_weights*, const char**) TENSORACLE_NOEXCEPT;
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
}
|
|
23
|
+
#endif
|
|
24
|
+
#endif
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* SP-TENSORACLE-054, SP-TENSORACLE-073, SP-TENSORACLE-074:
|
|
2
|
+
* C callers build and run an engine with the installed static target. */
|
|
3
|
+
#include "fixture.h"
|
|
4
|
+
#include <stdio.h>
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
|
|
7
|
+
int main(int argc, char** argv) {
|
|
8
|
+
tensoracle_version version = {sizeof(version), 0, 0, 0};
|
|
9
|
+
if (tensoracle_get_version(&version, NULL) != TENSORACLE_SUCCESS ||
|
|
10
|
+
version.major != TENSORACLE_VERSION_MAJOR) return 1;
|
|
11
|
+
if (argc == 1) return 0;
|
|
12
|
+
if (argc != 3) return 2;
|
|
13
|
+
gpu_fixture gpu = {0};
|
|
14
|
+
if (fixture_start(&gpu)) { fixture_destroy(&gpu); return 3; }
|
|
15
|
+
const int64_t shape[] = {4};
|
|
16
|
+
tensoracle_input_profile profile = {sizeof(profile), "input", 1, shape, shape, shape};
|
|
17
|
+
const tensoracle_input_profile* profiles[] = {&profile};
|
|
18
|
+
tensoracle_tensor_spec input = {0}, output = {0};
|
|
19
|
+
input.struct_size = sizeof(input); input.name = "input";
|
|
20
|
+
input.dtype = TENSORACLE_FLOAT32; input.rank = 1; input.dimensions = shape; input.input = 1;
|
|
21
|
+
output = input; output.name = "output"; output.input = 0;
|
|
22
|
+
const tensoracle_tensor_spec* io[] = {&input, &output};
|
|
23
|
+
const char* files[] = {argv[1]};
|
|
24
|
+
tensoracle_builder_options options = {0};
|
|
25
|
+
options.struct_size = sizeof(options); options.name = "static-c"; options.graph_version = "1";
|
|
26
|
+
options.weight_files = files; options.weight_count = 1;
|
|
27
|
+
options.inputs = profiles; options.input_count = 1; options.io = io; options.io_count = 2;
|
|
28
|
+
options.has_workspace_limit = 1; options.workspace_limit = 64 * 1024 * 1024;
|
|
29
|
+
int calls = 0, result = 4;
|
|
30
|
+
tensoracle_network_builder builder = {sizeof(builder), &calls, fixture_graph};
|
|
31
|
+
tensoracle_engine* engine = NULL;
|
|
32
|
+
tensoracle_execution* execution = NULL;
|
|
33
|
+
tensoracle_error* error = NULL;
|
|
34
|
+
if (tensoracle_open_engine(&options, &builder, &engine, &error) != TENSORACLE_SUCCESS) goto cleanup;
|
|
35
|
+
if (calls != atoi(argv[2])) goto cleanup;
|
|
36
|
+
if (tensoracle_execution_create(engine, &execution, &error) != TENSORACLE_SUCCESS) goto cleanup;
|
|
37
|
+
tensoracle_tensor_address source = {sizeof(source), "input", gpu.input};
|
|
38
|
+
tensoracle_tensor_address target = {sizeof(target), "output", gpu.output};
|
|
39
|
+
const tensoracle_tensor_address* addresses[] = {&source, &target};
|
|
40
|
+
if (tensoracle_execution_enqueue(execution, addresses, 2, gpu.stream, &error) != TENSORACLE_SUCCESS) goto cleanup;
|
|
41
|
+
result = fixture_check(&gpu);
|
|
42
|
+
cleanup:
|
|
43
|
+
if (error) {
|
|
44
|
+
const char* message = NULL;
|
|
45
|
+
if (tensoracle_error_message(error, &message, NULL) == TENSORACLE_SUCCESS)
|
|
46
|
+
fprintf(stderr, "%s\n", message);
|
|
47
|
+
}
|
|
48
|
+
tensoracle_error_destroy(error);
|
|
49
|
+
tensoracle_execution_destroy(execution); tensoracle_engine_destroy(engine);
|
|
50
|
+
fixture_destroy(&gpu);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SP-TENSORACLE-054, SP-TENSORACLE-073, SP-TENSORACLE-074:
|
|
2
|
+
// The same installed static target supports the public C++ wrappers.
|
|
3
|
+
#include "fixture.h"
|
|
4
|
+
#include <tensoracle/builder.hpp>
|
|
5
|
+
#include <cstdio>
|
|
6
|
+
#include <cstdlib>
|
|
7
|
+
|
|
8
|
+
int main(int argc, char** argv) {
|
|
9
|
+
gpu_fixture gpu{};
|
|
10
|
+
try {
|
|
11
|
+
tensoracle::check_version();
|
|
12
|
+
if (argc == 1) return 0;
|
|
13
|
+
if (argc != 3 || fixture_start(&gpu)) { fixture_destroy(&gpu); return 2; }
|
|
14
|
+
int result = 1;
|
|
15
|
+
{
|
|
16
|
+
tensoracle::builder_options options;
|
|
17
|
+
options.name = "static-cpp"; options.graph_version = "1"; options.weights = {argv[1]};
|
|
18
|
+
options.inputs = {{"input", {4}, {4}, {4}}};
|
|
19
|
+
options.io = {{"input", TENSORACLE_FLOAT32, {4}, true}, {"output", TENSORACLE_FLOAT32, {4}, false}};
|
|
20
|
+
options.workspace_limit = 64 * 1024 * 1024; options.optimization_level = 0;
|
|
21
|
+
int calls = 0;
|
|
22
|
+
auto engine = tensoracle::open_engine(options,
|
|
23
|
+
[&](nvinfer1::INetworkDefinition& network, const tensoracle::weights_view& weights) {
|
|
24
|
+
++calls;
|
|
25
|
+
auto bias = weights.at("bias");
|
|
26
|
+
if (fixture_add(&network, &bias) != TENSORACLE_SUCCESS)
|
|
27
|
+
throw std::runtime_error("Network addition failed");
|
|
28
|
+
});
|
|
29
|
+
if (calls != std::atoi(argv[2])) throw std::runtime_error("Unexpected builder callback count");
|
|
30
|
+
auto execution = engine.create_execution();
|
|
31
|
+
execution.enqueue({{"input", gpu.input}, {"output", gpu.output}}, gpu.stream);
|
|
32
|
+
result = fixture_check(&gpu);
|
|
33
|
+
}
|
|
34
|
+
fixture_destroy(&gpu);
|
|
35
|
+
return result;
|
|
36
|
+
} catch (const std::exception& error) {
|
|
37
|
+
std::fprintf(stderr, "%s\n", error.what()); fixture_destroy(&gpu); return 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -6,6 +6,9 @@ The archive contains the shared C ABI library, public C and C++ headers, the CMa
|
|
|
6
6
|
package and plugin helpers, their source files, and MIT and third-party licenses.
|
|
7
7
|
It does not contain TensorRT. The release asset requires no authentication.
|
|
8
8
|
Python applications continue to install tensoracle through PyPI.
|
|
9
|
+
Release SDK archives and Python wheels contain the shared library only. To
|
|
10
|
+
embed tensoracle statically, build it from source; static libraries are not
|
|
11
|
+
distributed.
|
|
9
12
|
The tensoracle Conan package recipe is maintained separately and is not included
|
|
10
13
|
in this repository.
|
|
11
14
|
|
|
@@ -58,6 +61,53 @@ Pass its `user.cuda:root` through `CUDAToolkit_ROOT` in the consumer toolchain,
|
|
|
58
61
|
as shown in the SDK guide. Existing explicit CUDA SDK roots remain supported;
|
|
59
62
|
the link stub is not part of the application runtime.
|
|
60
63
|
|
|
64
|
+
## Embed tensoracle from source
|
|
65
|
+
|
|
66
|
+
Source builds select a shared library by default (`BUILD_SHARED_LIBS=ON`). After
|
|
67
|
+
[preparing the build dependencies](../cpp/README.md), select a static library
|
|
68
|
+
with `BUILD_SHARED_LIBS=OFF`:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
cmake -S cpp -B build/static -G Ninja -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF
|
|
72
|
+
cmake --build build/static --parallel 8
|
|
73
|
+
cmake --install build/static --prefix /path/to/prefix
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The installed package keeps the same public headers and
|
|
77
|
+
`tensoracle::tensoracle` target. The archive contains only tensoracle's objects;
|
|
78
|
+
miniz and the CUDA driver remain separate link dependencies. The CMake package
|
|
79
|
+
finds these dependencies, TensorRT's shared library, and the platform thread
|
|
80
|
+
and dynamic-loader libraries for the final link. The current library uses the
|
|
81
|
+
CUDA Driver API and does not use the CUDA runtime. If a future version uses
|
|
82
|
+
the CUDA runtime, its static parts must also be supplied to the final link.
|
|
83
|
+
TensorRT remains a host-supplied shared runtime.
|
|
84
|
+
|
|
85
|
+
Configure a consumer with the prepared Conan toolchain so it can resolve the
|
|
86
|
+
same miniz and CUDA build inputs. For example, from the tensoracle source root:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cmake -S /path/to/application -B build/application \
|
|
90
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
91
|
+
-DCMAKE_TOOLCHAIN_FILE="$PWD/build/static/conan/conan_toolchain.cmake" \
|
|
92
|
+
-DCMAKE_PREFIX_PATH=/path/to/prefix
|
|
93
|
+
cmake --build build/application --parallel 8
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The consumer uses the same `find_package(tensoracle)` and
|
|
97
|
+
`target_link_libraries(... tensoracle::tensoracle)` calls shown above. The
|
|
98
|
+
static target supplies `TENSORACLE_STATIC_LIBRARY`, which disables DLL import
|
|
99
|
+
and export attributes in the public headers. Source-based cubin plugin helpers
|
|
100
|
+
remain available after `find_package(tensoracle)`. A source-building Conan
|
|
101
|
+
recipe selects this form with `from_source=True` and `shared=False`; the
|
|
102
|
+
prebuilt SDK route supports shared libraries only.
|
|
103
|
+
|
|
104
|
+
A process must contain exactly one tensoracle implementation, used by all its
|
|
105
|
+
code. An artifact that embeds tensoracle must be its only owner in that
|
|
106
|
+
process. Do not load another artifact embedding tensoracle or a tensoracle
|
|
107
|
+
shared library into the same process. Python processes use the wheel's shared
|
|
108
|
+
library. Relink an artifact that embeds tensoracle when updating the embedded
|
|
109
|
+
tensoracle version.
|
|
110
|
+
|
|
61
111
|
## Install the host runtime and relocate a prefix
|
|
62
112
|
|
|
63
113
|
The execution host needs TensorRT 11.2 or later, below 12, compatible with its
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.
|
|
22
|
-
__version_tuple__ = version_tuple = (2,
|
|
21
|
+
__version__ = version = '2.3.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 3, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"""Source builds can embed tensoracle through the installed CMake target."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import re
|
|
5
|
+
import shutil
|
|
6
|
+
import subprocess
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from native_build import ROOT
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def run(*command, **kwargs):
|
|
15
|
+
result = subprocess.run(
|
|
16
|
+
command, capture_output=True, text=True, check=False, timeout=180, **kwargs
|
|
17
|
+
)
|
|
18
|
+
assert result.returncode == 0, result.stdout + result.stderr
|
|
19
|
+
return result.stdout
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@pytest.fixture(scope="module")
|
|
23
|
+
def static_sdk(tmp_path_factory):
|
|
24
|
+
work = tmp_path_factory.mktemp("static-sdk")
|
|
25
|
+
build = work / "library"
|
|
26
|
+
environment = {**os.environ, "TENSORACLE_CONAN_OFFLINE": "ON"}
|
|
27
|
+
environment.pop("LD_LIBRARY_PATH", None)
|
|
28
|
+
environment.pop("LD_PRELOAD", None)
|
|
29
|
+
run(
|
|
30
|
+
"cmake",
|
|
31
|
+
"-S",
|
|
32
|
+
str(ROOT / "cpp"),
|
|
33
|
+
"-B",
|
|
34
|
+
str(build),
|
|
35
|
+
"-G",
|
|
36
|
+
"Ninja",
|
|
37
|
+
"-DBUILD_SHARED_LIBS=OFF",
|
|
38
|
+
"-DBUILD_TESTING=OFF",
|
|
39
|
+
env=environment,
|
|
40
|
+
)
|
|
41
|
+
run("cmake", "--build", str(build), "--parallel", "8", env=environment)
|
|
42
|
+
prefix = work / "prefix"
|
|
43
|
+
run("cmake", "--install", str(build), "--prefix", str(prefix), env=environment)
|
|
44
|
+
relocated = work / "relocated"
|
|
45
|
+
prefix.rename(relocated)
|
|
46
|
+
return work, build, relocated, environment
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.mark.req("SP-TENSORACLE-074")
|
|
50
|
+
def test_static_archive_contains_only_tensoracle_objects(static_sdk):
|
|
51
|
+
"""The installed archive defines tensoracle operations without bundling its dependencies."""
|
|
52
|
+
_, _, prefix, _ = static_sdk
|
|
53
|
+
archives = list(prefix.rglob("libtensoracle.a"))
|
|
54
|
+
assert len(archives) == 1, "BUILD_SHARED_LIBS=OFF must install libtensoracle.a"
|
|
55
|
+
assert not list(prefix.rglob("libtensoracle.so*"))
|
|
56
|
+
symbols = run("nm", "--defined-only", str(archives[0]))
|
|
57
|
+
assert re.search(r"\bT tensoracle_open_engine$", symbols, re.MULTILINE)
|
|
58
|
+
assert not re.search(r"\b(?:mz_|miniz_|tdefl_|tinfl_|cuda|__cuda)\w*$", symbols, re.MULTILINE)
|
|
59
|
+
members = run("ar", "t", str(archives[0])).splitlines()
|
|
60
|
+
assert members and all(member.endswith(".cpp.o") for member in members)
|
|
61
|
+
for config in prefix.rglob("*.cmake"):
|
|
62
|
+
text = config.read_text()
|
|
63
|
+
assert str(ROOT) not in text
|
|
64
|
+
assert "/.conan2/" not in text
|
|
65
|
+
assert "tensoracle_json" not in text
|
|
66
|
+
assert "tensoracle_miniz" not in text
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@pytest.mark.req("SP-TENSORACLE-074")
|
|
70
|
+
@pytest.mark.parametrize("language,compiler", [("c", "cc"), ("c++", "c++")])
|
|
71
|
+
def test_static_windows_headers_do_not_import_or_export_dlls(tmp_path, language, compiler):
|
|
72
|
+
"""The static definition makes the public C declarations usable without DLL attributes."""
|
|
73
|
+
source = tmp_path / "declarations.h"
|
|
74
|
+
source.write_text("#include <tensoracle/builder.h>\n")
|
|
75
|
+
run(
|
|
76
|
+
compiler,
|
|
77
|
+
"-x",
|
|
78
|
+
language,
|
|
79
|
+
"-fsyntax-only",
|
|
80
|
+
"-Werror",
|
|
81
|
+
"-D_WIN32",
|
|
82
|
+
"-DTENSORACLE_STATIC_LIBRARY",
|
|
83
|
+
"-I",
|
|
84
|
+
str(ROOT / "cpp/include"),
|
|
85
|
+
str(source),
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@pytest.fixture(scope="module")
|
|
90
|
+
def static_consumers(static_sdk):
|
|
91
|
+
work, library, prefix, environment = static_sdk
|
|
92
|
+
source = work / "source"
|
|
93
|
+
shutil.copytree(ROOT / "cpp/tests/static_consumer", source)
|
|
94
|
+
build = work / "consumers"
|
|
95
|
+
run(
|
|
96
|
+
"cmake",
|
|
97
|
+
"-S",
|
|
98
|
+
str(source),
|
|
99
|
+
"-B",
|
|
100
|
+
str(build),
|
|
101
|
+
"-G",
|
|
102
|
+
"Ninja",
|
|
103
|
+
"-DCMAKE_BUILD_TYPE=Release",
|
|
104
|
+
f"-DCMAKE_PREFIX_PATH={prefix}",
|
|
105
|
+
f"-DCMAKE_TOOLCHAIN_FILE={library / 'conan/conan_toolchain.cmake'}",
|
|
106
|
+
env=environment,
|
|
107
|
+
)
|
|
108
|
+
run("cmake", "--build", str(build), "--parallel", "8", env=environment)
|
|
109
|
+
# The consumer keeps the installed SDK and resolved dependencies only.
|
|
110
|
+
shutil.rmtree(source)
|
|
111
|
+
return work, build, environment
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@pytest.mark.req("SP-TENSORACLE-073")
|
|
115
|
+
@pytest.mark.req("SP-TENSORACLE-074")
|
|
116
|
+
def test_c_and_cpp_consumers_embed_the_installed_static_library(static_consumers):
|
|
117
|
+
"""Both languages link the same installed target without a tensoracle shared dependency."""
|
|
118
|
+
_, build, environment = static_consumers
|
|
119
|
+
for name in ("consumer_c", "consumer_cpp"):
|
|
120
|
+
executable = build / name
|
|
121
|
+
assert "libtensoracle.so" not in run("readelf", "-d", str(executable))
|
|
122
|
+
run(str(executable), env=environment)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@pytest.mark.gpu
|
|
126
|
+
@pytest.mark.req("SP-TENSORACLE-054")
|
|
127
|
+
@pytest.mark.req("SP-TENSORACLE-073")
|
|
128
|
+
@pytest.mark.req("SP-TENSORACLE-074")
|
|
129
|
+
def test_static_c_and_cpp_consumers_build_execute_and_reuse_engines(static_consumers):
|
|
130
|
+
"""Each embedded consumer builds on the host TensorRT, executes, then reuses its engine."""
|
|
131
|
+
import numpy as np
|
|
132
|
+
from safetensors.numpy import save_file
|
|
133
|
+
|
|
134
|
+
work, build, environment = static_consumers
|
|
135
|
+
weights = work / "bias.safetensors"
|
|
136
|
+
save_file({"bias": np.array([0.5, -2, 3.25, -0.75], dtype=np.float32)}, weights)
|
|
137
|
+
import tensorrt_libs
|
|
138
|
+
|
|
139
|
+
runtime = Path(tensorrt_libs.__file__).parent
|
|
140
|
+
environment = {
|
|
141
|
+
**environment,
|
|
142
|
+
"LD_LIBRARY_PATH": str(runtime),
|
|
143
|
+
"XDG_CACHE_HOME": str(work / "cache"),
|
|
144
|
+
}
|
|
145
|
+
for name in ("consumer_c", "consumer_cpp"):
|
|
146
|
+
for builds in (1, 0):
|
|
147
|
+
run(str(build / name), str(weights), str(builds), env=environment)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|