|
| 1 | +# trtorhc |
| 2 | + |
| 3 | +trtorchc is a compiler CLI application using the TRTorch compiler. It serves as an easy way to compile a |
| 4 | +TorchScript Module with TRTorch from the command-line to quickly check support or as part of |
| 5 | +a deployment pipeline. All basic features of the compiler are supported including post training |
| 6 | +quantization (though you must already have a calibration cache file to use). The compiler can |
| 7 | +output two formats, either a TorchScript program with the TensorRT engine embedded or |
| 8 | +the TensorRT engine itself as a PLAN file. |
| 9 | + |
| 10 | +All that is required to run the program after compilation is for C++ linking against libtrtorch.so |
| 11 | +or in Python importing the trtorch package. All other aspects of using compiled modules are identical |
| 12 | +to standard TorchScript. Load with `torch.jit.load()` and run like you would run any other module. |
| 13 | + |
| 14 | + |
| 15 | +``` |
| 16 | +trtorchc [input_file_path] [output_file_path] |
| 17 | + [input_shapes...] {OPTIONS} |
| 18 | +
|
| 19 | + TRTorch is a compiler for TorchScript, it will compile and optimize |
| 20 | + TorchScript programs to run on NVIDIA GPUs using TensorRT |
| 21 | +
|
| 22 | + OPTIONS: |
| 23 | +
|
| 24 | + -h, --help Display this help menu |
| 25 | + Verbiosity of the compiler |
| 26 | + -v, --verbose Dumps debugging information about the |
| 27 | + compilation process onto the console |
| 28 | + -w, --warnings Disables warnings generated during |
| 29 | + compilation onto the console (warnings |
| 30 | + are on by default) |
| 31 | + --info Dumps info messages generated during |
| 32 | + compilation onto the console |
| 33 | + --build-debuggable-engine Creates a debuggable engine |
| 34 | + --use-strict-types Restrict operating type to only use set |
| 35 | + default operation precision |
| 36 | + (op_precision) |
| 37 | + --allow-gpu-fallback (Only used when targeting DLA |
| 38 | + (device-type)) Lets engine run layers on |
| 39 | + GPU if they are not supported on DLA |
| 40 | + -p[precision], |
| 41 | + --default-op-precision=[precision] |
| 42 | + Default operating precision for the |
| 43 | + engine (Int8 requires a |
| 44 | + calibration-cache argument) [ float | |
| 45 | + float32 | f32 | half | float16 | f16 | |
| 46 | + int8 | i8 ] (default: float) |
| 47 | + -d[type], --device-type=[type] The type of device the engine should be |
| 48 | + built for [ gpu | dla ] (default: gpu) |
| 49 | + --engine-capability=[capability] The type of device the engine should be |
| 50 | + built for [ default | safe_gpu | |
| 51 | + safe_dla ] |
| 52 | + --calibration-cache-file=[file_path] |
| 53 | + Path to calibration cache file to use |
| 54 | + for post training quantization |
| 55 | + --num-min-timing-iter=[num_iters] Number of minimization timing iterations |
| 56 | + used to select kernels |
| 57 | + --num-avg-timing-iters=[num_iters] |
| 58 | + Number of averaging timing iterations |
| 59 | + used to select kernels |
| 60 | + --workspace-size=[workspace_size] Maximum size of workspace given to |
| 61 | + TensorRT |
| 62 | + --max-batch-size=[max_batch_size] Maximum batch size (must be >= 1 to be |
| 63 | + set, 0 means not set) |
| 64 | + -t[threshold], |
| 65 | + --threshold=[threshold] Maximum acceptable numerical deviation |
| 66 | + from standard torchscript output |
| 67 | + (default 2e-5) |
| 68 | + --save-engine Instead of compiling a full a |
| 69 | + TorchScript program, save the created |
| 70 | + engine to the path specified as the |
| 71 | + output path |
| 72 | + input_file_path Path to input TorchScript file |
| 73 | + output_file_path Path for compiled TorchScript (or |
| 74 | + TensorRT engine) file |
| 75 | + input_shapes... Sizes for inputs to engine, can either |
| 76 | + be a single size or a range defined by |
| 77 | + Min, Optimal, Max sizes, e.g. |
| 78 | + "(N,..,C,H,W)" |
| 79 | + "[(MIN_N,..,MIN_C,MIN_H,MIN_W);(OPT_N,..,OPT_C,OPT_H,OPT_W);(MAX_N,..,MAX_C,MAX_H,MAX_W)]" |
| 80 | + "--" can be used to terminate flag options and force all following |
| 81 | + arguments to be treated as positional options |
| 82 | +``` |
| 83 | + |
| 84 | +e.g. |
| 85 | +``` |
| 86 | +trtorchc tests/modules/ssd_traced.jit.pt ssd_trt.ts "[(1,3,300,300); (1,3,512,512); (1, 3, 1024, 1024)]" -p f16 |
| 87 | +``` |
0 commit comments