diff --git a/rust/tvm-rt/Cargo.toml b/rust/tvm-rt/Cargo.toml index 8e69dcd9397f..24d9061a213f 100644 --- a/rust/tvm-rt/Cargo.toml +++ b/rust/tvm-rt/Cargo.toml @@ -33,7 +33,55 @@ default = ["dynamic-linking"] dynamic-linking = ["tvm-sys/dynamic-linking"] static-linking = ["tvm-sys/static-linking"] standalone = ["tvm-sys/runtime-only"] +runtime-only = ["tvm-sys/runtime-only"] blas = ["ndarray/blas"] +# Enabling any of the following features is like setting the value to "ON" in config.cmake. +use-cuda = ["tvm-sys/use-cuda"] +use-opencl = ["tvm-sys/use-opencl"] +use-vulkan = ["tvm-sys/use-vulkan"] +use-metal = ["tvm-sys/use-metal"] +use-rocm = ["tvm-sys/use-rocm"] +use-hexagon-device = ["tvm-sys/use-hexagon-device"] +use-rpc = ["tvm-sys/use-rpc"] +use-threads = ["tvm-sys/use-threads"] +use-llvm = ["tvm-sys/use-llvm"] +use-stackvm-runtime = ["tvm-sys/use-stackvm-runtime"] +use-graph-runtime = ["tvm-sys/use-graph-runtime"] +use-graph-runtime-debug = ["tvm-sys/use-graph-runtime-debug"] +use-openmp = ["tvm-sys/use-openmp"] +use-relay-debug = ["tvm-sys/use-relay-debug"] +use-rtti = ["tvm-sys/use-rtti"] +use-mscv-mt = ["tvm-sys/use-mscv-mt"] +use-micro = ["tvm-sys/use-micro"] +use-install-dev = ["tvm-sys/use-install-dev"] +hide-private-symbols = ["tvm-sys/hide-private-symbols"] +use-fallback-stl-map = ["tvm-sys/use-fallback-stl-map"] +use-ethosn = ["tvm-sys/use-ethosn"] +use-index-default-i64 = ["tvm-sys/use-index-default-i64"] +use-tf-tvmdsoop = ["tvm-sys/use-tf-tvmdsoop"] +use-byodt-posit = ["tvm-sys/use-byodt-posit"] +use-mkl = ["tvm-sys/use-mkl"] +use-mkldnn = ["tvm-sys/use-mkldnn"] +use-dnnl-codegen = ["tvm-sys/use-dnnl-codegen"] +use-cudnn = ["tvm-sys/use-cudnn"] +use-cublas = ["tvm-sys/use-cublas"] +use-thrust = ["tvm-sys/use-thrust"] +use-miopen = ["tvm-sys/use-miopen"] +use-rocblas = ["tvm-sys/use-rocblas"] +use-sort = ["tvm-sys/use-sort"] +use-nnpack = ["tvm-sys/use-nnpack"] +use-random = ["tvm-sys/use-random"] +use-micro-standalone-runtime = ["tvm-sys/use-micro-standalone-runtime"] +use-cpp-rpc = ["tvm-sys/use-cpp-rpc"] +use-tflite = ["tvm-sys/use-tflite"] +use-coreml = ["tvm-sys/use-coreml"] +use-target-onnx = ["tvm-sys/use-target-onnx"] +use-arm-compute-lib = ["tvm-sys/use-arm-compute-lib"] +use-arm-compute-lib-graph-runtime = ["tvm-sys/use-arm-compute-lib-graph-runtime"] +use-tensorrt-codegen = ["tvm-sys/use-tensorrt-codegen"] +use-tensorrt-runtime = ["tvm-sys/use-tensorrt-runtime"] +use-vitis-ai = ["tvm-sys/use-vitis-ai"] +build-static-runtime = ["tvm-sys/build-static-runtime"] [dependencies] thiserror = "^1.0" diff --git a/rust/tvm-sys/Cargo.toml b/rust/tvm-sys/Cargo.toml index 1daa3086028b..ccc104ba9223 100644 --- a/rust/tvm-sys/Cargo.toml +++ b/rust/tvm-sys/Cargo.toml @@ -28,6 +28,53 @@ default = ["dynamic-linking"] static-linking = [] dynamic-linking = [] runtime-only = [] +# Enabling any of the following features is like setting the value to "ON" in config.cmake. +use-cuda = [] +use-opencl = [] +use-vulkan = [] +use-metal = [] +use-rocm = [] +use-hexagon-device = [] +use-rpc = [] +use-threads = [] +use-llvm = [] +use-stackvm-runtime = [] +use-graph-runtime = [] +use-graph-runtime-debug = [] +use-openmp = [] +use-relay-debug = [] +use-rtti = [] +use-mscv-mt = [] +use-micro = [] +use-install-dev = [] +hide-private-symbols = [] +use-fallback-stl-map = [] +use-ethosn = [] +use-index-default-i64 = [] +use-tf-tvmdsoop = [] +use-byodt-posit = [] +use-mkl = [] +use-mkldnn = [] +use-dnnl-codegen = [] +use-cudnn = [] +use-cublas = [] +use-thrust = [] +use-miopen = [] +use-rocblas = [] +use-sort = [] +use-nnpack = [] +use-random = [] +use-micro-standalone-runtime = [] +use-cpp-rpc = [] +use-tflite = [] +use-coreml = [] +use-target-onnx = [] +use-arm-compute-lib = [] +use-arm-compute-lib-graph-runtime = [] +use-tensorrt-codegen = [] +use-tensorrt-runtime = [] +use-vitis-ai = [] +build-static-runtime = [] [dependencies] thiserror = "^1.0" @@ -38,4 +85,4 @@ enumn = "^0.1" [build-dependencies] bindgen = { version="0.57", default-features = false, features = ["runtime"] } anyhow = "^1.0" -tvm-build = "0.1" +tvm-build = "0.2.1" diff --git a/rust/tvm-sys/build.rs b/rust/tvm-sys/build.rs index 5990f0d8064f..930ee59b7bf9 100644 --- a/rust/tvm-sys/build.rs +++ b/rust/tvm-sys/build.rs @@ -19,10 +19,10 @@ extern crate bindgen; -use std::path::{Path, PathBuf}; +use std::{path::{Path, PathBuf}, str::FromStr}; use anyhow::{Context, Result}; -use tvm_build::BuildConfig; +use tvm_build::{BuildConfig, CMakeSetting}; /// The necessary information for detecting a TVM installation. struct TVMInstall { @@ -59,6 +59,146 @@ fn find_using_tvm_build() -> Result { let mut build_config = BuildConfig::default(); build_config.repository = Some("https://github.com/apache/tvm".to_string()); build_config.branch = Some(option_env!("TVM_BRANCH").unwrap_or("main").into()); + + if cfg!(feature = "use-cuda") { + build_config.settings.use_cuda = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-opencl") { + build_config.settings.use_opencl = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-vulkan") { + build_config.settings.use_vulkan = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-rocm") { + build_config.settings.use_rocm = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-metal") { + build_config.settings.use_metal = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-hexagon-device") { + build_config.settings.use_hexagon_device = Some(true); + } + if cfg!(feature = "use-rpc") { + build_config.settings.use_rpc = Some(true); + } + if cfg!(feature = "use-threads") { + build_config.settings.use_threads = Some(true); + } + if cfg!(feature = "use-llvm") { + build_config.settings.use_llvm = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-stackvm-runtime") { + build_config.settings.use_stackvm_runtime = Some(true); + } + if cfg!(feature = "use-graph-runtime") { + build_config.settings.use_graph_runtime = Some(true); + } + if cfg!(feature = "use-graph-runtime-debug") { + build_config.settings.use_graph_runtime_debug = Some(true); + } + if cfg!(feature = "use-openmp") { + build_config.settings.use_openmp = Some(true); + } + if cfg!(feature = "use-relay-debug") { + build_config.settings.use_relay_debug = Some(true); + } + if cfg!(feature = "use-rtti") { + build_config.settings.use_rtti = Some(true); + } + if cfg!(feature = "use-mscv-mt") { + build_config.settings.use_mscv_mt = Some(true); + } + if cfg!(feature = "use-micro") { + build_config.settings.use_micro = Some(true); + } + if cfg!(feature = "use-install-dev") { + build_config.settings.use_install_dev = Some(true); + } + if cfg!(feature = "hide_private-symbols") { + build_config.settings.hide_private_symbols = Some(true); + } + if cfg!(feature = "use-fallback-stl-map") { + build_config.settings.use_fallback_stl_map = Some(true); + } + if cfg!(feature = "use-ethosn") { + build_config.settings.use_ethosn = Some(true); + } + if cfg!(feature = "use-index_default-i64") { + build_config.settings.use_index_default_i64 = Some(true); + } + if cfg!(feature = "use-tf-tvmdsoop") { + build_config.settings.use_tf_tvmdsoop = Some(true); + } + if cfg!(feature = "use-byodt-posit") { + build_config.settings.use_byodt_posit = Some(true); + } + if cfg!(feature = "use-mkl") { + build_config.settings.use_mkl = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-mkldnn") { + build_config.settings.use_mkldnn = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-dnnl-codegen") { + build_config.settings.use_dnnl_codegen = Some(true); + } + if cfg!(feature = "use-cudnn") { + build_config.settings.use_cudnn = Some(true); + } + if cfg!(feature = "use-cublas") { + build_config.settings.use_cublas = Some(true); + } + if cfg!(feature = "use-thrust") { + build_config.settings.use_thrust = Some(true); + } + if cfg!(feature = "use-miopen") { + build_config.settings.use_miopen = Some(true); + } + if cfg!(feature = "use-rocblas") { + build_config.settings.use_rocblas = Some(true); + } + if cfg!(feature = "use-sort") { + build_config.settings.use_sort = Some(true); + } + if cfg!(feature = "use-nnpack") { + build_config.settings.use_nnpack = Some(true); + } + if cfg!(feature = "use-random") { + build_config.settings.use_random = Some(true); + } + if cfg!(feature = "use-micro-standalone-runtime") { + build_config.settings.use_micro_standalone_runtime = Some(true); + } + if cfg!(feature = "use-cpp-rpc") { + build_config.settings.use_cpp_rpc = Some(true); + } + if cfg!(feature = "use-tflite") { + build_config.settings.use_tflite = Some(true); + } + if cfg!(feature = "use-coreml") { + build_config.settings.use_coreml = Some(true); + } + if cfg!(feature = "use-target-onnx") { + build_config.settings.use_target_onnx = Some(true); + } + if cfg!(feature = "use-arm-compute-lib") { + build_config.settings.use_arm_compute_lib = Some(true); + } + if cfg!(feature = "use-arm-compute-lib-graph-runtime") { + build_config.settings.use_arm_compute_lib_graph_runtime = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-tensorrt-codegen") { + build_config.settings.use_tensorrt_codegen = Some(true); + } + if cfg!(feature = "use-tensorrt-runtime") { + build_config.settings.use_tensorrt_runtime = CMakeSetting::from_str("on").ok(); + } + if cfg!(feature = "use-vitis-ai") { + build_config.settings.use_vitis_ai = Some(true); + } + if cfg!(any(feature = "static-linking", feature = "build-static-runtime")) { + build_config.settings.build_static_runtime = Some(true); + } + let build_result = tvm_build::build(build_config)?; let source_path = build_result.revision.source_path(); let build_path = build_result.revision.build_path(); diff --git a/rust/tvm/Cargo.toml b/rust/tvm/Cargo.toml index ca32226e0ac5..8d9b23f7616b 100644 --- a/rust/tvm/Cargo.toml +++ b/rust/tvm/Cargo.toml @@ -34,6 +34,52 @@ dynamic-linking = ["tvm-rt/dynamic-linking"] static-linking = ["tvm-rt/static-linking"] blas = ["ndarray/blas"] python = ["pyo3"] +# Enabling any of the following features is like setting the value to "ON" in config.cmake. +use-cuda = ["tvm-rt/use-cuda"] +use-opencl = ["tvm-rt/use-opencl"] +use-vulkan = ["tvm-rt/use-vulkan"] +use-metal = ["tvm-rt/use-metal"] +use-rocm = ["tvm-rt/use-rocm"] +use-hexagon-device = ["tvm-rt/use-hexagon-device"] +use-rpc = ["tvm-rt/use-rpc"] +use-threads = ["tvm-rt/use-threads"] +use-llvm = ["tvm-rt/use-llvm"] +use-stackvm-runtime = ["tvm-rt/use-stackvm-runtime"] +use-graph-runtime = ["tvm-rt/use-graph-runtime"] +use-graph-runtime-debug = ["tvm-rt/use-graph-runtime-debug"] +use-openmp = ["tvm-rt/use-openmp"] +use-relay-debug = ["tvm-rt/use-relay-debug"] +use-rtti = ["tvm-rt/use-rtti"] +use-mscv-mt = ["tvm-rt/use-mscv-mt"] +use-micro = ["tvm-rt/use-micro"] +use-install-dev = ["tvm-rt/use-install-dev"] +hide-private-symbols = ["tvm-rt/hide-private-symbols"] +use-fallback-stl-map = ["tvm-rt/use-fallback-stl-map"] +use-ethosn = ["tvm-rt/use-ethosn"] +use-index-default-i64 = ["tvm-rt/use-index-default-i64"] +use-tf-tvmdsoop = ["tvm-rt/use-tf-tvmdsoop"] +use-byodt-posit = ["tvm-rt/use-byodt-posit"] +use-mkl = ["tvm-rt/use-mkl"] +use-mkldnn = ["tvm-rt/use-mkldnn"] +use-dnnl-codegen = ["tvm-rt/use-dnnl-codegen"] +use-cudnn = ["tvm-rt/use-cudnn"] +use-cublas = ["tvm-rt/use-cublas"] +use-thrust = ["tvm-rt/use-thrust"] +use-miopen = ["tvm-rt/use-miopen"] +use-rocblas = ["tvm-rt/use-rocblas"] +use-sort = ["tvm-rt/use-sort"] +use-nnpack = ["tvm-rt/use-nnpack"] +use-random = ["tvm-rt/use-random"] +use-micro-standalone-runtime = ["tvm-rt/use-micro-standalone-runtime"] +use-cpp-rpc = ["tvm-rt/use-cpp-rpc"] +use-tflite = ["tvm-rt/use-tflite"] +use-coreml = ["tvm-rt/use-coreml"] +use-target-onnx = ["tvm-rt/use-target-onnx"] +use-arm-compute-lib = ["tvm-rt/use-arm-compute-lib"] +use-arm-compute-lib-graph-runtime = ["tvm-rt/use-arm-compute-lib-graph-runtime"] +use-tensorrt-codegen = ["tvm-rt/use-tensorrt-codegen"] +use-tensorrt-runtime = ["tvm-rt/use-tensorrt-runtime"] +use-vitis-ai = ["tvm-rt/use-vitis-ai"] [dependencies.tvm-rt] version = "0.1.0-alpha"