Skip to main content

atomr_accel_tensorrt/
lib.rs

1//! # atomr-accel-tensorrt
2//!
3//! TensorRT engine builder + runtime as supervised atomr actors.
4//! Wraps NVIDIA's libnvinfer (and optionally libnvonnxparser) at
5//! runtime — the library itself is **not** vendored because it is
6//! proprietary; users opt in via the `tensorrt-link` feature and
7//! either install TensorRT system-wide or set `LIBNVINFER_PATH`.
8//!
9//! ## Features
10//!
11//! - `tensorrt-link` — actually link libnvinfer at build time.
12//!   Off-by-default so the crate compiles on hosts without
13//!   TensorRT (used by CI + unit tests).
14//! - `tensorrt-onnx` — pull in `nvonnxparser` for ONNX import.
15//! - `tensorrt-plugin` — `IPluginV3` Rust trampolines.
16//! - `tensorrt-int8` — INT8 calibration helpers (entropy / minmax).
17//! - `tensorrt-fp8` — FP8 PTQ helpers (Hopper-class GPUs).
18//!
19//! ## Public surface
20//!
21//! - [`actor::TrtActor`] / [`actor::TrtMsg`] — sibling actor to
22//!   `atomr_accel_cuda::DeviceActor`. Shares `Arc<CudaStream>` with
23//!   the device actor so inference rides the same execution
24//!   timeline.
25//! - [`builder::IBuilderConfig`] — pure-Rust mirror of the TensorRT
26//!   builder config, with knobs for precision, DLA, structured
27//!   sparsity, tactic sources, timing cache, and engine refit.
28//! - [`engine::TrtEngine`] — owned, immutable engine handle that's
29//!   `Send + Sync` via newtype.
30//! - [`runtime::TrtRuntime`] / [`runtime::ExecutionContext`] — load
31//!   serialised plans + drive `enqueueV3` on a shared CUDA stream.
32//! - [`onnx::OnnxParser`] — gated on `tensorrt-onnx`.
33//! - [`calibration`] — gated on `tensorrt-int8` / `tensorrt-fp8`.
34//! - [`plugin`] — gated on `tensorrt-plugin`.
35
36#![allow(
37    clippy::type_complexity,
38    clippy::too_many_arguments,
39    clippy::arc_with_non_send_sync
40)]
41
42pub mod actor;
43pub mod builder;
44pub mod engine;
45pub mod error;
46pub mod runtime;
47pub mod sys;
48
49#[cfg(feature = "tensorrt-onnx")]
50pub mod onnx;
51
52#[cfg(feature = "tensorrt-int8")]
53pub mod calibration;
54
55#[cfg(feature = "tensorrt-plugin")]
56pub mod plugin;
57
58pub use actor::{
59    BuildFromOnnxReply, BuildReply, CreateContextReply, DeserializeReply, EnqueueReply,
60    ExecuteReply, NetworkSource, RefitReply, RefitWeights, TrtActor, TrtMsg,
61};
62pub use builder::{
63    BuilderFlags, DeviceType, IBuilderConfig, Precision, RefitPolicy, TacticSources,
64};
65pub use engine::{EnginePlan, TrtEngine, TrtRefitter};
66pub use error::TrtError;
67pub use runtime::{EnqueueRequest, ExecutionBindings, ExecutionContext, TensorShape, TrtRuntime};