TensorRT 10.8.0
|
网络定义中的一个resize层。 更多...
#include <NvInfer.h>
公共成员函数 | |
void | setOutputDimensions (Dims const &dimensions) noexcept |
设置输出维度。 更多... | |
Dims | getOutputDimensions () const noexcept |
获取输出维度。 更多... | |
void | setScales (float const *scales, int32_t nbScales) noexcept |
设置resize比例因子。 更多... | |
int32_t | getScales (int32_t size, float *scales) const noexcept |
复制resize比例因子到 scales[0, ..., nbScales-1],其中 nbScales 是已设置的比例因子的数量。 更多... | |
void | setResizeMode (InterpolationMode interpolationMode) noexcept |
为输入张量设置resize模式。 更多... | |
InterpolationMode | getResizeMode () const noexcept |
获取输入张量的resize模式。 更多... | |
void | setCoordinateTransformation (ResizeCoordinateTransformation coordTransform) noexcept |
设置坐标变换函数。 更多... | |
ResizeCoordinateTransformation | getCoordinateTransformation () const noexcept |
获取坐标变换函数。 更多... | |
void | setSelectorForSinglePixel (ResizeSelector selector) noexcept |
设置resize到单像素时的坐标选择器函数。 更多... | |
ResizeSelector | getSelectorForSinglePixel () const noexcept |
获取resize到单像素时的坐标选择器函数。 更多... | |
void | setNearestRounding (ResizeRoundMode value) noexcept |
为最近邻resize设置舍入模式。 更多... | |
ResizeRoundMode | getNearestRounding () const noexcept |
获取最近邻resize的舍入模式。 更多... | |
void | setCubicCoeff (float A) noexcept |
设置三次插值中使用的系数 'A'。 更多... | |
float | getCubicCoeff () const noexcept |
获取三次插值中使用的系数 'A'。 更多... | |
void | setExcludeOutside (bool excludeFlag) noexcept |
设置排除外部像素的状态。 更多... | |
bool | getExcludeOutside () const noexcept |
获取排除外部像素的状态。 更多... | |
void | setInput (int32_t index, ITensor &tensor) noexcept |
为一个层的输入追加或替换特定的张量。 更多... | |
![]() | |
LayerType | getType () const noexcept |
返回层的类型。 更多... | |
void | setName (char const *name) noexcept |
设置层的名称。 更多... | |
char const * | getName () 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 |
获取与给定索引对应的层输出。 更多... | |
void | setInput (int32_t index, ITensor &tensor) noexcept |
用特定的张量替换此层的输入。 更多... | |
void | setPrecision (DataType dataType) noexcept |
在弱类型网络中,设置此层的首选或必需的计算精度。 更多... | |
DataType | getPrecision () const noexcept |
获取此层的计算精度 更多... | |
bool | precisionIsSet () const noexcept |
是否为此层设置了计算精度 更多... | |
void | resetPrecision () noexcept |
重置此层的计算精度 更多... | |
void | setOutputType (int32_t index, DataType dataType) noexcept |
在弱类型网络中,设置此层的输出类型。 更多... | |
DataType | getOutputType (int32_t index) const noexcept |
获取此层的输出类型 更多... | |
bool | outputTypeIsSet (int32_t index) const noexcept |
是否为此层设置了输出类型 更多... | |
void | resetOutputType (int32_t index) noexcept |
重置此层的输出类型 更多... | |
void | setMetadata (char const *metadata) noexcept |
为此层设置元数据。 更多... | |
char const * | getMetadata () const noexcept |
获取此层的元数据。 更多... | |
保护成员函数 | |
virtual | ~IResizeLayer () noexcept=default |
![]() | |
virtual | ~ILayer () noexcept=default |
![]() | |
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 |
保护属性 | |
apiv::VResizeLayer * | mImpl |
![]() | |
apiv::VLayer * | mLayer |
网络定义中的一个resize层。
Resize层可以用于调整 N 维张量的大小。
Resize层目前支持以下配置
m
个维度的大小,其中 0 < m <= min(8, N) 且 N > 0m
个维度的大小,其中 0 < m <= min(3, N) 且 N > 0默认的resize模式是 InterpolationMode::kNEAREST。
输出张量中的坐标使用 setCoordinateTransformation() 调用的函数映射到输入张量中的坐标。所有 InterpolationMode 设置(nearest、linear、bilinear 等)的默认值是 ResizeCoordinateTransformation::kASYMMETRIC。
resize层提供了两种调整张量维度大小的方法。
如果在 DLA 上执行此层,则支持以下参数组合
|
protectedvirtualdefaultnoexcept |
|
inlinenoexcept |
获取坐标变换函数。
|
inlinenoexcept |
获取三次插值中使用的系数 'A'。
|
inlinenoexcept |
获取排除外部像素的状态。
|
inlinenoexcept |
获取最近邻resize的舍入模式。
|
inlinenoexcept |
获取输出维度。
|
inlinenoexcept |
获取输入张量的resize模式。
|
inlinenoexcept |
复制resize比例因子到 scales[0, ..., nbScales-1],其中 nbScales 是已设置的比例因子的数量。
size | 要获取的比例因子的数量。如果 size != nbScales,则不会复制任何比例因子。 |
scales | 指向复制比例因子位置的指针。仅当 size == nbScales 且 scales != nullptr 时,才会复制比例因子。 |
如果大小未知,请考虑使用 size = 0 和 scales = nullptr。此方法将返回resize比例因子的数量。
|
inlinenoexcept |
获取resize到单像素时的坐标选择器函数。
|
inlinenoexcept |
设置坐标变换函数。
该函数将输出张量中的坐标映射到输入张量中的坐标。
|
inlinenoexcept |
设置三次插值中使用的系数 'A'。
三次插值使用系数 'A' 来计算输入像素的权重
x := The relative distance between the sampled pixels and the input coordinates. weight(x) := for |x| <= 1, ((A + 2) * x - (A + 3)) * x * x + 1, for 1 < |x| < 2, ((A * x - 5 * A) * x + 8 * A) * x - 4 * A, others 0;
此属性仅在“resize模式”为“cubic”时有效。
默认值为 -0.75。
|
inlinenoexcept |
设置排除外部像素的状态。
如果设置为 true,则输入张量外部采样位置的权重将设置为 false,并且权重将被重新归一化,使其总和为 1.0。
默认值为 false。
|
inlinenoexcept |
为一个层的输入追加或替换特定的张量。
index | 要修改的输入的索引。 |
tensor | 新的输入张量。 |
为给定的索引设置输入张量。对于静态resize层,索引必须为 0。通过调用 setInput 并使用索引 1,静态resize层会转换为动态resize层。动态resize层无法转换回静态resize层。
对于动态resize层,值 0 和 1 有效。动态情况下的索引如下:
如果使用值 1 调用此函数,则函数 getNbInputs() 的返回值将从 1 变为 2。
|
inlinenoexcept |
|
inlinenoexcept |
设置输出维度。
dimensions | 输出维度。输出维度的数量必须与输入维度的数量相同。 |
如果在 DLA 上执行此层,则不支持 setOutputDimensions()。
如果存在第二个输入,即resize层是动态的,则调用 setOutputDimensions() 是错误的,并且不会更新维度。
输出维度可以直接指定,也可以通过相对于输入维度的比例因子指定。可以使用 setScales() 提供resize的比例因子。
|
inlinenoexcept |
|
inlinenoexcept |
设置resize比例因子。
scales | resize比例因子数组。 |
nbScales | 比例因子的数量。比例因子的数量必须等于输入维度的数量。 |
如果在 DLA 上执行此层,则有三个限制:1) nbScales 必须正好为 4。2) 比例因子中的前两个元素必须正好为 1(对于未更改的批次和通道维度)。3) 最后两个元素中的比例因子(分别表示高度和宽度维度上的比例值)对于 kNEAREST 模式需要在 [1, 32] 范围内,对于 kLINEAR 模式需要在 [1, 4] 范围内。DLA 支持的比例因子示例:{1, 1, 2, 2}。
如果存在第二个输入,即resize层是动态的,则调用 setScales() 是错误的,并且不会更新比例因子。
输出维度的计算方式如下:outputDims[i] = floor(inputDims[i] * scales[i])
输出维度可以直接指定,也可以通过相对于输入维度的比例因子指定。可以使用 setOutputDimensions() 直接提供输出维度。
|
inlinenoexcept |
|
protected |
版权所有 © 2024 NVIDIA Corporation
隐私政策 | 管理我的隐私 | 请勿出售或分享我的数据 | 服务条款 | 辅助功能 | 公司政策 | 产品安全 | 联系我们