|
TensorRT 10.8.0
|
网络定义中的 Gather 层。支持多种类型的 gathering。(收集)。更多...
#include <NvInfer.h>
公共成员函数 | |
| 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 |
| 获取层的输入数量。更多... | |
| 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 | ~IGatherLayer () noexcept=default |
继承自 nvinfer1::ILayer 的受保护成员函数 | |
| virtual | ~ILayer () noexcept=default |
继承自 nvinfer1::INoCopy 的受保护成员函数 | |
| 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::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::kINT32 或 DataType::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 的处理取决于模式
注释
|
protectedvirtualdefaultnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
获取 gather 模式。
|
inlinenoexcept |
获取 indices 张量的要逐元素处理的前导维度数。
|
inlinenoexcept |
设置 GatherMode::kELEMENTS 和 GatherMode::kDEFAULT 使用的轴。该轴必须小于数据输入中的维度数。轴默认为 0。
|
inlinenoexcept |
设置 gather 模式。
|
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
|
protected |
版权所有 © 2024 NVIDIA Corporation
隐私政策 | 管理我的隐私 | 请勿出售或分享我的数据 | 服务条款 | 无障碍访问 | 公司政策 | 产品安全 | 联系我们