-
Notifications
You must be signed in to change notification settings - Fork 362
/
Copy pathtrtorchc.html
521 lines (517 loc) · 21.4 KB
/
trtorchc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<meta content="width=device-width,initial-scale=1" name="viewport"/>
<meta content="ie=edge" http-equiv="x-ua-compatible"/>
<meta content="Copy to clipboard" name="lang:clipboard.copy"/>
<meta content="Copied to clipboard" name="lang:clipboard.copied"/>
<meta content="en" name="lang:search.language"/>
<meta content="True" name="lang:search.pipeline.stopwords"/>
<meta content="True" name="lang:search.pipeline.trimmer"/>
<meta content="No matching documents" name="lang:search.result.none"/>
<meta content="1 matching document" name="lang:search.result.one"/>
<meta content="# matching documents" name="lang:search.result.other"/>
<meta content="[\s\-]+" name="lang:search.tokenizer"/>
<link crossorigin="" href="https://fonts.gstatic.com/" rel="preconnect"/>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700|Roboto:300,400,400i,700&display=fallback" rel="stylesheet"/>
<style>
body,
input {
font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif
}
code,
kbd,
pre {
font-family: "Roboto Mono", "Courier New", Courier, monospace
}
</style>
<link href="../_static/stylesheets/application.css" rel="stylesheet"/>
<link href="../_static/stylesheets/application-palette.css" rel="stylesheet"/>
<link href="../_static/stylesheets/application-fixes.css" rel="stylesheet"/>
<link href="../_static/fonts/material-icons.css" rel="stylesheet"/>
<meta content="84bd00" name="theme-color"/>
<script src="../_static/javascripts/modernizr.js">
</script>
<title>
trtorchc — TRTorch 0.0.3 documentation
</title>
<link href="../_static/material.css" rel="stylesheet" type="text/css"/>
<link href="../_static/pygments.css" rel="stylesheet" type="text/css"/>
<link href="../_static/collapsible-lists/css/tree_view.css" rel="stylesheet" type="text/css"/>
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js">
</script>
<script src="../_static/jquery.js">
</script>
<script src="../_static/underscore.js">
</script>
<script src="../_static/doctools.js">
</script>
<script src="../_static/language_data.js">
</script>
<script src="../_static/collapsible-lists/js/CollapsibleLists.compressed.js">
</script>
<script src="../_static/collapsible-lists/js/apply-collapsible-lists.js">
</script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js">
</script>
<link href="../genindex.html" rel="index" title="Index"/>
<link href="../search.html" rel="search" title="Search"/>
<link href="../_notebooks/lenet-getting-started.html" rel="next" title="TRTorch Getting Started - LeNet"/>
<link href="ptq.html" rel="prev" title="Post Training Quantization (PTQ)"/>
</head>
<body data-md-color-accent="light-green" data-md-color-primary="light-green" dir="ltr">
<svg class="md-svg">
<defs data-children-count="0">
<svg height="448" id="__github" viewbox="0 0 416 448" width="416" xmlns="http://www.w3.org/2000/svg">
<path d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z" fill="currentColor">
</path>
</svg>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" id="__drawer" type="checkbox"/>
<input class="md-toggle" data-md-toggle="search" id="__search" type="checkbox"/>
<label class="md-overlay" data-md-component="overlay" for="__drawer">
</label>
<a class="md-skip" href="#tutorials/trtorchc" tabindex="1">
Skip to content
</a>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex navheader">
<div class="md-flex__cell md-flex__cell--shrink">
<a class="md-header-nav__button md-logo" href="../index.html" title="TRTorch 0.0.3 documentation">
<i class="md-icon">
</i>
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="__drawer">
</label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<div class="md-flex__ellipsis md-header-nav__title" data-md-component="title">
<span class="md-header-nav__topic">
TRTorch
</span>
<span class="md-header-nav__topic">
trtorchc
</span>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="__search">
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search">
</label>
<div class="md-search__inner" role="search">
<form action="../search.html" class="md-search__form" method="GET" name="search">
<input autocapitalize="off" autocomplete="off" class="md-search__input" data-md-component="query" data-md-state="active" name="q" placeholder="Search" spellcheck="false" type="text"/>
<label class="md-icon md-search__icon" for="__search">
</label>
<button class="md-icon md-search__icon" data-md-component="reset" tabindex="-1" type="reset">
</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix="">
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list">
</ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a class="md-source" data-md-source="github" href="https://github.com/nvidia/TRTorch/" title="Go to repository">
<div class="md-source__icon">
<svg height="28" viewbox="0 0 24 24" width="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<use height="24" width="24" xlink:href="#__github">
</use>
</svg>
</div>
<div class="md-source__repository">
TRTorch
</div>
</a>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink dropdown">
<button class="dropdownbutton">
Versions
</button>
<div class="dropdown-content md-hero">
<a href="https://nvidia.github.io/TRTorch/" title="master">
master
</a>
<a href="https://nvidia.github.io/TRTorch/v0.0.3/" title="v0.0.3">
v0.0.3
</a>
<a href="https://nvidia.github.io/TRTorch/v0.0.2/" title="v0.0.2">
v0.0.2
</a>
<a href="https://nvidia.github.io/TRTorch/v0.0.1/" title="v0.0.1">
v0.0.1
</a>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container">
<nav class="md-tabs" data-md-component="tabs">
<div class="md-tabs__inner md-grid">
<ul class="md-tabs__list">
<li class="md-tabs__item">
<a class="md-tabs__link" href="../index.html">
TRTorch 0.0.3 documentation
</a>
</li>
</ul>
</div>
</nav>
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="__drawer">
<a class="md-nav__button md-logo" href="../index.html" title="TRTorch 0.0.3 documentation">
<i class="md-icon">
</i>
</a>
<a href="../index.html" title="TRTorch 0.0.3 documentation">
TRTorch
</a>
</label>
<div class="md-nav__source">
<a class="md-source" data-md-source="github" href="https://github.com/nvidia/TRTorch/" title="Go to repository">
<div class="md-source__icon">
<svg height="28" viewbox="0 0 24 24" width="28" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<use height="24" width="24" xlink:href="#__github">
</use>
</svg>
</div>
<div class="md-source__repository">
TRTorch
</div>
</a>
</div>
<ul class="md-nav__list">
<li class="md-nav__item">
<span class="md-nav__link caption">
<span class="caption-text">
Getting Started
</span>
</span>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="installation.html">
Installation
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="getting_started.html">
Getting Started
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="ptq.html">
Post Training Quantization (PTQ)
</a>
</li>
<li class="md-nav__item">
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" id="__toc" type="checkbox"/>
<label class="md-nav__link md-nav__link--active" for="__toc">
trtorchc
</label>
<a class="md-nav__link md-nav__link--active" href="#">
trtorchc
</a>
<nav class="md-nav md-nav--secondary">
<ul class="md-nav__list" data-md-scrollfix="">
<li class="md-nav__item">
<a class="md-nav__extra_link" href="../_sources/tutorials/trtorchc.rst.txt">
Show Source
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<span class="md-nav__link caption">
<span class="caption-text">
Notebooks
</span>
</span>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../_notebooks/lenet-getting-started.html">
TRTorch Getting Started - LeNet
</a>
</li>
<li class="md-nav__item">
<span class="md-nav__link caption">
<span class="caption-text">
Python API Documenation
</span>
</span>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../py_api/trtorch.html">
trtorch
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../py_api/logging.html">
trtorch.logging
</a>
</li>
<li class="md-nav__item">
<span class="md-nav__link caption">
<span class="caption-text">
C++ API Documenation
</span>
</span>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../_cpp_api/trtorch_cpp.html">
TRTorch C++ API
</a>
</li>
<li class="md-nav__item">
<span class="md-nav__link caption">
<span class="caption-text">
Contributor Documentation
</span>
</span>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../contributors/system_overview.html">
System Overview
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../contributors/writing_converters.html">
Writing Converters
</a>
</li>
<li class="md-nav__item">
<a class="md-nav__link" href="../contributors/useful_links.html">
Useful Links for TRTorch Development
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<ul class="md-nav__list" data-md-scrollfix="">
<li class="md-nav__item">
<a class="md-nav__extra_link" href="../_sources/tutorials/trtorchc.rst.txt">
Show Source
</a>
</li>
<li class="md-nav__item" id="searchbox">
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset" role="main">
<span id="id1">
</span>
<h1 id="tutorials-trtorchc--page-root">
trtorchc
<a class="headerlink" href="#tutorials-trtorchc--page-root" title="Permalink to this headline">
¶
</a>
</h1>
<p>
<code class="docutils literal notranslate">
<span class="pre">
trtorchc
</span>
</code>
is a CLI application for using the TRTorch compiler. It serves as an easy way to compile a
TorchScript Module with TRTorch from the command-line to quickly check support or as part of
a deployment pipeline. All basic features of the compiler are supported including post training
quantization (though you must already have a calibration cache file to use the PTQ feature). The compiler can
output two formats, either a TorchScript program with the TensorRT engine embedded or
the TensorRT engine itself as a PLAN file.
</p>
<p>
All that is required to run the program after compilation is for C++ linking against
<code class="docutils literal notranslate">
<span class="pre">
libtrtorch.so
</span>
</code>
or in Python importing the trtorch package. All other aspects of using compiled modules are identical
to standard TorchScript. Load with
<code class="docutils literal notranslate">
<span class="pre">
torch.jit.load()
</span>
</code>
and run like you would run any other module.
</p>
<div class="highlight-txt notranslate">
<div class="highlight">
<pre><span></span>trtorchc [input_file_path] [output_file_path]
[input_shapes...] {OPTIONS}
TRTorch is a compiler for TorchScript, it will compile and optimize
TorchScript programs to run on NVIDIA GPUs using TensorRT
OPTIONS:
-h, --help Display this help menu
Verbiosity of the compiler
-v, --verbose Dumps debugging information about the
compilation process onto the console
-w, --warnings Disables warnings generated during
compilation onto the console (warnings
are on by default)
--info Dumps info messages generated during
compilation onto the console
--build-debuggable-engine Creates a debuggable engine
--use-strict-types Restrict operating type to only use set
default operation precision
(op_precision)
--allow-gpu-fallback (Only used when targeting DLA
(device-type)) Lets engine run layers on
GPU if they are not supported on DLA
-p[precision],
--default-op-precision=[precision]
Default operating precision for the
engine (Int8 requires a
calibration-cache argument) [ float |
float32 | f32 | half | float16 | f16 |
int8 | i8 ] (default: float)
-d[type], --device-type=[type] The type of device the engine should be
built for [ gpu | dla ] (default: gpu)
--engine-capability=[capability] The type of device the engine should be
built for [ default | safe_gpu |
safe_dla ]
--calibration-cache-file=[file_path]
Path to calibration cache file to use
for post training quantization
--num-min-timing-iter=[num_iters] Number of minimization timing iterations
used to select kernels
--num-avg-timing-iters=[num_iters]
Number of averaging timing iterations
used to select kernels
--workspace-size=[workspace_size] Maximum size of workspace given to
TensorRT
--max-batch-size=[max_batch_size] Maximum batch size (must be >= 1 to be
set, 0 means not set)
-t[threshold],
--threshold=[threshold] Maximum acceptable numerical deviation
from standard torchscript output
(default 2e-5)
--save-engine Instead of compiling a full a
TorchScript program, save the created
engine to the path specified as the
output path
input_file_path Path to input TorchScript file
output_file_path Path for compiled TorchScript (or
TensorRT engine) file
input_shapes... Sizes for inputs to engine, can either
be a single size or a range defined by
Min, Optimal, Max sizes, e.g.
"(N,..,C,H,W)"
"[(MIN_N,..,MIN_C,MIN_H,MIN_W);(OPT_N,..,OPT_C,OPT_H,OPT_W);(MAX_N,..,MAX_C,MAX_H,MAX_W)]"
"--" can be used to terminate flag options and force all following
arguments to be treated as positional options
</pre>
</div>
</div>
<p>
e.g.
</p>
<div class="highlight-shell notranslate">
<div class="highlight">
<pre><span></span>trtorchc tests/modules/ssd_traced.jit.pt ssd_trt.ts <span class="s2">"[(1,3,300,300); (1,3,512,512); (1, 3, 1024, 1024)]"</span> -p f16
</pre>
</div>
</div>
</article>
</div>
</div>
</main>
</div>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a class="md-flex md-footer-nav__link md-footer-nav__link--prev" href="ptq.html" rel="prev" title="Post Training Quantization (PTQ)">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button">
</i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Previous
</span>
Post Training Quantization (PTQ)
</span>
</div>
</a>
<a class="md-flex md-footer-nav__link md-footer-nav__link--next" href="../_notebooks/lenet-getting-started.html" rel="next" title="TRTorch Getting Started - LeNet">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Next
</span>
TRTorch Getting Started - LeNet
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-forward md-footer-nav__button">
</i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
© Copyright 2020, NVIDIA Corporation.
</div>
Created using
<a href="http://www.sphinx-doc.org/">
Sphinx
</a>
3.1.2.
and
<a href="https://github.com/bashtage/sphinx-material/">
Material for
Sphinx
</a>
</div>
</div>
</div>
</footer>
<script src="../_static/javascripts/application.js">
</script>
<script>
app.initialize({version: "1.0.4", url: {base: ".."}})
</script>
</body>
</html>