Yes, I mean for the fixed shape it is totally correct, but not for dynamic width.
Frankly, I have used Polygraphy to debug the precision.
polygraphy run dytest.onnx --trt --onnxrt \
--onnx-outputs mark all \
--trt-outputs mark all \
--verbose \
--trt-min-shapes input:[1,2,32,32] --trt-opt-shapes input:[1,2,64,64] --trt-max-shapes input:[1,2,64,64] \
--load-inputs custom_inputs.json \
--atol 1e-05 --rtol 1e-05 &>log.log
and it tells me something wrong with the Transpose layer, which is I cannot understand.
[I] Comparing Output: 'onnx::Transpose_239' (dtype=float32, shape=(1, 64, 32, 2)) with 'onnx::Transpose_239' (dtype=float32, shape=(1, 64, 32, 2))
[I] Tolerance: [abs=1e-05, rel=1e-05] | Checking elemwise error
[I] trt-runner-N0-11/15/22-18:03:01: onnx::Transpose_239 | Stats: mean=0.011494, std-dev=0.028912, var=0.00083588, median=0.011251, min=-0.19488 at (0, 11, 0, 0), max=0.20742 at (0, 4, 3, 0), avg-magnitude=0.020177
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(-0.195 , -0.155 ) | 3 |
(-0.155 , -0.114 ) | 10 |
(-0.114 , -0.0742) | 53 |
(-0.0742, -0.034 ) | 151 | #
(-0.034 , 0.00627) | 290 | ###
(0.00627, 0.0465 ) | 3301 | ########################################
(0.0465 , 0.0867 ) | 193 | ##
(0.0867 , 0.127 ) | 65 |
(0.127 , 0.167 ) | 28 |
(0.167 , 0.207 ) | 2 |
[I] onnxrt-runner-N0-11/15/22-18:03:01: onnx::Transpose_239 | Stats: mean=0.011458, std-dev=0.04055, var=0.0016443, median=0.011217, min=-0.19488 at (0, 22, 0, 0), max=0.20742 at (0, 8, 3, 0), avg-magnitude=0.0292
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(-0.195 , -0.155 ) | 5 |
(-0.155 , -0.114 ) | 22 |
(-0.114 , -0.0742) | 109 | #
(-0.0742, -0.034 ) | 315 | ####
(-0.034 , 0.00627) | 550 | ########
(0.00627, 0.0465 ) | 2525 | ########################################
(0.0465 , 0.0867 ) | 381 | ######
(0.0867 , 0.127 ) | 142 | ##
(0.127 , 0.167 ) | 45 |
(0.167 , 0.207 ) | 2 |
[I] Error Metrics: onnx::Transpose_239
[I] Minimum Required Tolerance: elemwise error | [abs=0.35695] OR [rel=906.73] (requirements may be lower if both abs/rel tolerances are set)
[I] Absolute Difference | Stats: mean=0.028014, std-dev=0.039618, var=0.0015695, median=0.0053119, min=0 at (0, 0, 0, 0), max=0.35695 at (0, 22, 0, 0), avg-magnitude=0.028014
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(0 , 0.0357) | 2903 | ########################################
(0.0357, 0.0714) | 610 | ########
(0.0714, 0.107 ) | 359 | ####
(0.107 , 0.143 ) | 142 | #
(0.143 , 0.178 ) | 61 |
(0.178 , 0.214 ) | 15 |
(0.214 , 0.25 ) | 2 |
(0.25 , 0.286 ) | 3 |
(0.286 , 0.321 ) | 0 |
(0.321 , 0.357 ) | 1 | [!] FAILED | Command: /docker/miniconda3/envs/faceshifter/bin/polygraphy run dytest.onnx --trt --onnxrt --onnx-outputs mark all --trt-outputs mark all --verbose --trt-min-shapes input:[1,2,32,32] --trt-opt-shapes input:[1,2,64,64] --trt-max-shapes input:[1,2,64,64] --load-inputs custom_inputs.json --atol 1e-05 --rtol 1e-05
[I] Relative Difference | Stats: mean=1.8051, std-dev=16.308, var=265.95, median=0.42768, min=0 at (0, 0, 0, 0), max=906.73 at (0, 21, 9, 0), avg-magnitude=1.8051
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(0 , 90.7) | 4088 | ########################################
(90.7, 181 ) | 5 |
(181 , 272 ) | 2 |
(272 , 363 ) | 0 |
(363 , 453 ) | 0 |
(453 , 544 ) | 0 |
(544 , 635 ) | 0 |
(635 , 725 ) | 0 |
(725 , 816 ) | 0 |
(816 , 907 ) | 1 |
[E] FAILED | Difference exceeds tolerance (rel=1e-05, abs=1e-05)
[I] Comparing Output: 'output' (dtype=float32, shape=(1, 2, 64, 32)) with 'output' (dtype=float32, shape=(1, 2, 64, 32))
[I] Tolerance: [abs=1e-05, rel=1e-05] | Checking elemwise error
[I] trt-runner-N0-11/15/22-18:03:01: output | Stats: mean=0.011494, std-dev=0.028912, var=0.00083588, median=0.011251, min=-0.19488 at (0, 0, 11, 0), max=0.20742 at (0, 0, 4, 3), avg-magnitude=0.020177
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(-0.195 , -0.155 ) | 3 |
(-0.155 , -0.114 ) | 10 |
(-0.114 , -0.0742) | 53 |
(-0.0742, -0.034 ) | 151 | #
(-0.034 , 0.00627) | 290 | ###
(0.00627, 0.0465 ) | 3301 | ########################################
(0.0465 , 0.0867 ) | 193 | ##
(0.0867 , 0.127 ) | 65 |
(0.127 , 0.167 ) | 28 |
(0.167 , 0.207 ) | 2 |
[I] onnxrt-runner-N0-11/15/22-18:03:01: output | Stats: mean=0.011458, std-dev=0.04055, var=0.0016443, median=0.011217, min=-0.19488 at (0, 0, 22, 0), max=0.20742 at (0, 0, 8, 3), avg-magnitude=0.0292
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(-0.195 , -0.155 ) | 5 |
(-0.155 , -0.114 ) | 22 |
(-0.114 , -0.0742) | 109 | #
(-0.0742, -0.034 ) | 315 | ####
(-0.034 , 0.00627) | 550 | ########
(0.00627, 0.0465 ) | 2525 | ########################################
(0.0465 , 0.0867 ) | 381 | ######
(0.0867 , 0.127 ) | 142 | ##
(0.127 , 0.167 ) | 45 |
(0.167 , 0.207 ) | 2 |
[I] Error Metrics: output
[I] Minimum Required Tolerance: elemwise error | [abs=0.35695] OR [rel=906.73] (requirements may be lower if both abs/rel tolerances are set)
[I] Absolute Difference | Stats: mean=0.028014, std-dev=0.039618, var=0.0015695, median=0.0053119, min=0 at (0, 0, 0, 0), max=0.35695 at (0, 0, 22, 0), avg-magnitude=0.028014
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(0 , 0.0357) | 2903 | ########################################
(0.0357, 0.0714) | 610 | ########
(0.0714, 0.107 ) | 359 | ####
(0.107 , 0.143 ) | 142 | #
(0.143 , 0.178 ) | 61 |
(0.178 , 0.214 ) | 15 |
(0.214 , 0.25 ) | 2 |
(0.25 , 0.286 ) | 3 |
(0.286 , 0.321 ) | 0 |
(0.321 , 0.357 ) | 1 |
[I] Relative Difference | Stats: mean=1.8051, std-dev=16.308, var=265.95, median=0.42768, min=0 at (0, 0, 0, 0), max=906.73 at (0, 0, 21, 9), avg-magnitude=1.8051
[I] ---- Histogram ----
Bin Range | Num Elems | Visualization
(0 , 90.7) | 4088 | ########################################
(90.7, 181 ) | 5 |
(181 , 272 ) | 2 |
(272 , 363 ) | 0 |
(363 , 453 ) | 0 |
(453 , 544 ) | 0 |
(544 , 635 ) | 0 |
(635 , 725 ) | 0 |
(725 , 816 ) | 0 |
(816 , 907 ) | 1 |
[E] FAILED | Difference exceeds tolerance (rel=1e-05, abs=1e-05)
[E] FAILED | Mismatched outputs: ['onnx::Transpose_239', 'output']
[V] Loaded Module: sys
here is the log file
[V] Model: dytest.onnx
[V] Loaded Module: polygraphy | Version: 0.42.2 | Path: ['/docker/miniconda3/envs/faceshifter/lib/python3.7/site-packages/polygraphy']
[V] Loaded extension modules: []
[V] Loaded Module: tensorrt | Version: 8.5.1.7 | Path: ['/docker/miniconda3/envs/faceshifter/lib/python3.7/site-packages/tensorrt']
[V] Loaded Module: numpy | Version: 1.21.6 | Path: ['/docker/miniconda3/envs/faceshifter/lib/python3.7/site-packages/numpy']
[I] Loading input data from custom_inputs.json
[I] trt-runner-N0-11/15/22-18:03:01 | Activating and starting inference
[V] [MemUsageChange] Init CUDA: CPU +328, GPU +0, now: CPU 346, GPU 20112 (MiB)
[V] [MemUsageChange] Init builder kernel library: CPU +441, GPU +118, now: CPU 839, GPU 20230 (MiB)
[W] CUDA lazy loading is not enabled. Enabling it can significantly reduce device memory usage. See `CUDA_MODULE_LOADING` in https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars
[V] ----------------------------------------------------------------
[V] Input filename: /workspace/Github/Tensorrt-CV/dynamic_shape/dytest.onnx
[V] ONNX IR version: 0.0.8
[V] Opset version: 16
[V] Producer name: pytorch
[V] Producer version: 1.12.1
[V] Domain:
[V] Model version: 0
[V] Doc string:
[V] ----------------------------------------------------------------
This file has been truncated. show original