#[cfg(test)]
mod tests {
use trtx::builder::{
Builder, BuilderFlag, DeviceType, EngineCapability, HardwareCompatibilityLevel,
MemoryPoolType, PreviewFeature, ProfilingVerbosity, RuntimePlatform,
TilingOptimizationLevel,
};
use trtx::logger::Logger;
#[cfg(not(feature = "enterprise"))]
use trtx::ComputeCapability;
#[test]
fn test_builder_config_methods() {
#[cfg(feature = "dlopen_tensorrt_rtx")]
trtx::dynamically_load_tensorrt(None::<String>).unwrap();
let logger = Logger::stderr().unwrap();
let mut builder = Builder::new(&logger).unwrap();
let mut config = builder.create_config().unwrap();
config.set_avg_timing_iterations(5);
#[cfg(not(feature = "mock"))]
assert_eq!(config.avg_timing_iterations(), 5);
config.set_engine_capability(EngineCapability::kSTANDARD);
#[cfg(not(feature = "mock"))]
assert_eq!(config.engine_capability(), EngineCapability::kSTANDARD);
config.set_flags(0);
#[cfg(not(feature = "mock"))]
assert_eq!(config.flags(), 0);
config.set_flag(BuilderFlag::kDEBUG);
#[cfg(not(feature = "mock"))]
assert!(config.flag(BuilderFlag::kDEBUG));
config.clear_flag(BuilderFlag::kDEBUG);
#[cfg(not(feature = "mock"))]
assert!(!config.flag(BuilderFlag::kDEBUG));
config.set_dla_core(-1);
#[cfg(not(feature = "mock"))]
assert_eq!(config.dla_core(), -1);
config.set_default_device_type(DeviceType::kGPU);
#[cfg(not(feature = "mock"))]
assert_eq!(config.default_device_type(), DeviceType::kGPU);
assert_eq!(config.nb_optimization_profiles(), 0);
let sources = 1u32 << 3;
config.set_tactic_sources(sources).unwrap();
#[cfg(not(feature = "mock"))]
assert_eq!(config.tactic_sources(), sources);
config.set_memory_pool_limit(MemoryPoolType::kWORKSPACE, 0);
let limit = config.memory_pool_limit(MemoryPoolType::kWORKSPACE);
assert_eq!(limit, 0);
config.set_preview_feature(PreviewFeature::kALIASED_PLUGIN_IO_10_03, true);
#[cfg(not(feature = "mock"))]
assert!(config.preview_feature(PreviewFeature::kALIASED_PLUGIN_IO_10_03));
config.set_builder_optimization_level(5);
#[cfg(not(feature = "mock"))]
assert_eq!(config.builder_optimization_level(), 5);
config.set_hardware_compatibility_level(HardwareCompatibilityLevel::kNONE);
#[cfg(not(feature = "mock"))]
assert_eq!(
config.hardware_compatibility_level(),
HardwareCompatibilityLevel::kNONE
);
config.set_max_aux_streams(2);
#[cfg(not(feature = "mock"))]
assert_eq!(config.max_aux_streams(), 2);
config.set_runtime_platform(RuntimePlatform::kSAME_AS_BUILD);
#[cfg(not(feature = "mock"))]
assert_eq!(config.runtime_platform(), RuntimePlatform::kSAME_AS_BUILD);
config.set_max_nb_tactics(10);
#[cfg(not(feature = "mock"))]
assert_eq!(config.max_nb_tactics(), 10);
config
.set_tiling_optimization_level(TilingOptimizationLevel::kFAST)
.unwrap();
#[cfg(not(feature = "mock"))]
assert_eq!(
config.tiling_optimization_level(),
TilingOptimizationLevel::kFAST
);
config.set_l2_limit_for_tiling(1024).unwrap();
#[cfg(not(feature = "mock"))]
assert_eq!(config.l2_limit_for_tiling(), 1024);
#[cfg(not(feature = "enterprise"))]
{
config.set_nb_compute_capabilities(1).unwrap();
#[cfg(not(feature = "mock"))]
assert_eq!(config.nb_compute_capabilities(), 1);
config
.set_compute_capability(ComputeCapability::kCURRENT, 0)
.unwrap();
#[cfg(not(feature = "mock"))]
assert_eq!(config.compute_capability(0), ComputeCapability::kCURRENT);
}
config.set_profiling_verbosity(ProfilingVerbosity::kDETAILED);
#[cfg(not(feature = "mock"))]
assert_eq!(config.profiling_verbosity(), ProfilingVerbosity::kDETAILED);
config.reset();
println!("All BuilderConfig methods working correctly!");
}
}