TensorRT 10.8.0
nvinfer1::IResizeLayer 类参考

网络定义中的一个resize层。 更多...

#include <NvInfer.h>

nvinfer1::IResizeLayer 的继承关系图
nvinfer1::ILayer nvinfer1::INoCopy

公共成员函数

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
 为一个层的输入追加或替换特定的张量。 更多...
 
- 继承自 nvinfer1::ILayer 的公共成员函数
LayerType getType () const noexcept
 返回层的类型。 更多...
 
void setName (char const *name) noexcept
 设置层的名称。 更多...
 
char const * getName () const noexcept
 返回层的名称。 更多...
 
int32_t getNbInputs () const noexcept
 获取层的输入数量。 更多...
 
ITensorgetInput (int32_t index) const noexcept
 获取与给定索引对应的层输入。 更多...
 
int32_t getNbOutputs () const noexcept
 获取层的输出数量。 更多...
 
ITensorgetOutput (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
 
- 继承自 nvinfer1::ILayer 的保护成员函数
virtual ~ILayer () noexcept=default
 
- 继承自 nvinfer1::INoCopy 的保护成员函数
 INoCopy ()=default
 
virtual ~INoCopy ()=default
 
 INoCopy (INoCopy const &other)=delete
 
INoCopyoperator= (INoCopy const &other)=delete
 
 INoCopy (INoCopy &&other)=delete
 
INoCopyoperator= (INoCopy &&other)=delete
 

保护属性

apiv::VResizeLayer * mImpl
 
- 继承自 nvinfer1::ILayer 的保护属性
apiv::VLayer * mLayer
 

详细描述

网络定义中的一个resize层。

Resize层可以用于调整 N 维张量的大小。

Resize层目前支持以下配置

默认的resize模式是 InterpolationMode::kNEAREST

输出张量中的坐标使用 setCoordinateTransformation() 调用的函数映射到输入张量中的坐标。所有 InterpolationMode 设置(nearest、linear、bilinear 等)的默认值是 ResizeCoordinateTransformation::kASYMMETRIC

resize层提供了两种调整张量维度大小的方法。

  • 直接设置输出维度。这可以用于静态和动态resize层。静态resize层需要在构建时知道输出维度。动态resize层需要将输出维度设置为输入张量之一。
  • 设置resize比例因子。每个输出维度计算为 floor(输入维度 * 比例因子)。只有静态resize层允许设置在构建时已知的比例因子。

如果在 DLA 上执行此层,则支持以下参数组合

警告
不要从此类继承,因为这样做会破坏 API 和 ABI 的向前兼容性。

构造函数 & 析构函数文档

◆ ~IResizeLayer()

virtual nvinfer1::IResizeLayer::~IResizeLayer ( )
protectedvirtualdefaultnoexcept

成员函数文档

◆ getCoordinateTransformation()

ResizeCoordinateTransformation nvinfer1::IResizeLayer::getCoordinateTransformation ( ) const
inlinenoexcept

获取坐标变换函数。

返回
坐标变换函数。

◆ getCubicCoeff()

float nvinfer1::IResizeLayer::getCubicCoeff ( ) const
inlinenoexcept

获取三次插值中使用的系数 'A'。

另请参阅
setCubicCoeff()

◆ getExcludeOutside()

bool nvinfer1::IResizeLayer::getExcludeOutside ( ) const
inlinenoexcept

获取排除外部像素的状态。

另请参阅
setExcludeOutside()

◆ getNearestRounding()

ResizeRoundMode nvinfer1::IResizeLayer::getNearestRounding ( ) const
inlinenoexcept

获取最近邻resize的舍入模式。

返回
舍入模式。

◆ getOutputDimensions()

Dims nvinfer1::IResizeLayer::getOutputDimensions ( ) const
inlinenoexcept

获取输出维度。

返回
输出维度。

◆ getResizeMode()

InterpolationMode nvinfer1::IResizeLayer::getResizeMode ( ) const
inlinenoexcept

获取输入张量的resize模式。

返回
resize模式。

◆ getScales()

int32_t nvinfer1::IResizeLayer::getScales ( int32_t  size,
float *  scales 
) const
inlinenoexcept

复制resize比例因子到 scales[0, ..., nbScales-1],其中 nbScales 是已设置的比例因子的数量。

参数
size要获取的比例因子的数量。如果 size != nbScales,则不会复制任何比例因子。
scales指向复制比例因子位置的指针。仅当 size == nbScales 且 scales != nullptr 时,才会复制比例因子。

如果大小未知,请考虑使用 size = 0 和 scales = nullptr。此方法将返回resize比例因子的数量。

返回
resize比例因子的数量,即如果设置了比例因子,则为 nbScales。如果未设置比例因子或resize层在动态模式下使用,则返回 -1。

◆ getSelectorForSinglePixel()

ResizeSelector nvinfer1::IResizeLayer::getSelectorForSinglePixel ( ) const
inlinenoexcept

获取resize到单像素时的坐标选择器函数。

返回
选择器函数。

◆ setCoordinateTransformation()

void nvinfer1::IResizeLayer::setCoordinateTransformation ( ResizeCoordinateTransformation  coordTransform)
inlinenoexcept

设置坐标变换函数。

该函数将输出张量中的坐标映射到输入张量中的坐标。

默认函数是 ResizeCoordinateTransformation::kASYMMETRIC

另请参阅
ResizeCoordinateTransformation

◆ setCubicCoeff()

void nvinfer1::IResizeLayer::setCubicCoeff ( float  A)
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。

◆ setExcludeOutside()

void nvinfer1::IResizeLayer::setExcludeOutside ( bool  excludeFlag)
inlinenoexcept

设置排除外部像素的状态。

如果设置为 true,则输入张量外部采样位置的权重将设置为 false,并且权重将被重新归一化,使其总和为 1.0。

默认值为 false。

◆ setInput()

void nvinfer1::ILayer::setInput ( int32_t  index,
ITensor tensor 
)
inlinenoexcept

为一个层的输入追加或替换特定的张量。

参数
index要修改的输入的索引。
tensor新的输入张量。

为给定的索引设置输入张量。对于静态resize层,索引必须为 0。通过调用 setInput 并使用索引 1,静态resize层会转换为动态resize层。动态resize层无法转换回静态resize层。

对于动态resize层,值 0 和 1 有效。动态情况下的索引如下:

  • 0:要调整大小的执行张量。
  • 1:输出维度,作为 Int32 或 Int64 类型的 1D 张量。

如果使用值 1 调用此函数,则函数 getNbInputs() 的返回值将从 1 变为 2。

◆ setNearestRounding()

void nvinfer1::IResizeLayer::setNearestRounding ( ResizeRoundMode  value)
inlinenoexcept

为最近邻resize设置舍入模式。

此值用于最近邻插值舍入。它在坐标变换后应用。

默认为 kFLOOR。

另请参阅
ResizeRoundMode

◆ setOutputDimensions()

void nvinfer1::IResizeLayer::setOutputDimensions ( Dims const &  dimensions)
inlinenoexcept

设置输出维度。

参数
dimensions输出维度。输出维度的数量必须与输入维度的数量相同。

如果在 DLA 上执行此层,则不支持 setOutputDimensions()

如果存在第二个输入,即resize层是动态的,则调用 setOutputDimensions() 是错误的,并且不会更新维度。

输出维度可以直接指定,也可以通过相对于输入维度的比例因子指定。可以使用 setScales() 提供resize的比例因子。

另请参阅
setScales
getOutputDimensions

◆ setResizeMode()

void nvinfer1::IResizeLayer::setResizeMode ( InterpolationMode  interpolationMode)
inlinenoexcept

为输入张量设置resize模式。

支持的resize模式为最近邻和线性。

另请参阅
InterpolationMode

◆ setScales()

void nvinfer1::IResizeLayer::setScales ( float const *  scales,
int32_t  nbScales 
)
inlinenoexcept

设置resize比例因子。

参数
scalesresize比例因子数组。
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() 直接提供输出维度。

另请参阅
setOutputDimensions
getScales

◆ setSelectorForSinglePixel()

void nvinfer1::IResizeLayer::setSelectorForSinglePixel ( ResizeSelector  selector)
inlinenoexcept

设置resize到单像素时的坐标选择器函数。

当resize到单像素图像时,使用此函数来决定如何映射原始图像中的坐标。

默认为 ResizeSelector::kFORMULA

另请参阅
ResizeSelector

成员数据文档

◆ mImpl

apiv::VResizeLayer* nvinfer1::IResizeLayer::mImpl
protected

此类文档的生成文件为:

  版权所有 © 2024 NVIDIA Corporation
  隐私政策 | 管理我的隐私 | 请勿出售或分享我的数据 | 服务条款 | 辅助功能 | 公司政策 | 产品安全 | 联系我们