@@ -193,6 +193,9 @@ def main(
193193# into the engine it builds, so bind the parameters before partitioning.
194194# - **Real values.** TensorRT actually computes, so we build for CUDA, run on
195195# the GPU, and cross-check against a plain CPU build -- not just the shape.
196+ #
197+ # The build-and-run cells below execute only when TensorRT and CUDA are
198+ # available. In CPU-only documentation builds, they produce no output.
196199
197200trt_mod = relax .transform .BindParams ("main" , {"weight" : weight_np })(ConvReLU )
198201trt_mod = partition_for_tensorrt (trt_mod )
@@ -218,8 +221,6 @@ def main(
218221
219222 np .testing .assert_allclose (trt_out , cpu_out , rtol = 1e-2 , atol = 1e-2 )
220223 print ("TensorRT output shape:" , trt_out .shape , "- matches the CPU reference." )
221- else :
222- print ("TensorRT/CUDA unavailable; skipping the GPU build and run." )
223224
224225######################################################################
225226# A real backend also exposes knobs the stub does not. Setting ``use_fp16``
@@ -244,8 +245,6 @@ def main(
244245
245246 np .testing .assert_allclose (fp16_out , cpu_out , rtol = 5e-2 , atol = 5e-2 )
246247 print ("TensorRT FP16 output shape:" , fp16_out .shape , "- matches within FP16 tolerance." )
247- else :
248- print ("TensorRT/CUDA unavailable; skipping the FP16 build." )
249248
250249######################################################################
251250# Example NPU vs TensorRT at a glance
@@ -322,8 +321,6 @@ def forward(self, x):
322321
323322 np .testing .assert_allclose (deployed , torch_ref , rtol = 1e-2 , atol = 1e-2 )
324323 print ("Deployed PyTorch model on TensorRT; output" , deployed .shape , "matches PyTorch." )
325- else :
326- print ("PyTorch / TensorRT / CUDA unavailable; skipping the deployment example." )
327324
328325######################################################################
329326# Real deployment builds once and reuses the artifact. Export the compiled
@@ -340,8 +337,6 @@ def forward(self, x):
340337 )[0 ].numpy ()
341338 np .testing .assert_allclose (reran , torch_ref , rtol = 1e-2 , atol = 1e-2 )
342339 print ("Reloaded the exported library and reran; output" , reran .shape , "still matches." )
343- else :
344- print ("PyTorch / TensorRT / CUDA unavailable; skipping the export/reload step." )
345340
346341######################################################################
347342# Notes for real deployments
0 commit comments