From 53b7924f63dafdd56121b85bfac9134f69fe38a2 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Thu, 22 Oct 2026 13:13:56 +0800 Subject: [PATCH 1/2] refactor: Share RuntimeConfig with Arc It is now safe to move between threads. --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- trtexec-rs/Cargo.toml | 4 ++-- trtx/Cargo.toml | 2 +- trtx/src/cuda_engine.rs | 4 ++-- trtx/src/execution_context.rs | 6 +++--- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 193b304..22a2c87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Share `RuntimeConfig` with `Arc`, so `ExecutionContext` can move between threads. + ### Removed - Removed all deprecated Rust API methods, including the old getter aliases and diff --git a/Cargo.toml b/Cargo.toml index dc60462..2f0b721 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["trtx-sys", "trtx", "trtexec-rs"] resolver = "2" [workspace.package] -version = "0.9.1+rtx1.7" +version = "0.9.2+rtx1.7" edition = "2021" license = "Apache-2.0" authors = ["Tarek Ziade", "Markus Tavenrath", "Stephan Seitz"] diff --git a/trtexec-rs/Cargo.toml b/trtexec-rs/Cargo.toml index 3b282b2..9540efd 100644 --- a/trtexec-rs/Cargo.toml +++ b/trtexec-rs/Cargo.toml @@ -17,8 +17,8 @@ pretty_env_logger = "0.5" # To upgrade the trtx version to new major version, create a PR with that bump to the RustNN repo # and switch the RustNN dep temporarily to that branch until RustNN main has that version bump -trtx = { version = "0.9.1", path = "../trtx", default-features = true } -trtx-sys = { version = "0.9.1", path = "../trtx-sys", default-features = true } +trtx = { version = "0.9.2", path = "../trtx", default-features = true } +trtx-sys = { version = "0.9.2", path = "../trtx-sys", default-features = true } indicatif = "0.18" anyhow = { version = "1.0", features = ["backtrace"] } clap = { version = "4.6", features = ["derive"] } diff --git a/trtx/Cargo.toml b/trtx/Cargo.toml index de2bf53..60fa118 100644 --- a/trtx/Cargo.toml +++ b/trtx/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["tensorrt", "inference", "deep-learning", "nvidia", "gpu"] categories = ["api-bindings", "science"] [dependencies] -trtx-sys = { version = "0.9.1", path = "../trtx-sys", default-features = false } +trtx-sys = { version = "0.9.2", path = "../trtx-sys", default-features = false } thiserror = "2.0" cxx = "1.0" libloading = { version = "0.9", optional = true } diff --git a/trtx/src/cuda_engine.rs b/trtx/src/cuda_engine.rs index 75bd263..5bc3832 100644 --- a/trtx/src/cuda_engine.rs +++ b/trtx/src/cuda_engine.rs @@ -3,7 +3,7 @@ //! [`CudaEngine`] wraps [`nvinfer1::ICudaEngine`] (C++ [`nvinfer1::ICudaEngine`](https://docs.nvidia.com/deeplearning/tensorrt-rtx/latest/_static/c-api/classnvinfer1_1_1_i_cuda_engine.html)). //! [`SerializationConfig`] wraps [`nvinfer1::ISerializationConfig`] (C++ [`nvinfer1::ISerializationConfig`](https://docs.nvidia.com/deeplearning/tensorrt-rtx/latest/_static/c-api/classnvinfer1_1_1_i_serialization_config.html)). -use std::rc::Rc; +use std::sync::Arc; #[cfg(all(feature = "v_1_6", not(feature = "enterprise")))] use std::{ffi::c_void, pin::Pin}; use std::{ffi::CStr, marker::PhantomData}; @@ -353,7 +353,7 @@ impl<'engine> CudaEngine<'engine> { /// See [nvinfer1::ICudaEngine::createExecutionContext1] pub fn create_execution_context_with_config( &'_ mut self, - runtime_config: Rc>, + runtime_config: Arc>, ) -> Result> { #[cfg(not(feature = "mock_runtime"))] { diff --git a/trtx/src/execution_context.rs b/trtx/src/execution_context.rs index d73e5a0..cc3a586 100644 --- a/trtx/src/execution_context.rs +++ b/trtx/src/execution_context.rs @@ -1,6 +1,6 @@ use std::ffi::{CStr, CString}; use std::pin::Pin; -use std::rc::Rc; +use std::sync::Arc; use cxx::UniquePtr; use trtx_sys::nvinfer1; @@ -20,7 +20,7 @@ use crate::RuntimeConfig; /// pointers before their Rust wrappers run destructors. pub struct ExecutionContext<'engine> { _engine: std::marker::PhantomData<&'engine CudaEngine<'engine>>, - _config: Option>>, + _config: Option>>, debug_listener: Option>>, profiler: Option>>, error_recorder: Option>>, @@ -38,7 +38,7 @@ impl std::fmt::Debug for ExecutionContext<'_> { impl<'engine> ExecutionContext<'engine> { pub(crate) unsafe fn from_ptr( execution_context: *mut nvinfer1::IExecutionContext, - config: Option>>, + config: Option>>, ) -> Result { #[cfg(not(feature = "mock_runtime"))] if execution_context.is_null() { From 8396f7bb67a4e70ef674f534bcad84a79edc3297 Mon Sep 17 00:00:00 2001 From: Shubham Gupta Date: Thu, 22 Oct 2026 22:22:23 +0800 Subject: [PATCH 2/2] Temp pin Signed-off-by: Shubham Gupta --- trtexec-rs/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trtexec-rs/Cargo.toml b/trtexec-rs/Cargo.toml index 9540efd..f67b3f3 100644 --- a/trtexec-rs/Cargo.toml +++ b/trtexec-rs/Cargo.toml @@ -7,7 +7,7 @@ authors.workspace = true repository.workspace = true [dependencies] -rustnn = { git = "https://github.com/theHamsta/rustnn/", branch = "bump-trtx-v0.9.0", features = [ +rustnn = { git = "https://github.com/shubhamg13/rustnn/", branch = "fix/trtx-send", features = [ "trtx-runtime", ], default-features = false, optional = true }