TensorRT 10.8.0
nvinfer1::IGatherLayer 类参考

网络定义中的 Gather 层。支持多种类型的 gathering。(收集)。更多...

#include <NvInfer.h>

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

公共成员函数

void setGatherAxis (int32_t axis) noexcept
 设置 GatherMode::kELEMENTS 和 GatherMode::kDEFAULT 使用的轴。该轴必须小于数据输入中的维度数。轴默认为 0。更多...
 
int32_t getGatherAxis () const noexcept
 获取要进行 gather 操作的轴。更多...
 
void setNbElementWiseDims (int32_t elementWiseDims) noexcept
 设置 indices 张量的要逐元素处理的前导维度数。更多...
 
int32_t getNbElementWiseDims () const noexcept
 获取 indices 张量的要逐元素处理的前导维度数。更多...
 
void setMode (GatherMode mode) noexcept
 设置 gather 模式。更多...
 
GatherMode getMode () const noexcept
 获取 gather 模式。更多...
 
- 继承自 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 ~IGatherLayer () 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::VGatherLayer * mImpl
 
- 继承自 nvinfer1::ILayer 的受保护属性
apiv::VLayer * mLayer
 

详细描述

网络定义中的 Gather 层。支持多种类型的 gathering(收集)。

Gather 层有两个输入张量:Data 和 Indices,以及一个输出张量 Output。此外,还有三个参数:mode、nbElementwiseDims 和 axis,它们控制如何解释索引。

输出的维度同样取决于模式

GatherMode::kDEFAULT:

    First nbElementwiseDims of output are computed by applying broadcast rules to
    first nbElementwiseDims of indices and data. Note that nbElementwiseDims <= 1.
    Rest of dimensions are computed by copying dimensions of Data, and replacing
    the dimension for axis gatherAxis with the dimensions of indices.

GatherMode::kND:
    If indices.d[q-1] = r - nbElementwiseDims
        output.d = [indices.d[0], ... , indices.d[q-2]]
    Else if indices.d[q-1] < r - nbElementWiseDims
        output.d = [indices.d[0], ... , indices.d[q-1], data.d[nbElementwiseDims + indices.d[q-1] + q],
        data.d[r-1]]
    Else
        This is build time error

GatherMode::kELEMENT:
    The output dimensions match the dimensions of the indices tensor.

Data 和 Output 的类型必须相同,并且 Indices 应为 DataType::kINT32DataType::kINT64

Data 元素的 gather 方式取决于模式

GatherMode::kDEFAULT:
    Each index in indices is used to index Data along axis gatherAxis.

GatherMode::kND:
    Indices is a rank q integer tensor, best thought of as a rank (q-1) tensor of
    indices into data, where each element defines a slice of data
    The operation can be formulated as output[i_1, ..., i_{q-1}] = data[indices[i_1, ..., i_{q-1}]]

GatherMode::kELEMENT:

    Here "axis" denotes the result of getGatherAxis().
    For each element X of indices:
        Let J denote a sequence for the subscripts of X
        Let K = sequence J with element [axis] replaced by X
        output[J] = data[K]

nbElementWiseDims 的处理取决于模式

注释

  • 对于模式 GatherMode::kNDGatherMode::kELEMENT,data 和 index 的前 nbElementWiseDims 维度必须相等。否则,将在构建时或运行时报告错误。
  • 如果 Data 的轴具有动态长度,则对其使用负索引具有未定义的行为。
  • 不支持 DLA
  • 对于 OOB 访问,将存储零
警告
请勿从此类继承,因为这样做会破坏 API 和 ABI 的向前兼容性。

构造函数 & 析构函数文档

◆ ~IGatherLayer()

virtual nvinfer1::IGatherLayer::~IGatherLayer ( )
protectedvirtualdefaultnoexcept

成员函数文档

◆ getGatherAxis()

int32_t nvinfer1::IGatherLayer::getGatherAxis ( ) const
inlinenoexcept

获取要进行 gather 操作的轴。

警告
GatherMode::kND 一起使用时,行为未定义。
另请参阅
setGatherAxis()

◆ getMode()

GatherMode nvinfer1::IGatherLayer::getMode ( ) const
inlinenoexcept

获取 gather 模式。

另请参阅
setMode()

◆ getNbElementWiseDims()

int32_t nvinfer1::IGatherLayer::getNbElementWiseDims ( ) const
inlinenoexcept

获取 indices 张量的要逐元素处理的前导维度数。

另请参阅
setNbElementWiseDims()

◆ setGatherAxis()

void nvinfer1::IGatherLayer::setGatherAxis ( int32_t  axis)
inlinenoexcept

设置 GatherMode::kELEMENTS 和 GatherMode::kDEFAULT 使用的轴。该轴必须小于数据输入中的维度数。轴默认为 0。

警告
GatherMode::kND 一起使用时,行为未定义。
另请参阅
getGatherAxis()

◆ setMode()

void nvinfer1::IGatherLayer::setMode ( GatherMode  mode)
inlinenoexcept

设置 gather 模式。

另请参阅
getMode()

◆ setNbElementWiseDims()

void nvinfer1::IGatherLayer::setNbElementWiseDims ( int32_t  elementWiseDims)
inlinenoexcept

设置 indices 张量的要逐元素处理的前导维度数。

索引的 gather 操作从 data[NbElementWiseDims:] 的维度开始。NbElementWiseDims 必须小于数据输入的秩。

参数
elementWiseDims要作为 elementwise 处理的维度数。

默认值:0

nbElementWiseDims 和 GatherMode 的值在网络验证期间进行检查

GatherMode::kDEFAULT: nbElementWiseDims 可以为 0 或 1。GatherMode::kND: nbElementWiseDims 可以介于 0 和 rank(data) 减 1 之间。GatherMode::kELEMENT: nbElementWiseDims 必须为 0

另请参阅
getNbElementWiseDims()

成员数据文档

◆ mImpl

apiv::VGatherLayer* nvinfer1::IGatherLayer::mImpl
protected

此类文档从以下文件生成:

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