Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ license = "Apache-2.0"
authors = ["Tarek Ziade", "Markus Tavenrath", "Stephan Seitz"]
repository = "https://github.com/rustnn/trtx-rs"

[workspace.dependencies]
trtx-sys = { path = "trtx-sys" }
trtexec-rs = { path = "trtx" }

[profile.release]
opt-level = 3
lto = true
Expand Down
9 changes: 1 addition & 8 deletions trtx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ categories = ["api-bindings", "science"]
trtx-sys = { version = "0.8.1", path = "../trtx-sys", default-features = false }
thiserror = "2.0"
cxx = "1.0"
libc = "0.2"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never used. cargo warns about it

libloading = { version = "0.9", optional = true }
autocxx = { version = "0.30" }

# cudarc for safe CUDA operations (required when real mode is enabled)
# Using cuda-12050 as fallback; CUDA 13.x should be compatible
cudarc = { version = "0.11", features = ["driver", "cuda-12050"] }
log = "0.4.29"

[features]
Expand Down Expand Up @@ -48,6 +44,7 @@ v_1_6 = ["trtx-sys/v_1_6", "v_1_5"]
enterprise = ["trtx-sys/enterprise"]

[dev-dependencies]
cudarc = { version = "0.19.9", features = ["cuda-13020"] }
# For examples and tests
pretty_env_logger = "0.5"

Expand All @@ -58,7 +55,3 @@ required-features = []
[[example]]
name = "basic_workflow"
required-features = ["onnxparser"]

[[example]]
name = "rustnn_executor"
required-features = ["onnxparser"]
100 changes: 0 additions & 100 deletions trtx/examples/rustnn_executor.rs

This file was deleted.

38 changes: 13 additions & 25 deletions trtx/examples/tiny_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
//! Network architecture:
//! Input [1, 3, 4, 4] -> ReLU -> Output [1, 3, 4, 4]

use cudarc::driver::{CudaContext, CudaSlice, DevicePtr, DevicePtrMut};
use trtx::builder::MemoryPoolType;
use trtx::cuda::{synchronize, DeviceBuffer};
use trtx::error::Result;
use trtx::{ActivationType, Builder, DataType, Logger, Runtime};

fn main() -> Result<()> {
fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
pretty_env_logger::init();
println!("=== Tiny Network Example ===\n");

Expand Down Expand Up @@ -67,45 +67,33 @@ fn main() -> Result<()> {
println!(" Input shape: [1, 3, 4, 4] ({} elements)", input_size);
println!(" First 8 input values: {:?}", &input_data[..8]);

let ctx = CudaContext::new(0)?;
let stream = ctx.new_stream()?;

// Allocate device memory
let mut input_device = DeviceBuffer::new(input_size * std::mem::size_of::<f32>())?;
let output_device = DeviceBuffer::new(output_size * std::mem::size_of::<f32>())?;

// Copy input to device (convert f32 slice to bytes)
let input_bytes = unsafe {
std::slice::from_raw_parts(
input_data.as_ptr() as *const u8,
input_data.len() * std::mem::size_of::<f32>(),
)
};
input_device.copy_from_host(input_bytes)?;
let input_device = stream.clone_htod(&input_data)?;
let mut output_device: CudaSlice<f32> = stream.alloc_zeros(output_size)?;

// 7. Set tensor addresses
println!("\n7. Binding tensors...");
unsafe {
context.set_tensor_address("input", input_device.as_ptr())?;
context.set_tensor_address("output", output_device.as_ptr())?;
context
.set_input_tensor_address("input", input_device.device_ptr(&stream).0 as *const _)?;
context.set_tensor_address("output", output_device.device_ptr_mut(&stream).0 as *mut _)?;
}

// 8. Execute inference
println!("8. Running inference...");
let stream = trtx::cuda::default_stream();
unsafe {
context.enqueue_v3(stream)?;
context.enqueue_v3(stream.cu_stream() as *mut _)?;
}
synchronize()?;
stream.synchronize()?;
println!(" ✓ Inference completed");

// 9. Copy output back to host
println!("\n9. Reading results...");
let mut output_data: Vec<f32> = vec![0.0; output_size];
let output_bytes = unsafe {
std::slice::from_raw_parts_mut(
output_data.as_mut_ptr() as *mut u8,
output_data.len() * std::mem::size_of::<f32>(),
)
};
output_device.copy_to_host(output_bytes)?;
stream.memcpy_dtoh(&output_device, &mut output_data)?;

println!(" Output shape: [1, 3, 4, 4] ({} elements)", output_size);
println!(" First 8 output values: {:?}", &output_data[..8]);
Expand Down
111 changes: 0 additions & 111 deletions trtx/src/cuda.rs

This file was deleted.

Loading
Loading