-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathpyGraphDoc.h
More file actions
3147 lines (2392 loc) · 147 KB
/
Copy pathpyGraphDoc.h
File metadata and controls
3147 lines (2392 loc) · 147 KB
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
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* SPDX-FileCopyrightText: Copyright (c) 1993-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// This file contains all INetworkDefinition related docstrings, since these are typically too long to keep in the
// binding code.
#pragma once
namespace tensorrt
{
namespace LayerTypeDoc
{
constexpr char const* descr = R"trtdoc(Type of Layer)trtdoc";
constexpr char const* CONVOLUTION = R"trtdoc(Convolution layer)trtdoc";
constexpr char const* GRID_SAMPLE = R"trtdoc(Grid sample layer)trtdoc";
constexpr char const* NMS = R"trtdoc(NMS layer)trtdoc";
constexpr char const* ACTIVATION = R"trtdoc(Activation layer)trtdoc";
constexpr char const* POOLING = R"trtdoc(Pooling layer)trtdoc";
constexpr char const* LRN = R"trtdoc(LRN layer)trtdoc";
constexpr char const* SCALE = R"trtdoc(Scale layer)trtdoc";
constexpr char const* SOFTMAX = R"trtdoc(Softmax layer)trtdoc";
constexpr char const* DECONVOLUTION = R"trtdoc(Deconvolution layer)trtdoc";
constexpr char const* CONCATENATION = R"trtdoc(Concatenation layer)trtdoc";
constexpr char const* ELEMENTWISE = R"trtdoc(Elementwise layer)trtdoc";
constexpr char const* PLUGIN = R"trtdoc(Plugin layer)trtdoc";
constexpr char const* UNARY = R"trtdoc(Unary layer)trtdoc";
constexpr char const* PADDING = R"trtdoc(Padding layer)trtdoc";
constexpr char const* SHUFFLE = R"trtdoc(Shuffle layer)trtdoc";
constexpr char const* REDUCE = R"trtdoc(Reduce layer)trtdoc";
constexpr char const* TOPK = R"trtdoc(TopK layer)trtdoc";
constexpr char const* GATHER = R"trtdoc(Gather layer)trtdoc";
constexpr char const* MATRIX_MULTIPLY = R"trtdoc(Matrix multiply layer)trtdoc";
constexpr char const* RAGGED_SOFTMAX = R"trtdoc(Ragged softmax layer)trtdoc";
constexpr char const* CONSTANT = R"trtdoc(Constant layer)trtdoc";
constexpr char const* IDENTITY = R"trtdoc(Identity layer)trtdoc";
constexpr char const* CAST = R"trtdoc(Cast layer)trtdoc";
constexpr char const* PLUGIN_V2 = R"trtdoc(PluginV2 layer)trtdoc";
constexpr char const* SLICE = R"trtdoc(Slice layer)trtdoc";
constexpr char const* SHAPE = R"trtdoc(Shape layer)trtdoc";
constexpr char const* PARAMETRIC_RELU = R"trtdoc(Parametric ReLU layer)trtdoc";
constexpr char const* RESIZE = R"trtdoc(Resize layer)trtdoc";
constexpr char const* TRIP_LIMIT = R"trtdoc(Loop Trip limit layer)trtdoc";
constexpr char const* RECURRENCE = R"trtdoc(Loop Recurrence layer)trtdoc";
constexpr char const* ITERATOR = R"trtdoc(Loop Iterator layer)trtdoc";
constexpr char const* LOOP_OUTPUT = R"trtdoc(Loop output layer)trtdoc";
constexpr char const* SELECT = R"trtdoc(Select layer)trtdoc";
constexpr char const* ASSERTION = R"trtdoc(Assertion layer)trtdoc";
constexpr char const* FILL = R"trtdoc(Fill layer)trtdoc";
constexpr char const* QUANTIZE = R"trtdoc(Quantize layer)trtdoc";
constexpr char const* DEQUANTIZE = R"trtdoc(Dequantize layer)trtdoc";
constexpr char const* SCATTER = R"trtdoc(Scatter layer)trtdoc";
constexpr char const* CONDITION = R"trtdoc(If-conditional Condition layer)trtdoc";
constexpr char const* CONDITIONAL_OUTPUT = R"trtdoc(If-conditional output layer)trtdoc";
constexpr char const* CONDITIONAL_INPUT = R"trtdoc(If-conditional input layer)trtdoc";
constexpr char const* EINSUM = R"trtdoc(Einsum layer)trtdoc";
constexpr char const* ONE_HOT = R"trtdoc(OneHot layer)trtdoc";
constexpr char const* NON_ZERO = R"trtdoc(NonZero layer)trtdoc";
constexpr char const* REVERSE_SEQUENCE = R"trtdoc(ReverseSequence layer)trtdoc";
constexpr char const* NORMALIZATION = R"trtdoc(Normalization layer)trtdoc";
constexpr char const* PLUGIN_V3 = R"trtdoc(PluginV3 layer)trtdoc";
constexpr char const* SQUEEZE = R"trtdoc(Squeeze layer)trtdoc";
constexpr char const* UNSQUEEZE = R"trtdoc(Unsqueeze layer)trtdoc";
constexpr char const* CUMULATIVE = R"trtdoc(Cumulative layer)trtdoc";
constexpr char const* DYNAMIC_QUANTIZE = R"trtdoc(DynamicQuantize layer)trtdoc";
constexpr char const* ATTENTION_INPUT = R"trtdoc(Attention input layer)trtdoc";
constexpr char const* ATTENTION_OUTPUT = R"trtdoc(Attention output layer)trtdoc";
constexpr char const* KV_CACHE_UPDATE = R"trtdoc(KVCacheUpdate layer)trtdoc";
constexpr char const* SPLIT_TO_RAGGED = R"trtdoc(SplitToRagged layer)trtdoc";
constexpr char const* CONCAT_FROM_RAGGED = R"trtdoc(ConcatFromRagged layer)trtdoc";
constexpr char const* ROTARY_EMBEDDING = R"trtdoc(Rotary Embedding layer)trtdoc";
constexpr char const* DIST_COLLECTIVE = R"trtdoc(DistCollective layer)trtdoc";
constexpr char const* MOE = R"trtdoc(MoE layer)trtdoc";
} // namespace LayerTypeDoc
namespace TensorFormatDoc
{
constexpr char const* descr = R"trtdoc(
Format of the input/output tensors.
This enum is used by both plugins and network I/O tensors.
For more information about data formats, see the topic "Data Format Description" located in the
TensorRT Developer Guide (https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html).
)trtdoc";
constexpr char const* LINEAR = R"trtdoc(
Row major linear format.
For a tensor with dimensions {N, C, H, W}, the W axis always has unit stride, and the stride of every other axis is at least the product of the next dimension times the next stride. the strides are the same as for a C array with dimensions [N][C][H][W].
)trtdoc";
constexpr char const* CHW2 = R"trtdoc(
Two wide channel vectorized row major format.
This format is bound to FP16 and BF16. It is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, the memory layout is equivalent to a C array with dimensions [N][(C+1)/2][H][W][2], with the tensor coordinates (n, c, h, w) mapping to array subscript [n][c/2][h][w][c%2].
)trtdoc";
constexpr char const* HWC8 = R"trtdoc(
Eight channel format where C is padded to a multiple of 8.
This format is bound to FP16 and BF16. It is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, the memory layout is equivalent to the array with dimensions [N][H][W][(C+7)/8*8], with the tensor coordinates (n, c, h, w) mapping to array subscript [n][h][w][c].
)trtdoc";
constexpr char const* CHW4 = R"trtdoc(
Four wide channel vectorized row major format.
This format is bound to INT8. It is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, the memory layout is equivalent to a C array with dimensions [N][(C+3)/4][H][W][4], with the tensor coordinates (n, c, h, w) mapping to array subscript [n][c/4][h][w][c%4].
)trtdoc";
constexpr char const* CHW16 = R"trtdoc(
Sixteen wide channel vectorized row major format.
This format is only supported by DLA and requires FP16. It is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, the memory layout is equivalent to a C array with dimensions [N][(C+15)/16][H][W][16], with the tensor coordinates (n, c, h, w) mapping to array subscript [n][c/16][h][w][c%16].
)trtdoc";
constexpr char const* CHW32 = R"trtdoc(
Thirty-two wide channel vectorized row major format.
This format is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, the memory layout is equivalent to a C array with dimensions [N][(C+31)/32][H][W][32], with the tensor coordinates (n, c, h, w) mapping to array subscript [n][c/32][h][w][c%32].
)trtdoc";
constexpr char const* DHWC8 = R"trtdoc(
Eight channel format where C is padded to a multiple of 8.
This format is bound to FP16 and BF16, and it is only available for dimensions >= 4.
For a tensor with dimensions {N, C, D, H, W}, the memory layout is equivalent to an array with dimensions [N][D][H][W][(C+7)/8*8], with the tensor coordinates (n, c, d, h, w) mapping to array subscript [n][d][h][w][c].
)trtdoc";
constexpr char const* CDHW32 = R"trtdoc(
Thirty-two wide channel vectorized row major format with 3 spatial dimensions.
This format is bound to FP16 and INT8. It is only available for dimensions >= 4.
For a tensor with dimensions {N, C, D, H, W}, the memory layout is equivalent to a C array with dimensions [N][(C+31)/32][D][H][W][32], with the tensor coordinates (n, d, c, h, w) mapping to array subscript [n][c/32][d][h][w][c%32].
)trtdoc";
constexpr char const* HWC = R"trtdoc(
Non-vectorized channel-last format.
This format is bound to FP32, FP16, INT8, INT64 and BF16, and is only available for dimensions >= 3.
)trtdoc";
constexpr char const* DLA_LINEAR = R"trtdoc(
DLA planar format. Row major format. The stride for stepping along the H axis is rounded up to 64 bytes.
This format is bound to FP16/Int8 and is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, the memory layout is equivalent to a C array with dimensions [N][C][H][roundUp(W, 64/elementSize)] where elementSize is 2 for FP16 and 1 for Int8, with the tensor coordinates (n, c, h, w) mapping to array subscript [n][c][h][w].
)trtdoc";
constexpr char const* DLA_HWC4 = R"trtdoc(
DLA image format. channel-last format. C can only be 1, 3, 4. If C == 3 it will be rounded to 4. The stride for stepping along the H axis is rounded up to 32 bytes.
This format is bound to FP16/Int8 and is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, with C’ is 1, 4, 4 when C is 1, 3, 4 respectively, the memory layout is equivalent to a C array with dimensions [N][H][roundUp(W, 32/C'/elementSize)][C'] where elementSize is 2 for FP16 and 1 for Int8, C' is the rounded C. The tensor coordinates (n, c, h, w) maps to array subscript [n][h][w][c].
)trtdoc";
constexpr char const* HWC16 = R"trtdoc(
Sixteen channel format where C is padded to a multiple of 16. This format is bound to FP16/INT8/FP8. It is only available for dimensions >= 3.
For a tensor with dimensions {N, C, H, W}, the memory layout is equivalent to the array with dimensions [N][H][W][(C+15)/16*16], with the tensor coordinates (n, c, h, w) mapping to array subscript [n][h][w][c].
)trtdoc";
constexpr char const* DHWC = R"trtdoc(
Non-vectorized channel-last format. This format is bound to FP32. It is only available for dimensions >= 4.
)trtdoc";
} // namespace TensorFormatDoc
namespace ITensorDoc
{
constexpr char const* descr = R"trtdoc(
A tensor in an :class:`INetworkDefinition` .
:ivar name: :class:`str` The tensor name. For a network input, the name is assigned by the application. For tensors which are layer outputs, a default name is assigned consisting of the layer name followed by the index of the output in brackets. Each network input and output tensor must have a unique name.
:ivar shape: :class:`Dims` The shape of a tensor. For a network input the shape is assigned by the application. For a network output it is computed based on the layer parameters and the inputs to the layer. If a tensor size or a parameter is modified in the network, the shape of all dependent tensors will be recomputed. This call is only legal for network input tensors, since the shape of layer output tensors are inferred based on layer inputs and parameters.
:ivar dtype: :class:`DataType` The data type of a tensor. The type is unchanged if the type is invalid for the given tensor.
:ivar broadcast_across_batch: :class:`bool` [DEPRECATED] Deprecated in TensorRT 10.0. Always false since the implicit batch dimensions support has been removed.
:ivar location: :class:`TensorLocation` The storage location of a tensor.
:ivar is_network_input: :class:`bool` Whether the tensor is a network input.
:ivar is_network_output: :class:`bool` Whether the tensor is a network output.
)trtdoc"
R"trtdoc(
:ivar is_shape: :class:`bool` Whether the tensor is a shape tensor.
:ivar allowed_formats: :class:`int32` The allowed set of TensorFormat candidates. This should be an integer consisting of one or more :class:`TensorFormat` s, combined via bitwise OR after bit shifting. For example, ``1 << int(TensorFormat.CHW4) | 1 << int(TensorFormat.CHW32)``.
)trtdoc";
constexpr char const* set_dimension_name = R"trtdoc(
Name a dimension of an input tensor.
Associate a runtime dimension of an input tensor with a symbolic name.
Dimensions with the same non-empty name must be equal at runtime.
Knowing this equality for runtime dimensions may help the TensorRT optimizer.
Both runtime and build-time dimensions can be named.
If the function is called again, with the same index, it will overwrite the previous name.
If None is passed as name, it will clear the name of the dimension.
For example, setDimensionName(0, "n") associates the symbolic name "n" with the leading dimension.
:arg index: index of the dimension.
:arg name: name of the dimension.
)trtdoc";
constexpr char const* get_dimension_name = R"trtdoc(
Get the name of an input dimension.
:arg index: index of the dimension.
:returns: name of the dimension, or null if dimension is unnamed.
)trtdoc";
} // namespace ITensorDoc
namespace ILayerDoc
{
constexpr char const* descr = R"trtdoc(
Base class for all layer classes in an :class:`INetworkDefinition` .
:ivar name: :class:`str` The name of the layer.
:ivar metadata: :class:`str` The per-layer metadata.
:ivar num_ranks: :class:`int` The number of ranks for multi-device execution (default: 1).
:ivar type: :class:`LayerType` The type of the layer.
:ivar num_inputs: :class:`int` The number of inputs of the layer.
:ivar num_outputs: :class:`int` The number of outputs of the layer.
)trtdoc"
R"trtdoc(
)trtdoc";
constexpr char const* set_input = R"trtdoc(
Set the layer input corresponding to the given index.
:arg index: The index of the input tensor.
:arg tensor: The input tensor.
)trtdoc";
constexpr char const* get_input = R"trtdoc(
Get the layer input corresponding to the given index.
:arg index: The index of the input tensor.
:returns: The input tensor, or :class:`None` if the index is out of range.
)trtdoc";
constexpr char const* get_output = R"trtdoc(
Get the layer output corresponding to the given index.
:arg index: The index of the output tensor.
:returns: The output tensor, or :class:`None` if the index is out of range.
)trtdoc";
constexpr char const* num_ranks = R"trtdoc(
:class:`int` The number of ranks for multi-device execution.
Currently, setting num_ranks > 1 via ILayer is only allowed for IDistCollectiveLayer, which uses it to
determine output shape for kALL_GATHER and kREDUCE_SCATTER operations.
For attention layers, use IAttention.num_ranks instead.
Default value is 1.
)trtdoc";
constexpr char const* get_output_type = R"trtdoc(
Get the output type of the layer.
:arg index: The index of the output tensor.
:returns: The output precision. Default : DataType.FLOAT.
)trtdoc";
} // namespace ILayerDoc
namespace PaddingModeDoc
{
constexpr char const* descr = R"trtdoc(
Enumerates types of padding available in convolution, deconvolution and pooling layers.
Padding mode takes precedence if both :attr:`padding_mode` and :attr:`pre_padding` are set.
| EXPLICIT* corresponds to explicit padding.
| SAME* implicitly calculates padding such that the output dimensions are the same as the input dimensions. For convolution and pooling,
output dimensions are determined by ceil(input dimensions, stride).
| CAFFE* corresponds to symmetric padding.
)trtdoc";
constexpr char const* EXPLICIT_ROUND_DOWN = R"trtdoc(Use explicit padding, rounding the output size down)trtdoc";
constexpr char const* EXPLICIT_ROUND_UP = R"trtdoc(Use explicit padding, rounding the output size up)trtdoc";
constexpr char const* SAME_UPPER = R"trtdoc(Use SAME padding, with :attr:`pre_padding` <= :attr:`post_padding` )trtdoc";
constexpr char const* SAME_LOWER = R"trtdoc(Use SAME padding, with :attr:`pre_padding` >= :attr:`post_padding` )trtdoc";
} // namespace PaddingModeDoc
namespace IConvolutionLayerDoc
{
constexpr char const* descr = R"trtdoc(
A convolution layer in an :class:`INetworkDefinition` .
This layer performs a correlation operation between 3 or 4 dimensional filter with a 4 or 5 dimensional tensor to produce another 4 or 5 dimensional tensor.
An optional bias argument is supported, which adds a per-channel constant to each value in the output.
:ivar num_output_maps: :class:`int` The number of output maps for the convolution.
:ivar pre_padding: :class:`DimsHW` The pre-padding. The start of input will be zero-padded by this number of elements in the height and width directions. Default: (0, 0)
:ivar post_padding: :class:`DimsHW` The post-padding. The end of input will be zero-padded by this number of elements in the height and width directions. Default: (0, 0)
:ivar padding_mode: :class:`PaddingMode` The padding mode. Padding mode takes precedence if both :attr:`IConvolutionLayer.padding_mode` and either :attr:`IConvolutionLayer.pre_padding` or :attr:`IConvolutionLayer.post_padding` are set.
:ivar num_groups: :class:`int` The number of groups for a convolution. The input tensor channels are divided into this many groups, and a convolution is executed for each group, using a filter per group. The results of the group convolutions are concatenated to form the output. **Note** When using groups in int8 mode, the size of the groups (i.e. the channel count divided by the group count) must be a multiple of 4 for both input and output. Default: 1.
:ivar kernel: :class:`Weights` The kernel weights for the convolution. The weights are specified as a contiguous array in `GKCRS` order, where `G` is the number of groups, `K` the number of output feature maps, `C` the number of input channels, and `R` and `S` are the height and width of the filter.
:ivar bias: :class:`Weights` The bias weights for the convolution. Bias is optional. To omit bias, set this to an empty :class:`Weights` object. The bias is applied per-channel, so the number of weights (if non-zero) must be equal to the number of output feature maps.
:ivar kernel_size_nd: :class:`Dims` The multi-dimension kernel size of the convolution.
:ivar stride_nd: :class:`Dims` The multi-dimension stride of the convolution. Default: (1, ..., 1)
:ivar padding_nd: :class:`Dims` The multi-dimension padding of the convolution. The input will be zero-padded by this number of elements in each dimension. If the padding is asymmetric, this value corresponds to the pre-padding. Default: (0, ..., 0)
:ivar dilation_nd: :class:`Dims` The multi-dimension dilation for the convolution. Default: (1, ..., 1)
)trtdoc";
} // namespace IConvolutionLayerDoc
namespace ActivationTypeDoc
{
constexpr char const* descr = R"trtdoc(The type of activation to perform.)trtdoc";
constexpr char const* RELU = R"trtdoc(Rectified Linear activation)trtdoc";
constexpr char const* SIGMOID = R"trtdoc(Sigmoid activation)trtdoc";
constexpr char const* TANH = R"trtdoc(Hyperbolic Tangent activation)trtdoc";
constexpr char const* LEAKY_RELU
= R"trtdoc(Leaky Relu activation: f(x) = x if x >= 0, f(x) = alpha * x if x < 0)trtdoc";
constexpr char const* ELU = R"trtdoc(Elu activation: f(x) = x if x >= 0, f(x) = alpha * (exp(x) - 1) if x < 0)trtdoc";
constexpr char const* SELU
= R"trtdoc(Selu activation: f(x) = beta * x if x > 0, f(x) = beta * (alpha * exp(x) - alpha) if x <= 0)trtdoc";
constexpr char const* SOFTSIGN = R"trtdoc(Softsign activation: f(x) = x / (1 + abs(x)))trtdoc";
constexpr char const* SOFTPLUS = R"trtdoc(Softplus activation: f(x) = alpha * log(exp(beta * x) + 1))trtdoc";
constexpr char const* CLIP = R"trtdoc(Clip activation: f(x) = max(alpha, min(beta, x)))trtdoc";
constexpr char const* HARD_SIGMOID = R"trtdoc(Hard sigmoid activation: f(x) = max(0, min(1, alpha * x + beta)))trtdoc";
constexpr char const* SCALED_TANH = R"trtdoc(Scaled Tanh activation: f(x) = alpha * tanh(beta * x))trtdoc";
constexpr char const* THRESHOLDED_RELU
= R"trtdoc(Thresholded Relu activation: f(x) = x if x > alpha, f(x) = 0 if x <= alpha)trtdoc";
constexpr char const* GELU_ERF = R"trtdoc(GELU erf activation: 0.5 * x * (1 + erf(sqrt(0.5) * x)))trtdoc";
constexpr char const* GELU_TANH
= R"trtdoc(GELU tanh activation: 0.5 * x * (1 + tanh(sqrt(2/pi) * (0.044715F * pow(x, 3) + x))))trtdoc";
} // namespace ActivationTypeDoc
namespace IActivationLayerDoc
{
constexpr char const* descr = R"trtdoc(
An Activation layer in an :class:`INetworkDefinition` . This layer applies a per-element activation function to its input. The output has the same shape as the input.
:ivar type: :class:`ActivationType` The type of activation to be performed.
:ivar alpha: :class:`float` The alpha parameter that is used by some parametric activations (LEAKY_RELU, ELU, SELU, SOFTPLUS, CLIP, HARD_SIGMOID, SCALED_TANH). Other activations ignore this parameter.
:ivar beta: :class:`float` The beta parameter that is used by some parametric activations (SELU, SOFTPLUS, CLIP, HARD_SIGMOID, SCALED_TANH). Other activations ignore this parameter.
)trtdoc";
} // namespace IActivationLayerDoc
namespace PoolingTypeDoc
{
constexpr char const* descr = R"trtdoc(The type of pooling to perform in a pooling layer.)trtdoc";
constexpr char const* MAX = R"trtdoc(Maximum over elements)trtdoc";
constexpr char const* AVERAGE
= R"trtdoc(Average over elements. If the tensor is padded, the count includes the padding)trtdoc";
constexpr char const* MAX_AVERAGE_BLEND
= R"trtdoc(Blending between the max pooling and average pooling: `(1-blendFactor)*maxPool + blendFactor*avgPool`)trtdoc";
} // namespace PoolingTypeDoc
namespace IPoolingLayerDoc
{
constexpr char const* descr = R"trtdoc(
A Pooling layer in an :class:`INetworkDefinition` . The layer applies a reduction operation within a window over the input.
:ivar type: :class:`PoolingType` The type of pooling to be performed.
:ivar pre_padding: :class:`DimsHW` The pre-padding. The start of input will be zero-padded by this number of elements in the height and width directions. Default: (0, 0)
:ivar post_padding: :class:`DimsHW` The post-padding. The end of input will be zero-padded by this number of elements in the height and width directions. Default: (0, 0)
:ivar padding_mode: :class:`PaddingMode` The padding mode. Padding mode takes precedence if both :attr:`IPoolingLayer.padding_mode` and either :attr:`IPoolingLayer.pre_padding` or :attr:`IPoolingLayer.post_padding` are set.
:ivar blend_factor: :class:`float` The blending factor for the max_average_blend mode: :math:`max_average_blendPool = (1-blendFactor)*maxPool + blendFactor*avgPool` . ``blend_factor`` is a user value in [0,1] with the default value of 0.0. This value only applies for the :const:`PoolingType.MAX_AVERAGE_BLEND` mode.
:ivar average_count_excludes_padding: :class:`bool` Whether average pooling uses as a denominator the overlap area between the window and the unpadded input. If this is not set, the denominator is the overlap between the pooling window and the padded input. Default: True
:ivar window_size_nd: :class:`Dims` The multi-dimension window size for pooling.
:ivar stride_nd: :class:`Dims` The multi-dimension stride for pooling. Default: (1, ..., 1)
:ivar padding_nd: :class:`Dims` The multi-dimension padding for pooling. Default: (0, ..., 0)
)trtdoc";
} // namespace IPoolingLayerDoc
namespace ILRNLayerDoc
{
constexpr char const* descr = R"trtdoc(
A LRN layer in an :class:`INetworkDefinition` . The output size is the same as the input size.
:ivar window_size: :class:`int` The LRN window size. The window size must be odd and in the range of [1, 15].
:ivar alpha: :class:`float` The LRN alpha value. The valid range is [-1e20, 1e20].
:ivar beta: :class:`float` The LRN beta value. The valid range is [0.01, 1e5f].
:ivar k: :class:`float` The LRN K value. The valid range is [1e-5, 1e10].
)trtdoc";
} // namespace ILRNLayerDoc
namespace ScaleModeDoc
{
constexpr char const* descr = R"trtdoc(Controls how scale is applied in a Scale layer.)trtdoc";
constexpr char const* UNIFORM = R"trtdoc(Identical coefficients across all elements of the tensor.)trtdoc";
constexpr char const* CHANNEL
= R"trtdoc(Per-channel coefficients. The channel dimension is assumed to be the third to last dimension.)trtdoc";
constexpr char const* ELEMENTWISE = R"trtdoc(Elementwise coefficients.)trtdoc";
} // namespace ScaleModeDoc
namespace IScaleLayerDoc
{
constexpr char const* descr = R"trtdoc(
A Scale layer in an :class:`INetworkDefinition` .
This layer applies a per-element computation to its input:
:math:`output = (input * scale + shift) ^ {power}`
The coefficients can be applied on a per-tensor, per-channel, or per-element basis.
**Note**
If the number of weights is 0, then a default value is used for shift, power, and scale. The default shift is 0, the default power is 1, and the default scale is 1.
The output size is the same as the input size.
**Note**
The input tensor for this layer is required to have a minimum of 3 dimensions.
:ivar mode: :class:`ScaleMode` The scale mode.
:ivar shift: :class:`Weights` The shift value.
:ivar scale: :class:`Weights` The scale value.
:ivar power: :class:`Weights` The power value.
:ivar channel_axis: :class:`int` The channel axis.
)trtdoc";
} // namespace IScaleLayerDoc
namespace ISoftMaxLayerDoc
{
// TODO: Figure out how to do preformatted text inside :ivar:s
constexpr char const* descr = R"trtdoc(
A Softmax layer in an :class:`INetworkDefinition` .
This layer applies a per-channel softmax to its input.
The output size is the same as the input size.
:ivar axes: :class:`int` The axis along which softmax is computed. Currently, only one axis can be set.
The axis is specified by setting the bit corresponding to the axis to 1, as a bit mask.
For example, consider an NCHW tensor as input (three non-batch dimensions).
By default, softmax is performed on the axis which is the number of axes minus three. It is 0 if there are fewer than 3 non-batch axes. For example, if the input is NCHW, the default axis is C. If the input is NHW, then the default axis is H.
| Bit 0 corresponds to the N dimension boolean.
| Bit 1 corresponds to the C dimension boolean.
| Bit 2 corresponds to the H dimension boolean.
| Bit 3 corresponds to the W dimension boolean.
| By default, softmax is performed on the axis which is the number of axes minus three. It is 0 if
| there are fewer than 3 axes. For example, if the input is NCHW, the default axis is C. If the input
| is NHW, then the default axis is N.
|
| For example, to perform softmax on axis R of a NPQRCHW input, set bit 3.
The following constraints must be satisfied to execute this layer on DLA:
- Axis must be one of the channel or spatial dimensions.
- There are two classes of supported input sizes:
* Non-axis, non-batch dimensions are all 1 and the axis dimension is at most 8192. This is the recommended case for using softmax since it is the most accurate.
* At least one non-axis, non-batch dimension greater than 1 and the axis dimension is at most 1024. Note that in this case, there may be some approximation error as the axis dimension size approaches the upper bound. See the TensorRT Developer Guide for more details on the approximation error.
)trtdoc";
} // namespace ISoftMaxLayerDoc
namespace IConcatenationLayerDoc
{
constexpr char const* descr = R"trtdoc(
A concatenation layer in an :class:`INetworkDefinition` .
The output channel size is the sum of the channel sizes of the inputs.
The other output sizes are the same as the other input sizes, which must all match.
:ivar axis: :class:`int` The axis along which concatenation occurs. The default axis is the number of tensor dimensions minus three, or zero if the tensor has fewer than three dimensions. For example, for a tensor with dimensions NCHW, it is C.
)trtdoc";
} // namespace IConcatenationLayerDoc
namespace IDeconvolutionLayerDoc
{
constexpr char const* descr = R"trtdoc(
A deconvolution layer in an :class:`INetworkDefinition` .
:ivar num_output_maps: :class:`int` The number of output feature maps for the deconvolution.
:ivar pre_padding: :class:`DimsHW` The pre-padding. The start of input will be zero-padded by this number of elements in the height and width directions. Default: (0, 0)
:ivar post_padding: :class:`DimsHW` The post-padding. The end of input will be zero-padded by this number of elements in the height and width directions. Default: (0, 0)
:ivar padding_mode: :class:`PaddingMode` The padding mode. Padding mode takes precedence if both :attr:`IDeconvolutionLayer.padding_mode` and either :attr:`IDeconvolutionLayer.pre_padding` or :attr:`IDeconvolutionLayer.post_padding` are set.
:ivar num_groups: :class:`int` The number of groups for a deconvolution. The input tensor channels are divided into this many groups, and a deconvolution is executed for each group, using a filter per group. The results of the group convolutions are concatenated to form the output. **Note** When using groups in int8 mode, the size of the groups (i.e. the channel count divided by the group count) must be a multiple of 4 for both input and output. Default: 1
:ivar kernel: :class:`Weights` The kernel weights for the deconvolution. The weights are specified as a contiguous array in `CKRS` order, where `C` the number of input channels, `K` the number of output feature maps, and `R` and `S` are the height and width of the filter.
:ivar bias: :class:`Weights` The bias weights for the deconvolution. Bias is optional. To omit bias, set this to an empty :class:`Weights` object. The bias is applied per-feature-map, so the number of weights (if non-zero) must be equal to the number of output feature maps.
:ivar kernel_size_nd: :class:`Dims` The multi-dimension kernel size of the convolution.
:ivar stride_nd: :class:`Dims` The multi-dimension stride of the deconvolution. Default: (1, ..., 1)
:ivar padding_nd: :class:`Dims` The multi-dimension padding of the deconvolution. The input will be zero-padded by this number of elements in each dimension. Padding is symmetric. Default: (0, ..., 0)
)trtdoc";
} // namespace IDeconvolutionLayerDoc
namespace ElementWiseOperationDoc
{
constexpr char const* descr = R"trtdoc(The binary operations that may be performed by an ElementWise layer.)trtdoc";
constexpr char const* SUM = R"trtdoc(Sum of the two elements)trtdoc";
constexpr char const* PROD = R"trtdoc(Product of the two elements)trtdoc";
constexpr char const* MAX = R"trtdoc(Max of the two elements)trtdoc";
constexpr char const* MIN = R"trtdoc(Min of the two elements)trtdoc";
constexpr char const* SUB = R"trtdoc(Subtract the second element from the first)trtdoc";
constexpr char const* DIV = R"trtdoc(Divide the first element by the second)trtdoc";
constexpr char const* POW = R"trtdoc(The first element to the power of the second element)trtdoc";
constexpr char const* FLOOR_DIV = R"trtdoc(Floor division of the first element by the second)trtdoc";
constexpr char const* AND = R"trtdoc(Logical AND of two elements)trtdoc";
constexpr char const* OR = R"trtdoc(Logical OR of two elements)trtdoc";
constexpr char const* XOR = R"trtdoc(Logical XOR of two elements)trtdoc";
constexpr char const* EQUAL = R"trtdoc(Check if two elements are equal)trtdoc";
constexpr char const* GREATER
= R"trtdoc(Check if element in first tensor is greater than corresponding element in second tensor)trtdoc";
constexpr char const* LESS
= R"trtdoc(Check if element in first tensor is less than corresponding element in second tensor)trtdoc";
} // namespace ElementWiseOperationDoc
namespace IElementWiseLayerDoc
{
constexpr char const* descr = R"trtdoc(
A elementwise layer in an :class:`INetworkDefinition` .
This layer applies a per-element binary operation between corresponding elements of two tensors.
The input dimensions of the two input tensors must be equal, and the output tensor is the same size as each input.
:ivar op: :class:`ElementWiseOperation` The binary operation for the layer.
)trtdoc";
} // namespace IElementWiseLayerDoc
namespace IGatherLayerDoc
{
// TODO: Add better description here.
constexpr char const* descr = R"trtdoc(
A gather layer in an :class:`INetworkDefinition` .
:ivar axis: :class:`int` The non-batch dimension axis to gather on. The axis must be less than the number of non-batch dimensions in the data input.
:ivar num_elementwise_dims: :class:`int` The number of leading dimensions of indices tensor to be handled elementwise. For `GatherMode.DEFAULT`, it can be 0 or 1. For `GatherMode::kND`, it can be between 0 and one less than rank(data). For `GatherMode::kELEMENT`, it must be 0.
:ivar mode: :class:`GatherMode` The gather mode.
)trtdoc";
} // namespace IGatherLayerDoc
namespace ScatterModeDoc
{
constexpr char const* descr = R"trtdoc(The scatter mode to be done by the scatter layer.)trtdoc";
constexpr char const* ELEMENT = R"trtdoc(Scatter Element mode)trtdoc";
constexpr char const* ND = R"trtdoc(Scatter ND mode)trtdoc";
} // namespace ScatterModeDoc
namespace IScatterLayerDoc
{
constexpr char const* descr = R"trtdoc(
A Scatter layer as in :class:`INetworkDefinition`.
:ivar axis: axis to scatter on when using Scatter Element mode (ignored in ND mode)
:ivar mode: :class:`ScatterMode` The operation mode of the scatter.
)trtdoc";
} // namespace IScatterLayerDoc
namespace GatherModeDoc
{
constexpr char const* descr = R"trtdoc(Controls how IGatherLayer gathers data)trtdoc";
constexpr char const* DEFAULT = R"trtdoc(Similar to ONNX Gather. This is the default.)trtdoc";
constexpr char const* ELEMENT = R"trtdoc(Similar to ONNX GatherElements.)trtdoc";
constexpr char const* ND = R"trtdoc(Similar to ONNX GatherND.)trtdoc";
} // namespace GatherModeDoc
namespace IPluginV2LayerDoc
{
constexpr char const* descr = R"trtdoc(
A plugin layer in an :class:`INetworkDefinition` .
:ivar plugin: :class:`IPluginV2` The plugin for the layer.
)trtdoc";
} // namespace IPluginV2LayerDoc
namespace IPluginV3LayerDoc
{
constexpr char const* descr = R"trtdoc(
A plugin layer in an :class:`INetworkDefinition` .
:ivar plugin: :class:`IPluginV3` The plugin for the layer.
)trtdoc";
} // namespace IPluginV3LayerDoc
namespace UnaryOperationDoc
{
constexpr char const* descr = R"trtdoc(The unary operations that may be performed by a Unary layer.)trtdoc";
constexpr char const* EXP = R"trtdoc(Exponentiation)trtdoc";
constexpr char const* LOG = R"trtdoc(Log (base e))trtdoc";
constexpr char const* SQRT = R"trtdoc(Square root)trtdoc";
constexpr char const* RECIP = R"trtdoc(Reciprocal)trtdoc";
constexpr char const* ABS = R"trtdoc(Absolute value)trtdoc";
constexpr char const* NEG = R"trtdoc(Negation)trtdoc";
constexpr char const* SIN = R"trtdoc(Sine)trtdoc";
constexpr char const* COS = R"trtdoc(Cosine)trtdoc";
constexpr char const* TAN = R"trtdoc(Tangent)trtdoc";
constexpr char const* SINH = R"trtdoc(Hyperbolic sine)trtdoc";
constexpr char const* COSH = R"trtdoc(Hyperbolic cosine)trtdoc";
constexpr char const* ASIN = R"trtdoc(Inverse sine)trtdoc";
constexpr char const* ACOS = R"trtdoc(Inverse cosine)trtdoc";
constexpr char const* ATAN = R"trtdoc(Inverse tangent)trtdoc";
constexpr char const* ASINH = R"trtdoc(Inverse hyperbolic sine)trtdoc";
constexpr char const* ACOSH = R"trtdoc(Inverse hyperbolic cosine)trtdoc";
constexpr char const* ATANH = R"trtdoc(Inverse hyperbolic tangent)trtdoc";
constexpr char const* CEIL = R"trtdoc(Ceiling)trtdoc";
constexpr char const* FLOOR = R"trtdoc(Floor)trtdoc";
constexpr char const* ERF = R"trtdoc(Gauss error function)trtdoc";
constexpr char const* NOT = R"trtdoc(Not)trtdoc";
constexpr char const* SIGN
= R"trtdoc(Sign. If input > 0, output 1; if input < 0, output -1; if input == 0, output 0.)trtdoc";
constexpr char const* ROUND = R"trtdoc(Round to nearest even for floating-point data type.)trtdoc";
constexpr char const* ISINF
= R"trtdoc(Return true if the input value equals +/- infinity for floating-point data type.)trtdoc";
constexpr char const* ISNAN = R"trtdoc(Return true if the input value equals NaN for floating-point data type.)trtdoc";
} // namespace UnaryOperationDoc
namespace IUnaryLayerDoc
{
constexpr char const* descr = R"trtdoc(
A unary layer in an :class:`INetworkDefinition` .
:ivar op: :class:`UnaryOperation` The unary operation for the layer. When running this layer on DLA, only ``UnaryOperation.ABS`` is supported.
)trtdoc";
} // namespace IUnaryLayerDoc
namespace ReduceOperationDoc
{
constexpr char const* descr = R"trtdoc(The reduce operations that may be performed by a Reduce layer)trtdoc";
constexpr char const* SUM = R"trtdoc(Sum of the elements)trtdoc";
constexpr char const* PROD = R"trtdoc(Product of the elements)trtdoc";
constexpr char const* MAX = R"trtdoc(Maximum of the elements)trtdoc";
constexpr char const* MIN = R"trtdoc(Minimum of the elements)trtdoc";
constexpr char const* AVG = R"trtdoc(Average of the elements)trtdoc";
constexpr char const* NONE = R"trtdoc(No reduction)trtdoc";
} // namespace ReduceOperationDoc
namespace IReduceLayerDoc
{
constexpr char const* descr = R"trtdoc(
A reduce layer in an :class:`INetworkDefinition` .
:ivar op: :class:`ReduceOperation` The reduce operation for the layer.
:ivar axes: :class:`int` The axes over which to reduce.
:ivar keep_dims: :class:`bool` Specifies whether or not to keep the reduced dimensions for the layer.
)trtdoc";
} // namespace IReduceLayerDoc
namespace IPaddingLayerDoc
{
constexpr char const* descr = R"trtdoc(
A padding layer in an :class:`INetworkDefinition` .
:ivar pre_padding_nd: :class:`Dims` The padding that is applied at the start of the tensor. Negative padding results in trimming the edge by the specified amount. Only 2 dimensions currently supported.
:ivar post_padding_nd: :class:`Dims` The padding that is applied at the end of the tensor. Negative padding results in trimming the edge by the specified amount. Only 2 dimensions currently supported.
)trtdoc";
} // namespace IPaddingLayerDoc
namespace PermutationDoc
{
constexpr char const* descr = R"trtdoc(
The elements of the permutation. The permutation is applied as outputDimensionIndex = permutation[inputDimensionIndex], so to permute from CHW order to HWC order, the required permutation is [1, 2, 0], and to permute from HWC to CHW, the required permutation is [2, 0, 1].
It supports iteration and indexing and is implicitly convertible to/from Python iterables (like :class:`tuple` or :class:`list` ). Therefore, you can use those classes in place of :class:`Permutation` .
)trtdoc";
} // namespace PermutationDoc
namespace IShuffleLayerDoc
{
constexpr char const* descr = R"trtdoc(
A shuffle layer in an :class:`INetworkDefinition` .
This class shuffles data by applying in sequence: a transpose operation, a reshape operation and a second transpose operation. The dimension types of the output are those of the reshape dimension.
:ivar first_transpose: :class:`Permutation` The permutation applied by the first transpose operation. Default: Identity Permutation
:ivar reshape_dims: :class:`Dims` The reshaped dimensions, or ``None`` if they are specified dynamically through a second layer input instead.
Two special values can be used as dimensions.
Value 0 copies the corresponding dimension from input. This special value can be used more than once in the dimensions. If number of reshape dimensions is less than input, 0s are resolved by aligning the most significant dimensions of input.
Value -1 infers that particular dimension by looking at input and rest of the reshape dimensions. Note that only a maximum of one dimension is permitted to be specified as -1.
The product of the new dimensions must be equal to the product of the old.
:ivar second_transpose: :class:`Permutation` The permutation applied by the second transpose operation. Default: Identity Permutation
:ivar zero_is_placeholder: :class:`bool` The meaning of 0 in reshape dimensions.
If true, then a 0 in the reshape dimensions denotes copying the corresponding
dimension from the first input tensor. If false, then a 0 in the reshape
dimensions denotes a zero-length dimension.
)trtdoc";
constexpr char const* set_input = R"trtdoc(
Sets the input tensor for the given index. The index must be 0 for a static shuffle layer.
A static shuffle layer is converted to a dynamic shuffle layer by calling :func:`set_input` with an index 1.
A dynamic shuffle layer cannot be converted back to a static shuffle layer.
For a dynamic shuffle layer, the values 0 and 1 are valid.
The indices in the dynamic case are as follows:
======= ========================================================================
Index Description
======= ========================================================================
0 Data or Shape tensor to be shuffled.
1 The dimensions for the reshape operation, as a 1D :class:`int32` shape tensor.
======= ========================================================================
If this function is called with a value 1, then :attr:`num_inputs` changes
from 1 to 2.
:arg index: The index of the input tensor.
:arg tensor: The input tensor.
)trtdoc";
} // namespace IShuffleLayerDoc
namespace ISliceLayerDoc
{
constexpr char const* descr = R"trtdoc(
A slice layer in an :class:`INetworkDefinition` .
The slice layer has two variants, static and dynamic.
Static slice specifies the start, size, and stride dimensions at layer creation time via :class:`Dims` and can use the get/set accessor functions of the :class:`ISliceLayer` .
Dynamic slice specifies one or more of start, size, stride, or axes as :class:`ITensor`s, by using :func:`ILayer.set_input` to add a second, third, fourth, or sixth input respectively.
The corresponding :class:`Dims` are used if an input is missing or null.
An application can determine if the :class:`ISliceLayer` has a dynamic output shape based on whether the size or axes input is present and non-null.
The slice layer selects for each dimension a start location from within the input tensor, and copies elements to the output tensor using the specified stride across the input tensor.
Start, size, and stride tensors must be 1-D integer-typed shape tensors if not specified via :class:`Dims` .
An example of using slice on a tensor:
input = {{0, 2, 4}, {1, 3, 5}}
start = {1, 0}
size = {1, 2}
stride = {1, 2}
output = {{1, 5}}
If axes is provided then starts, ends, and strides must have the same length as axes and specifies a subset of dimensions to slice. If axes is not provided, starts, ends, and strides
must be of the same length as the rank of the input tensor.
An example of using slice on a tensor with axes specified:
input = {{0, 2, 4}, {1, 3, 5}}
start = {1}
size = {2}
stride = {1}
axes = {1}
output = {{2, 4}, {3, 5}}
When the sampleMode is :const:`SampleMode.CLAMP` or :const:`SampleMode.REFLECT` , for each input dimension, if its size is 0 then the corresponding output dimension must be 0 too.
When the sampleMode is :const:`SampleMode.FILL`, the fifth input to the slice layer is used to determine the value to fill in out-of-bound indices. It is an error to specify the fifth input in any other sample mode.
A slice layer can produce a shape tensor if the following conditions are met:
* ``start``, ``size``, and ``stride`` are build time constants, either as static :class:`Dims` or as constant input tensors.
* ``axes``, if provided, is a build time constant, either as static :class:`Dims` or as a constant input tensor.
* The number of elements in the output tensor does not exceed 2 * :const:`Dims.MAX_DIMS` .
The input tensor is a shape tensor if the output is a shape tensor.
The following constraints must be satisfied to execute this layer on DLA:
* ``start``, ``size``, and ``stride`` are build time constants, either as static :class:`Dims` or as constant input tensors.
* ``axes``, if provided, is a build time constant, either as static :class:`Dims` or as a constant input tensor.
* sampleMode is :const:`SampleMode.DEFAULT` , :const:`SampleMode.WRAP` , or :const:`SampleMode.FILL` .
* Strides are 1 for all dimensions.
* Slicing is not performed on the first dimension.
* The input tensor has four dimensions.
* For :const:`SliceMode.FILL` , the fill value input is a scalar output of an :class:`IConstantLayer` with value 0 that is not consumed by any other layer.
:ivar start: :class:`Dims` The start offset, or ``None`` if it is specified dynamically through a layer input instead.
:ivar shape: :class:`Dims` The output dimensions, or ``None`` if they are specified dynamically through a layer input instead.
:ivar stride: :class:`Dims` The slicing stride, or ``None`` if it is specified dynamically through a layer input instead.
:ivar mode: :class:`SampleMode` Controls how :class:`ISliceLayer` handles out of bounds coordinates.
:ivar axes: :class:`Dims` The axes that starts, sizes, and strides correspond to, or ``None`` if they are specified dynamically through a layer input instead.
)trtdoc";
constexpr char const* set_input = R"trtdoc(
Sets the input tensor for the given index. The index must be 0 or 4 for a static slice layer.
A static slice layer is converted to a dynamic slice layer by calling :func:`set_input` with an index between 1 and 3.
A dynamic slice layer cannot be converted back to a static slice layer.
The indices are as follows:
===== ==================================================================================
Index Description
===== ==================================================================================
0 Data or Shape tensor to be sliced.
1 The start tensor to begin slicing, N-dimensional for Data, and 1-D for Shape.
2 The size tensor of the resulting slice, N-dimensional for Data, and 1-D for Shape.
3 The stride of the slicing operation, N-dimensional for Data, and 1-D for Shape.
4 Value for the :const:`SampleMode.FILL` slice mode. Disallowed for other modes.
5 The axes tensor indicating the axes that starts, sizes, and strides correspond to. Must be a 1-D tensor.
===== ==================================================================================
If this function is called with a value greater than 0, then :attr:`num_inputs` changes
from 1 to index + 1.
:arg index: The index of the input tensor.
:arg tensor: The input tensor.
)trtdoc";
} // namespace ISliceLayerDoc
namespace SampleModeDoc
{
constexpr char const* descr
= R"trtdoc(Controls how ISliceLayer and IGridSample handles out of bounds coordinates)trtdoc";
constexpr char const* STRICT_BOUNDS = R"trtdoc(Fail with error when the coordinates are out of bounds.)trtdoc";
constexpr char const* WRAP = R"trtdoc(Coordinates wrap around periodically.)trtdoc";
constexpr char const* CLAMP = R"trtdoc(Out of bounds indices are clamped to bounds)trtdoc";
constexpr char const* FILL = R"trtdoc(Use fill input value when coordinates are out of bounds.)trtdoc";
constexpr char const* REFLECT = R"trtdoc(Coordinates reflect.)trtdoc";
} // namespace SampleModeDoc
namespace IShapeLayerDoc
{
constexpr char const* descr = R"trtdoc(
A shape layer in an :class:`INetworkDefinition` . Used for getting the shape of a tensor.
This class sets the output to a one-dimensional tensor with the dimensions of the input tensor.
For example, if the input is a four-dimensional tensor (of any type) with
dimensions [2,3,5,7], the output tensor is a one-dimensional :class:`int64` tensor
of length 4 containing the sequence 2, 3, 5, 7.
)trtdoc";
} // namespace IShapeLayerDoc
namespace TopKOperationDoc
{
constexpr char const* descr = R"trtdoc(The operations that may be performed by a TopK layer)trtdoc";
constexpr char const* MAX = R"trtdoc(Maximum of the elements)trtdoc";
constexpr char const* MIN = R"trtdoc(Minimum of the elements)trtdoc";
} // namespace TopKOperationDoc
namespace ITopKLayerDoc
{
constexpr char const* descr = R"trtdoc(
A TopK layer in an :class:`INetworkDefinition` .
:ivar op: :class:`TopKOperation` The operation for the layer.
:ivar k: :class:`TopKOperation` the k value for the layer. Currently only values up to 3840 are supported.
Use the set_input() method with index 1 to pass in dynamic k as a tensor.
:ivar axes: :class:`TopKOperation` The axes along which to reduce.
:ivar indices_type: :class:`DataType` The specified data type of the output indices tensor. Must be tensorrt.int32 or tensorrt.int64.
)trtdoc";
constexpr char const* set_input = R"trtdoc(
Sets the input tensor for the given index. The index must be 0 or 1 for a TopK layer.
The indices are as follows:
===== ==================================================================================
Index Description
===== ==================================================================================
0 Input data tensor.
1 A scalar Int32 tensor containing a positive value corresponding to the number
of top elements to retrieve. Values larger than 3840 will result in a runtime
error. If provided, this will override the static k value in calculations.
===== ==================================================================================
:arg index: The index of the input tensor.
:arg tensor: The input tensor.
)trtdoc";
} // namespace ITopKLayerDoc
namespace MatrixOperationDoc
{
constexpr char const* descr = R"trtdoc(The matrix operations that may be performed by a Matrix layer)trtdoc";
constexpr char const* NONE = R"trtdoc()trtdoc";
constexpr char const* TRANSPOSE = R"trtdoc(Transpose each matrix)trtdoc";
constexpr char const* VECTOR = R"trtdoc(Treat operand as collection of vectors)trtdoc";
} // namespace MatrixOperationDoc
namespace IMatrixMultiplyLayerDoc
{
constexpr char const* descr = R"trtdoc(
A matrix multiply layer in an :class:`INetworkDefinition` .
Let A be op(getInput(0)) and B be op(getInput(1)) where
op(x) denotes the corresponding MatrixOperation.
When A and B are matrices or vectors, computes the inner product A * B:
| matrix * matrix -> matrix
| matrix * vector -> vector
| vector * matrix -> vector
| vector * vector -> scalar
Inputs of higher rank are treated as collections of matrices or vectors.
The output will be a corresponding collection of matrices, vectors, or scalars.
:ivar op0: :class:`MatrixOperation` How to treat the first input.
:ivar op1: :class:`MatrixOperation` How to treat the second input.
)trtdoc";
} // namespace IMatrixMultiplyLayerDoc
namespace CollectiveOperationDoc
{
constexpr char const* descr
= R"trtdoc(The collective operations that may be performed by a DistCollective layer)trtdoc";
constexpr char const* ALL_REDUCE = R"trtdoc(All reduce collective operation)trtdoc";
constexpr char const* ALL_GATHER = R"trtdoc(All gather collective operation)trtdoc";
constexpr char const* BROADCAST = R"trtdoc(Broadcast collective operation)trtdoc";
constexpr char const* REDUCE = R"trtdoc(Reduce collective operation)trtdoc";
constexpr char const* REDUCE_SCATTER = R"trtdoc(Reduce scatter collective operation)trtdoc";
constexpr char const* ALL_TO_ALL = R"trtdoc(All-to-all collective operation)trtdoc";
constexpr char const* GATHER = R"trtdoc(Gather collective operation)trtdoc";
constexpr char const* SCATTER = R"trtdoc(Scatter collective operation)trtdoc";
} // namespace CollectiveOperationDoc
namespace IDistCollectiveLayerDoc
{
constexpr char const* descr = R"trtdoc(
A dist collective layer in an :class:`INetworkDefinition` .
)trtdoc";
} // namespace IDistCollectiveLayerDoc
namespace IRaggedSoftMaxLayerDoc
{
constexpr char const* descr = R"trtdoc(
A ragged softmax layer in an :class:`INetworkDefinition` .
This layer takes a ZxS input tensor and an additional Zx1 bounds tensor holding the lengths of the Z sequences.
This layer computes a softmax across each of the Z sequences.
The output tensor is of the same size as the input tensor.
)trtdoc";
} // namespace IRaggedSoftMaxLayerDoc
namespace IIdentityLayerDoc
{
constexpr char const* descr = R"trtdoc(
A layer that represents the identity function.
If tensor precision is explicitly specified, it can be used to transform from one precision to another.
Other than conversions between the same type (``float32`` -> ``float32`` for example), the only valid conversions are:
(``float32`` | ``float16`` | ``int32`` | ``bool``) -> (``float32`` | ``float16`` | ``int32`` | ``bool``)
(``float32`` | ``float16``) -> ``uint8``
``uint8`` -> (``float32`` | ``float16``)
)trtdoc";
} // namespace IIdentityLayerDoc
namespace ICastLayerDoc
{
constexpr char const* descr = R"trtdoc(
A layer that represents the cast function.
This layer casts the element of a given input tensor to a specified data type and returns an output tensor of the same shape in the converted type.
Conversions between all types except FP8 is supported.
:ivar to_type: :class:`DataType` The specified data type of the output tensor.
)trtdoc";
} // namespace ICastLayerDoc
namespace IConstantLayerDoc
{
constexpr char const* descr = R"trtdoc(
A constant layer in an :class:`INetworkDefinition` .
Note: This layer does not support boolean and uint8 types.