Skip to content

Commit

Permalink
fix functions mistakenly not executed on runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
gerwin3 committed Aug 8, 2023
1 parent 835557d commit da449c9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
13 changes: 3 additions & 10 deletions crates/async-tensorrt/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ impl Builder {
/// Create a new [`Builder`].
///
/// [TensorRT documentation](https://docs.nvidia.com/deeplearning/tensorrt/api/c_api/namespacenvinfer1_1_1anonymous__namespace_02_nv_infer_8h_03.html)
pub fn new() -> Self {
Builder {
inner: InnerBuilder::new(),
}
pub async fn new() -> Self {
let inner = Future::new(|| InnerBuilder::new()).await;
Builder { inner }
}

/// Create a new optimization profile.
Expand Down Expand Up @@ -124,9 +123,3 @@ impl Builder {
self.inner.platform_has_fast_fp16()
}
}

impl Default for Builder {
fn default() -> Self {
Builder::new()
}
}
2 changes: 1 addition & 1 deletion crates/async-tensorrt/src/ffi/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ mod tests {
#[tokio::test]
async fn test_parser_parses_onnx_file() {
let simple_onnx_file = simple_onnx_file!();
let mut builder = Builder::new();
let mut builder = Builder::new().await;
let network = builder.network_definition(NetworkDefinitionCreationFlags::ExplicitBatchSize);
assert!(
Parser::parse_network_definition_from_file(network, &simple_onnx_file.path()).is_ok()
Expand Down
13 changes: 3 additions & 10 deletions crates/async-tensorrt/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ pub struct Runtime {

impl Runtime {
/// Create a new [`Runtime`].
pub fn new() -> Self {
Self {
inner: InnerRuntime::new(),
}
pub async fn new() -> Self {
let inner = Future::new(|| InnerRuntime::new()).await;
Self { inner }
}

/// Deserialize engine from a plan (a [`HostBuffer`]).
Expand Down Expand Up @@ -53,9 +52,3 @@ impl Runtime {
.await
}
}

impl Default for Runtime {
fn default() -> Self {
Runtime::new()
}
}
7 changes: 5 additions & 2 deletions crates/async-tensorrt/src/tests/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
macro_rules! simple_network {
() => {{
let simple_onnx_file = $crate::tests::onnx::simple_onnx_file!();
let mut builder = $crate::Builder::new().with_optimization_profile().unwrap();
let mut builder = $crate::Builder::new()
.await
.with_optimization_profile()
.unwrap();
let network =
builder.network_definition($crate::NetworkDefinitionCreationFlags::ExplicitBatchSize);
let network =
Expand All @@ -25,7 +28,7 @@ macro_rules! simple_network_plan {
macro_rules! simple_engine {
() => {{
let network_plan = $crate::tests::utils::simple_network_plan!();
let runtime = $crate::Runtime::new();
let runtime = $crate::Runtime::new().await;
runtime
.deserialize_engine_from_plan(&network_plan)
.await
Expand Down

0 comments on commit da449c9

Please sign in to comment.