TensorRT 10.8.0
|
构建器的输入网络定义。 更多...
#include <NvInfer.h>
公共成员函数 | |
virtual | ~INetworkDefinition () noexcept=default |
ITensor * | addInput (char const *name, DataType type, Dims const &dimensions) noexcept |
向网络添加输入张量。 更多... | |
void | markOutput (ITensor &tensor) noexcept |
将张量标记为网络输出。 更多... | |
bool | markDebug (ITensor &tensor) noexcept |
将张量标记为调试张量。 更多... | |
bool | unmarkDebug (ITensor &tensor) noexcept |
取消张量作为调试张量的标记。 更多... | |
bool | isDebugTensor (nvinfer1::ITensor const &tensor) const noexcept |
检查张量是否标记为调试张量。 更多... | |
IActivationLayer * | addActivation (ITensor &input, ActivationType type) noexcept |
向网络添加激活层。 更多... | |
ILRNLayer * | addLRN (ITensor &input, int64_t window, float alpha, float beta, float k) noexcept |
向网络添加 LRN 层。 更多... | |
IScaleLayer * | addScale (ITensor &input, ScaleMode mode, Weights shift, Weights scale, Weights power) noexcept |
向网络添加 Scale 层。 更多... | |
ISoftMaxLayer * | addSoftMax (ITensor &input) noexcept |
向网络添加 SoftMax 层。 更多... | |
IConcatenationLayer * | addConcatenation (ITensor *const *inputs, int32_t nbInputs) noexcept |
向网络添加 concatenation 层。 更多... | |
IElementWiseLayer * | addElementWise (ITensor &input1, ITensor &input2, ElementWiseOperation op) noexcept |
向网络添加 elementwise 层。 更多... | |
IUnaryLayer * | addUnary (ITensor &input, UnaryOperation operation) noexcept |
向网络添加 unary 层。 更多... | |
IShuffleLayer * | addShuffle (ITensor &input) noexcept |
向网络添加 shuffle 层。 更多... | |
IOneHotLayer * | addOneHot (ITensor &indices, ITensor &values, ITensor &depth, int32_t axis) noexcept |
向网络添加 OneHot 层。 更多... | |
int32_t | getNbLayers () const noexcept |
获取网络中的层数。 更多... | |
ILayer * | getLayer (int32_t index) const noexcept |
获取给定索引指定的层。 更多... | |
int32_t | getNbInputs () const noexcept |
获取网络中的输入数量。 更多... | |
ITensor * | getInput (int32_t index) const noexcept |
获取给定索引指定的输入张量。 更多... | |
int32_t | getNbOutputs () const noexcept |
获取网络中的输出数量。 更多... | |
ITensor * | getOutput (int32_t index) const noexcept |
获取给定索引指定的输出张量。 更多... | |
IReduceLayer * | addReduce (ITensor &input, ReduceOperation operation, uint32_t reduceAxes, bool keepDimensions) noexcept |
向网络添加 reduce 层。 更多... | |
ITopKLayer * | addTopK (ITensor &input, TopKOperation op, int32_t k, uint32_t reduceAxes) noexcept |
向网络添加 TopK 层。 更多... | |
IGatherLayer * | addGather (ITensor &data, ITensor &indices, int32_t axis) noexcept |
添加 gather,模式为 GatherMode::kDEFAULT,并指定轴和 nbElementWiseDims=0。 更多... | |
IGatherLayer * | addGatherV2 (ITensor &data, ITensor &indices, GatherMode mode) noexcept |
添加 gather,指定模式,axis=0 和 nbElementWiseDims=0。 更多... | |
IRaggedSoftMaxLayer * | addRaggedSoftMax (ITensor &input, ITensor &bounds) noexcept |
向网络添加 RaggedSoftMax 层。 更多... | |
IMatrixMultiplyLayer * | addMatrixMultiply (ITensor &input0, MatrixOperation op0, ITensor &input1, MatrixOperation op1) noexcept |
向网络添加 MatrixMultiply 层。 更多... | |
INonZeroLayer * | addNonZero (ITensor &input) noexcept |
向网络添加 nonzero 层。 更多... | |
IConstantLayer * | addConstant (Dims const &dimensions, Weights weights) noexcept |
向网络添加 constant 层。 更多... | |
IIdentityLayer * | addIdentity (ITensor &input) noexcept |
添加 identity 层。 更多... | |
ICastLayer * | addCast (ITensor &input, DataType toType) noexcept |
添加 cast 层。 更多... | |
void | removeTensor (ITensor &tensor) noexcept |
从网络定义中移除张量。 更多... | |
void | unmarkOutput (ITensor &tensor) noexcept |
取消张量作为网络输出的标记。 更多... | |
TRT_DEPRECATED IPluginV2Layer * | addPluginV2 (ITensor *const *inputs, int32_t nbInputs, IPluginV2 &plugin) noexcept |
使用 IPluginV2 接口向网络添加插件层。 更多... | |
IPluginV3Layer * | addPluginV3 (ITensor *const *inputs, int32_t nbInputs, ITensor *const *shapeInputs, int32_t nbShapeInputs, IPluginV3 &plugin) noexcept |
向网络添加实现 IPluginV3 接口的插件层。 更多... | |
ISliceLayer * | addSlice (ITensor &input, Dims const &start, Dims const &size, Dims const &stride) noexcept |
向网络添加 slice 层。 更多... | |
void | setName (char const *name) noexcept |
设置网络的名称。 更多... | |
char const * | getName () const noexcept |
返回与网络关联的名称。 更多... | |
IShapeLayer * | addShape (ITensor &input) noexcept |
向网络添加 shape 层。 更多... | |
TRT_DEPRECATED bool | hasImplicitBatchDimension () const noexcept |
查询网络是否使用隐式批次维度创建。 更多... | |
NetworkDefinitionCreationFlags | getFlags () const noexcept |
获取此网络定义对象的网络定义创建标志。默认为 0。 更多... | |
bool | getFlag (NetworkDefinitionCreationFlag networkDefinitionCreationFlag) const noexcept |
如果设置了网络定义创建标志,则返回 true。 更多... | |
bool | markOutputForShapes (ITensor &tensor) noexcept |
启用 IExecutionContext::getShapeBinding 计算张量的值。 更多... | |
bool | unmarkOutputForShapes (ITensor &tensor) noexcept |
撤消 markOutputForShapes。 更多... | |
IParametricReLULayer * | addParametricReLU (ITensor &input, ITensor &slope) noexcept |
向网络添加 parametric ReLU 层。 更多... | |
IConvolutionLayer * | addConvolutionNd (ITensor &input, int64_t nbOutputMaps, Dims const &kernelSize, Weights kernelWeights, Weights biasWeights) noexcept |
向网络添加多维卷积层。 更多... | |
IPoolingLayer * | addPoolingNd (ITensor &input, PoolingType type, Dims const &windowSize) noexcept |
向网络添加多维 pooling 层。 更多... | |
IDeconvolutionLayer * | addDeconvolutionNd (ITensor &input, int64_t nbOutputMaps, Dims kernelSize, Weights kernelWeights, Weights biasWeights) noexcept |
向网络添加多维反卷积层。 更多... | |
IScaleLayer * | addScaleNd (ITensor &input, ScaleMode mode, Weights shift, Weights scale, Weights power, int32_t channelAxis) noexcept |
向网络添加多维 scale 层。 更多... | |
IResizeLayer * | addResize (ITensor &input) noexcept |
向网络添加 resize 层。 更多... | |
ILoop * | addLoop () noexcept |
向网络添加 loop。 更多... | |
IIfConditional * | addIfConditional () noexcept |
向网络添加 if-then-else。 更多... | |
ISelectLayer * | addSelect (ITensor &condition, ITensor &thenInput, ITensor &elseInput) noexcept |
向网络添加 select 层。 更多... | |
IAssertionLayer * | addAssertion (ITensor &condition, char const *message) noexcept |
向网络添加 assertion 层。 更多... | |
TRT_DEPRECATED IFillLayer * | addFill (Dims const &dimensions, FillOperation op) noexcept |
向网络添加 fill 层。 更多... | |
IFillLayer * | addFill (Dims const &dimensions, FillOperation op, DataType outputType) noexcept |
向网络添加 fill 层。 更多... | |
IPaddingLayer * | addPaddingNd (ITensor &input, Dims const &prePadding, Dims const &postPadding) noexcept |
向网络添加 padding 层。目前仅支持 2D padding。 更多... | |
bool | setWeightsName (Weights weights, char const *name) noexcept |
将名称与给定权重的当前所有用法关联。 更多... | |
void | setErrorRecorder (IErrorRecorder *recorder) noexcept |
为此接口设置 ErrorRecorder。 更多... | |
IErrorRecorder * | getErrorRecorder () const noexcept |
获取分配给此接口的 ErrorRecorder。 更多... | |
TRT_DEPRECATED IDequantizeLayer * | addDequantize (ITensor &input, ITensor &scale) noexcept |
向网络添加反量化层。 更多... | |
IDequantizeLayer * | addDequantize (ITensor &input, ITensor &scale, DataType outputType) noexcept |
向网络添加反量化层。 更多... | |
IScatterLayer * | addScatter (ITensor &data, ITensor &indices, ITensor &updates, ScatterMode mode) noexcept |
向网络添加 Scatter 层,模式为指定模式,axis=0。 更多... | |
TRT_DEPRECATED IQuantizeLayer * | addQuantize (ITensor &input, ITensor &scale) noexcept |
向网络添加量化层。 更多... | |
IQuantizeLayer * | addQuantize (ITensor &input, ITensor &scale, DataType outputType) noexcept |
向网络添加量化层。 更多... | |
IDynamicQuantizeLayer * | addDynamicQuantize (ITensor &input, int32_t axis, int32_t blockSize, DataType outputType, DataType scaleType) noexcept |
向网络添加动态量化层。 更多... | |
IEinsumLayer * | addEinsum (ITensor *const *inputs, int32_t nbInputs, char const *equation) noexcept |
向网络添加 Einsum 层。 更多... | |
IGridSampleLayer * | addGridSample (ITensor &input, ITensor &grid) noexcept |
向网络添加 GridSample 层。 更多... | |
INMSLayer * | addNMS (ITensor &boxes, ITensor &scores, ITensor &maxOutputBoxesPerClass) noexcept |
向网络添加非极大值抑制层。 更多... | |
IReverseSequenceLayer * | addReverseSequence (ITensor &input, ITensor &sequenceLens) noexcept |
向网络添加 ReverseSequence 层。 更多... | |
INormalizationLayer * | addNormalization (ITensor &input, ITensor &scale, ITensor &bias, uint32_t axesMask) noexcept |
向网络添加 normalization 层。 更多... | |
ICumulativeLayer * | addCumulative (ITensor &input, ITensor &axis, CumulativeOperation operation, bool exclusive, bool reverse) noexcept |
向网络添加 cumulative 层。 更多... | |
virtual IBuilder & | getBuilder () const noexcept |
返回从中创建此 INetworkDefinition 的构建器。 更多... | |
bool | markWeightsRefittable (char const *name) noexcept |
当构建器标志 kREFIT_INDIVIDUAL 设置时,将权重标记为可重新拟合。 更多... | |
bool | unmarkWeightsRefittable (char const *name) noexcept |
当构建器标志 kREFIT_INDIVIDUAL 设置时,取消权重作为可重新拟合的标记。 更多... | |
bool | areWeightsMarkedRefittable (char const *name) const noexcept |
权重是否已标记为可重新拟合。 更多... | |
ISqueezeLayer * | addSqueeze (ITensor &input, ITensor &axes) noexcept |
向网络添加 squeeze 层。 更多... | |
IUnsqueezeLayer * | addUnsqueeze (ITensor &input, ITensor &axes) noexcept |
向网络添加 unsqueeze 层。 更多... | |
保护属性 | |
apiv::VNetworkDefinition * | mImpl |
附加的继承成员 | |
![]() | |
INoCopy ()=default | |
virtual | ~INoCopy ()=default |
INoCopy (INoCopy const &other)=delete | |
INoCopy & | operator= (INoCopy const &other)=delete |
INoCopy (INoCopy &&other)=delete | |
INoCopy & | operator= (INoCopy &&other)=delete |
网络的定义,用于构建器。
网络定义定义了网络的结构,并与 IBuilderConfig 结合使用,通过 IBuilder 构建成引擎。INetworkDefinition 可以拥有所有显式维度,即完全维度模式,在网络定义中。之前的模式,即隐式批大小模式,已被弃用。
具有隐式批处理维度的网络返回不包含隐式维度的层维度,而批处理大小在执行/入队时指定。如果网络具有所有指定的维度,则第一个维度遵循元素级广播规则:如果对于某些输入为 1,而对于所有其他输入为某个值 N,则每个输出的第一个维度为 N,并且第一个维度为 1 的输入将被广播。不支持跨层输入具有不同的批处理大小。
|
virtualdefaultnoexcept |
|
inlinenoexcept |
向网络添加激活层。
input | 图层的输入张量。 |
type | 要应用的激活函数类型。 |
请注意,对于需要这些参数的激活函数,必须在输出上使用 setAlpha() 和 setBeta() 方法。
|
inlinenoexcept |
向网络添加断言层。
condition | 图层的输入张量。 |
message | 断言失败时要打印的消息。 |
输入张量必须是布尔形状张量。
|
inlinenoexcept |
|
inlinenoexcept |
向网络添加连接层。
inputs | 图层的输入张量。 |
nbInputs | 输入张量的数量。 |
|
inlinenoexcept |
向网络添加常量层。
dimensions | 常量的维度。 |
weights | 常量值,表示为权重。 |
如果 weights.type 是 DataType::kINT32,则输出是 32 位索引的张量。否则,输出是实数值的张量,输出类型将遵循 TensorRT 的正常精度规则。
如果使用通配符维度,则运行时维度的体积必须等于指定的权重数。
|
inlinenoexcept |
向网络添加多维卷积层。
input | 卷积的输入张量。 |
nbOutputMaps | 卷积的输出特征图的数量。 |
kernelSize | 卷积核的多维尺寸。 |
kernelWeights | 卷积的核权重。 |
biasWeights | 卷积的偏置权重。Weights{} 表示无偏置。 |
|
inlinenoexcept |
向网络添加累积层。
input | 图层的输入张量。 |
axis | 应用累积运算的轴张量。当前,它必须是构建时常量 0D 形状张量,并且必须在范围 [-rank(input), rank(input)-1] 内。负值表示从后向前计数维度。 |
operation | 要执行的归约运算。 |
exclusive | 指定是独占累积还是包含累积的布尔值。 |
reverse | 指定是否应向后应用累积运算的布尔值。 |
累积层通过对张量 input
在由 axis
指定的轴上执行指定的累积 operation
来工作。
|
inlinenoexcept |
向网络添加多维反卷积层。
input | 图层的输入张量。 |
nbOutputMaps | 输出特征图的数量。 |
kernelSize | 反卷积核的多维尺寸。 |
kernelWeights | 反卷积的核权重。 |
biasWeights | 反卷积的偏置权重。Weights{} 表示无偏置。 |
|
inlinenoexcept |
向网络添加反量化层。
input | 要反量化的输入张量。 |
scale | 具有比例值的张量。 |
input
张量数据类型必须是 DataType::kINT8/DataType::kFP8。scale
张量数据类型必须是 DataType::kFLOAT。以 scale
张量结尾的子图必须是构建时常量。
|
inlinenoexcept |
向网络添加反量化层。
input | 要反量化的输入张量。 |
scale | 具有比例值的张量。 |
input
张量数据类型必须是 DataType::kINT8/DataType::kFP8/DataType::kINT4。scale
张量数据类型默认为 DataType::kFLOAT。对于强类型网络,它必须与输出数据类型相同。以 scale
张量结尾的子图必须是构建时常量。outputType
输出张量数据类型,默认值为 DataType::kFLOAT。后续使用 setToType 或 setOutputType 设置输出类型的调用必须保持一致。对于强类型网络,它必须与比例数据类型相同。
|
inlinenoexcept |
向网络添加动态量化层。
此层对其输入张量执行动态块量化,并输出量化数据和计算出的块比例因子。块大小目前限制为 16,并且分块轴的大小必须可被 16 整除。
input | 要量化的输入张量。其数据类型必须是 DataType::kFLOAT、DataType::kHALF 或 DataType::kBF16 之一。目前仅支持 2D 和 3D 输入。 |
axis | 被切分成块的轴。该轴必须是最后一个或倒数第二个维度。 |
blockSize | 使用共享比例因子量化的元素数量。目前仅支持 16 个元素的块。 |
outputType
量化输出张量的数据类型,必须是 DataType::kFP4。后续使用 setToType 或 setOutputType 设置输出类型的调用必须保持一致。scaleType
用于量化输入数据的比例因子数据类型,必须是 DataType::kFP8。
|
inlinenoexcept |
向网络添加 Einsum 层。
inputs | 图层的输入张量。 |
nbInputs | 输入张量的数量。 |
equation | 图层的方程 |
|
inlinenoexcept |
向网络添加逐元素层。
input1 | 图层的第一个输入张量。 |
input2 | 图层的第二个输入张量。 |
op | 图层应用的二元运算。 |
输入张量必须具有相同的秩和兼容的类型。如果两种类型相同或都在集合 {kFLOAT, kHALF} 中,则它们是兼容的。对于每个维度,它们的长度必须匹配,或者其中一个必须为 1。在后一种情况下,张量沿该轴广播。
输出张量与输入具有相同的秩。对于每个维度,其长度是相应输入维度的长度的最大值。
如果输出是形状张量,则输入是形状张量。
|
inlinenoexcept |
向网络添加填充层。
dimensions | 如果输入 0 缺失,则为输出张量维度。 |
op | 图层应用的填充操作。 |
由于随机状态在调用之间共享,因此如果 op
是 FillOperation::kRANDOM_UNIFORM 或 FillOperation::kRANDOM_NORMAL 之一,则此层在后续调用中是不确定的,因为相同的输入将产生不同的输出张量。当从相同的初始状态开始时,生成的输出张量是确定的。
|
inlinenoexcept |
向网络添加填充层。
dimensions | 如果输入 0 缺失,则为输出张量维度。 |
op | 图层应用的填充操作。 |
outputType | 可选的输出张量数据类型,必须是 DataType::kFLOAT、DataType::kHALF、DataType::kINT32 或 DataType::kINT64。此参数仅用于静态 alpha/beta。后续使用 setToType 或 setOutputType 设置输出类型的调用必须保持一致。 |
由于随机状态在后续调用之间共享,因此如果 op
是 FillOperation::kRANDOM_UNIFORM 或 FillOperation::kRANDOM_NORMAL 之一,则此层在后续调用中是不确定的,因为相同的输入将产生不同的输出张量。当从相同的初始状态开始时,生成的输出张量是确定的。
|
inlinenoexcept |
添加 Gather,模式为 GatherMode::kDEFAULT,并指定轴和 nbElementWiseDims=0。
data | 从中收集值的张量。 |
indices | 从中获取索引以填充输出张量的张量。 |
axis | 要在数据张量上收集的轴。 |
|
inlinenoexcept |
添加 Gather,指定模式,axis=0 和 nbElementWiseDims=0。
data | 从中收集值的张量。 |
indices | 从中获取索引以填充输出张量的张量。 |
mode | Gather 模式。 |
|
inlinenoexcept |
向网络添加 GridSample 层。
input | 图层的输入张量。 |
grid | 图层的网格张量。 |
为 4d 形状输入张量创建具有 InterpolationMode::kLINEAR、未对齐角点和 SampleMode::kFILL 的 GridSample 层。
|
inlinenoexcept |
|
inlinenoexcept |
向网络添加 if-then-else 结构。
IIfConditional 提供了一种有条件地执行网络部分的方法。
|
inlinenoexcept |
向网络添加输入张量。
每个输入和输出张量都必须具有唯一的名称。体积必须小于 2^31 个元素。
对于具有通配符维度的网络,体积基于 IOptimizationProfile 指定的最大值。维度通常是非负整数。例外情况是,在具有所有显式维度的网络中,-1 可以用作运行时指定维度的通配符。具有此类通配符的输入张量必须在 IOptimizationProfiles 中具有相应的条目,指示允许的极值,并且输入维度必须由 IExecutionContext::setInputShape 设置。不同的 IExecutionContext 实例可以具有不同的维度。通配符维度仅在 EngineCapability::kSTANDARD 中受支持。在安全上下文中不支持它们。DLA 不支持通配符维度。
张量维度是独立于格式指定的。例如,如果张量以“NHWC”或矢量化格式格式化,则维度仍以 {N, C, H, W} 的顺序指定。对于具有通道维度的 2D 图像,最后三个维度始终为 {C,H,W}。对于具有通道维度的 3D 图像,最后四个维度始终为 {C,D,H,W}。
name | 张量的名称。 |
type | 张量中保存的数据类型。 |
dimensions | 张量的维度。 |
|
inlinenoexcept |
|
inlinenoexcept |
向网络添加 LRN 层。
input | 图层的输入张量。 |
window | 窗口的大小。 |
alpha | LRN 计算的 alpha 值。 |
beta | LRN 计算的 beta 值。 |
k | LRN 计算的 k 值。 |
|
inlinenoexcept |
向网络添加矩阵乘法层。
input0 | 第一个输入张量(通常为 A)。 |
op0 | 应用于 input0 的操作。 |
input1 | 第二个输入张量(通常为 B)。 |
op1 | 应用于 input1 的操作。 |
如果输出是形状张量,则输入是形状张量。
|
inlinenoexcept |
向网络添加非极大值抑制层。
boxes | 图层的输入框张量。 |
scores | 图层的输入分数张量。 |
maxOutputBoxesPerClass | 图层的输入 maxOutputBoxesPerClass 张量。 |
|
inlinenoexcept |
|
inlinenoexcept |
向网络添加归一化层。
input | 图层的输入张量。 |
scale | 用于缩放归一化输出的比例张量。 |
bias | 用于缩放归一化输出的偏置张量。 |
axesMask | 在其上执行均值计算的轴。位掩码 axesMask 中位置 i 的位对应于结果的显式维度 i。例如,最低有效位对应于第一个显式维度,下一个最低有效位对应于第二个显式维度。 |
归一化层通过对指定 axesMask
上的张量 input
执行归一化来工作。然后,结果通过与 scale
相乘并加上 bias
来缩放。
scale
和 bias
的形状应相同,并且必须具有相同的秩,并且可单向广播到 input
的形状。
|
inlinenoexcept |
向网络添加 OneHot 层。
indices | - 包含应设置 on_value 的索引的张量。 |
values | - 由 [off_value, on_value] 组成的 2 元素张量。 |
depth | - 包含添加的 one-hot 维度的宽度的形状张量。 |
axis | - 添加 one-hot 编码的轴。 |
|
inlinenoexcept |
向网络添加填充层。当前仅支持 2D 填充。
input | 图层的输入张量。 |
prePadding | 要应用于张量开头的填充。 |
postPadding | 要应用于张量末尾的填充。 |
|
inlinenoexcept |
向网络添加参数化 ReLU 层。
input | 图层的输入张量。 |
slope | 图层的斜率张量。此张量应可单向广播到输入张量。 |
|
inlinenoexcept |
使用 IPluginV2 接口向网络添加插件层。
inputs | 图层的输入张量。 |
nbInputs | 输入张量的数量。 |
plugin | 图层插件。 |
|
inlinenoexcept |
向网络添加实现 IPluginV3 接口的插件层。
inputs | 图层的输入张量。 |
nbInputs | 输入张量的数量。 |
shapeInputs | 图层的形状张量输入。 |
nbShapeInputs | 形状张量输入的数量。 |
plugin | 图层插件。 |
|
inlinenoexcept |
向网络添加多维池化层。
input | 图层的输入张量。 |
type | 要应用的池化类型。 |
windowSize | 池化窗口的大小。 |
|
inlinenoexcept |
向网络添加量化层。
input | 要反量化的输入张量。 |
scale | 具有比例值的张量。 |
input
张量数据类型必须是 DataType::kFLOAT/DataType::kHALF。scale
张量数据类型必须是 DataType::kFLOAT。以 scale
张量结尾的子图必须是构建时常量。
|
inlinenoexcept |
向网络添加量化层。
input | 要反量化的输入张量。 |
scale | 具有比例值的张量。 |
input
张量数据类型必须是 DataType::kFLOAT/DataType::kHALF/DataType::kBF16。scale
张量数据类型默认为 DataType::kFLOAT。对于强类型网络,它必须与输入具有相同的数据类型。以 scale
张量结尾的子图必须是构建时常量。outputType
输出张量数据类型,必须是 DataType::kINT8 (默认), DataType::kFP8 或 DataType::kINT4。后续使用 setToType 或 setOutputType 设置输出类型的调用必须保持一致。
|
inlinenoexcept |
向网络添加 RaggedSoftMax 层。
input | ZxS 输入张量。 |
bounds | Zx1 bounds 张量。 |
|
inlinenoexcept |
向网络添加一个 reduce 层。
input | 图层的输入张量。 |
operation | 要执行的归约运算。 |
reduceAxes | 缩减维度。位掩码 reduceAxes 中位置 i 的位对应于结果的显式维度 i。例如,最低有效位对应于第一个显式维度,次低有效位对应于第二个显式维度。 |
keepDimensions | 一个布尔值,指定是否在层的输出中保留缩减的维度。 |
reduce 层的工作原理是执行 operation
指定的操作,以在 reduceAxes
指定的轴上缩减张量 input
。
|
inlinenoexcept |
向网络添加一个 resize 层。
input | 图层的输入张量。 |
|
inlinenoexcept |
向网络添加一个 ReverseSequence 层。
input | 该层的输入张量。秩必须 >= 2。 |
sequenceLens | 1D 张量,指定批次中要反转的序列的长度。sequenceLens 张量的长度必须等于输入张量中由 batchAxis 指定的维度的大小。 |
|
inlinenoexcept |
向网络添加一个 Scale 层。
input | 该层的输入张量。此张量必须至少有 4 个维度。 |
mode | 缩放模式。 |
shift | shift 值。 |
scale | scale 值。 |
power | power 值。 |
如果权重可用,则权重的大小取决于 ScaleMode。对于 ScaleMode::kUNIFORM,权重数等于 1。对于 ScaleMode::kCHANNEL,权重数等于通道维度。对于 ScaleMode::kELEMENTWISE,权重数等于输入的最后三个维度的乘积。
|
inlinenoexcept |
向网络添加一个多维 scale 层。
input | 图层的输入张量。 |
mode | 缩放模式。 |
shift | shift 值。 |
scale | scale 值。 |
power | power 值。 |
channelAxis | 通道轴。 |
如果权重可用,则权重的大小取决于 ScaleMode。对于 ScaleMode::kUNIFORM,权重数等于 1。对于 ScaleMode::kCHANNEL,权重数等于通道维度。对于 ScaleMode::kELEMENTWISE,权重数等于 channelAxis 及之后所有输入维度的乘积。
例如,如果输入维度为 [A,B,C,D,E,F],并且 channelAxis=2:对于 ScaleMode::kUNIFORM,权重数等于 1。对于 ScaleMode::kCHANNEL,权重数为 C。对于 ScaleMode::kELEMENTWISE,权重数为 C*D*E*F。
channelAxis 也可以使用 setChannelAxis() 显式设置。
|
inlinenoexcept |
向网络添加一个 Scatter 层,并指定模式和 axis=0。
data | 要使用附加值更新的输入张量。 |
indices | 要更新的元素的索引。 |
updates | 用于更新的值。 |
mode | scatter 模式。 |
indices
张量数据类型必须是 DataType::kINT32。updates
张量数据类型必须与 data
相同
|
inlinenoexcept |
向网络添加一个 select 层。
condition | 该层的条件张量。必须具有 DataType::kBOOL 类型。 |
thenInput | 该层的 "then" 输入张量。 |
elseInput | 该层的 "else" 输入张量。 |
所有三个输入张量必须具有相同的秩,并且沿每个轴必须具有相同的长度或长度为 1。如果长度为 1,则张量沿该轴广播。输出张量具有应用广播规则后的输入维度。例如,给定
条件的维度:[1,1,5,9] thenInput 的维度:[1,1,5,9] elseInput 的维度:[1,3,1,9]
输出维度为 [1,3,5,9],输出内容由以下定义
output[0,i,j,k] = condition[0,0,j,k] ? thenInput[0,0,j,k] : elseInput[0,i,0,k]
如果任何输入是空张量,则输出维度不一定inputs维度的最大值。例如,如果在前面的示例中,将 5 更改为 0
条件的维度:[1,1,0,9] thenInput 的维度:[1,1,0,9] elseInput 的维度:[1,3,1,9]
则输出维度为 [1,3,0,9]。
如果输出是形状张量,则输入是形状张量。
|
inlinenoexcept |
向网络添加一个 shape 层。
input | 图层的输入张量。 |
|
inlinenoexcept |
|
inlinenoexcept |
向网络添加一个 slice 层。
input | 图层的输入张量。 |
start | 起始偏移量 |
size | 输出维度 |
stride | 切片步幅 |
允许正数、负数、零步幅值以及它们在不同维度中的组合。
|
inlinenoexcept |
|
inlinenoexcept |
向网络添加一个 squeeze 层。
input | 图层的输入张量。 |
axes | 要移除单位维度的轴。 |
轴必须可解析为常量 Int32 或 Int64 1D 形状张量。axes 中的值必须是唯一的,并且在 [-r, r-1] 范围内,其中 r 是输入张量的秩。对于每个轴值,输入张量中的相应维度必须为 1。
|
inlinenoexcept |
向网络添加一个 TopK 层。
TopK 层有两个相同维度的输出。第一个包含数据值,第二个包含值的索引位置。输出值已排序,对于 operation kMAX,从最大到最小排序,对于 operation kMIN,从最小到最大排序。
当前仅支持 K 值高达 3840。
input | 图层的输入张量。 |
op | 要执行的操作。 |
k | 要保留的元素数量。对于动态 k,请使用 setInput() 方法传入 k 作为张量,这将覆盖此处在计算中传递的静态 k 值。 |
reduceAxes | 缩减维度。位掩码 reduceAxes 中位置 i 的位对应于结果的显式维度 i。例如,最低有效位对应于第一个显式维度,次低有效位对应于第二个显式维度。 |
当前 reduceAxes 必须只指定一个维度,并且它必须是最后四个维度之一。
|
inlinenoexcept |
向网络添加一个 unary 层。
input | 图层的输入张量。 |
operation | 要应用的操作。 |
通常,输入必须具有浮点类型(或 kINT8 作为量化浮点数),但以下操作除外
如果输出是形状张量,则输入是形状张量。
|
inlinenoexcept |
向网络添加一个 unsqueeze 层。
input | 图层的输入张量。 |
axes | 要添加单位维度的轴。 |
轴必须可解析为常量 Int32 或 Int64 形状张量。axes 中的值必须是唯一的,并且在 [-r_final, r_final-1] 范围内,其中 r_final 是 rank(input) 和 len(axes) 的和。
r_final 必须小于 Dims::MAX_DIMS。
|
inlinenoexcept |
权重是否已标记为可重装配。
name | 要检查的权重的名称。 |
|
inlinevirtualnoexcept |
|
inlinenoexcept |
获取分配给此接口的 ErrorRecorder。
检索给定类别的已分配错误记录器对象。如果尚未调用 setErrorRecorder,则将返回 nullptr。
|
inlinenoexcept |
|
inlinenoexcept |
获取此网络定义对象的网络定义创建标志。默认为 0。
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
查询网络是否使用隐式批次维度创建。
|
inlinenoexcept |
检查张量是否标记为调试张量。
|
inlinenoexcept |
将张量标记为调试张量。
调试张量可以在运行时选择性地发出。请注意,需要张量名称才能在运行时指定调试张量。
tensor | 要标记为调试的张量 |
|
inlinenoexcept |
|
inlinenoexcept |
使 IExecutionContext::getShapeBinding 可以计算张量的值。
张量类型必须为 DataType::kINT32,并且维度不得超过一个。
|
inlinenoexcept |
当构建器标志 kREFIT_INDIVIDUAL 设置时,将权重标记为可重装配。
name | 权重的名称。 |
|
inlinenoexcept |
从网络定义中删除张量。
tensor | 要删除的张量 |
删除作为层输入或输出的张量是非法的。如果使用此类张量调用此方法,则会在日志中发出警告,并且该调用将被忽略。其预期用途是在使用 Layer::setInput() 连接两个网络后删除分离的张量。
|
inlinenoexcept |
为此接口设置 ErrorRecorder。
将 ErrorRecorder 分配给此接口。ErrorRecorder 将跟踪执行期间的所有错误。此函数将至少调用一次已注册 ErrorRecorder 的 incRefCount。将 recorder 设置为 nullptr 会取消注册接口的记录器,如果已注册记录器,则会导致调用 decRefCount。
如果未设置错误记录器,则消息将发送到全局日志流。
recorder | 要向此接口注册的错误记录器。 |
|
inlinenoexcept |
设置网络的名称。
name | 要分配给此网络的名称。 |
设置网络的名称,以便将其与构建的引擎关联。name
必须是空终止的 C 样式字符串。TensorRT 不使用此字符串,只是将其存储为引擎的一部分,以便可以在运行时检索它。默认情况下,将生成构建器唯一的名称。
此方法复制名称字符串。
|
inlinenoexcept |
|
inlinenoexcept |
取消将张量标记为调试张量。
移除将张量标记为调试张量的标记。
tensor | 要取消标记为调试的张量。 |
|
inlinenoexcept |
|
inlinenoexcept |
撤消 markOutputForShapes。
|
inlinenoexcept |
当构建器标志 kREFIT_INDIVIDUAL 设置时,取消将权重标记为可重装配。
name | 权重的名称。 |
|
protected |
版权所有 © 2024 NVIDIA Corporation
隐私政策 | 管理我的隐私 | 请勿出售或分享我的数据 | 服务条款 | 无障碍功能 | 公司政策 | 产品安全 | 联系方式