|
TensorRT 10.12.0
|
A Gather layer in a network definition. Supports several kinds of gathering. More...
#include <NvInfer.h>
Public Member Functions | |
| void | setGatherAxis (int32_t axis) noexcept |
| Set the axis used by GatherMode::kELEMENTS and GatherMode::kDEFAULT The axis must be less than the number of dimensions in the data input. The axis defaults to 0. More... | |
| int32_t | getGatherAxis () const noexcept |
| Get the axis to gather on. More... | |
| void | setNbElementWiseDims (int32_t elementWiseDims) noexcept |
| Set the number of leading dimensions of indices tensor to be handled elementwise. More... | |
| int32_t | getNbElementWiseDims () const noexcept |
| Get the number of leading dimensions of indices tensor to be handled elementwise. More... | |
| void | setMode (GatherMode mode) noexcept |
| Set the gather mode. More... | |
| GatherMode | getMode () const noexcept |
| Get the gather mode. More... | |
Public Member Functions inherited from nvinfer1::ILayer | |
| LayerType | getType () const noexcept |
| Return the type of a layer. More... | |
| void | setName (char const *name) noexcept |
| Set the name of a layer. More... | |
| char const * | getName () const noexcept |
| Return the name of a layer. More... | |
| int32_t | getNbInputs () const noexcept |
| Get the number of inputs of a layer. More... | |
| ITensor * | getInput (int32_t index) const noexcept |
| Get the layer input corresponding to the given index. More... | |
| int32_t | getNbOutputs () const noexcept |
| Get the number of outputs of a layer. More... | |
| ITensor * | getOutput (int32_t index) const noexcept |
| Get the layer output corresponding to the given index. More... | |
| void | setInput (int32_t index, ITensor &tensor) noexcept |
| Replace an input of this layer with a specific tensor. More... | |
| TRT_DEPRECATED void | setPrecision (DataType dataType) noexcept |
| Set the preferred or required computational precision of this layer in a weakly-typed network. More... | |
| DataType | getPrecision () const noexcept |
| get the computational precision of this layer More... | |
| TRT_DEPRECATED bool | precisionIsSet () const noexcept |
| whether the computational precision has been set for this layer More... | |
| TRT_DEPRECATED void | resetPrecision () noexcept |
| reset the computational precision for this layer More... | |
| TRT_DEPRECATED void | setOutputType (int32_t index, DataType dataType) noexcept |
| Set the output type of this layer in a weakly-typed network. More... | |
| DataType | getOutputType (int32_t index) const noexcept |
| get the output type of this layer More... | |
| TRT_DEPRECATED bool | outputTypeIsSet (int32_t index) const noexcept |
| whether the output type has been set for this layer More... | |
| TRT_DEPRECATED void | resetOutputType (int32_t index) noexcept |
| reset the output type for this layer More... | |
| void | setMetadata (char const *metadata) noexcept |
| Set the metadata for this layer. More... | |
| char const * | getMetadata () const noexcept |
| Get the metadata of the layer. More... | |
Protected Member Functions | |
| virtual | ~IGatherLayer () noexcept=default |
Protected Member Functions inherited from nvinfer1::ILayer | |
| virtual | ~ILayer () noexcept=default |
Protected Member Functions inherited from 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 |
Protected Attributes | |
| apiv::VGatherLayer * | mImpl |
Protected Attributes inherited from nvinfer1::ILayer | |
| apiv::VLayer * | mLayer |
A Gather layer in a network definition. Supports several kinds of gathering.
The Gather layer has two input tensors, Data and Indices, and an output tensor Output. Additionally, there are three parameters: mode, nbElementwiseDims, and axis that control how the indices are interpreted.
The dimensions of the output likewise depends on the mode:
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.
The types of Data and Output must be the same, and Indices shall be DataType::kINT32 or DataType::kINT64.
How the elements of Data are gathered depends on the mode:
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]
The handling of nbElementWiseDims depends on the mode:
Notes:
|
protectedvirtualdefaultnoexcept |
|
inlinenoexcept |
Get the axis to gather on.
|
inlinenoexcept |
Get the gather mode.
|
inlinenoexcept |
Get the number of leading dimensions of indices tensor to be handled elementwise.
|
inlinenoexcept |
Set the axis used by GatherMode::kELEMENTS and GatherMode::kDEFAULT The axis must be less than the number of dimensions in the data input. The axis defaults to 0.
|
inlinenoexcept |
Set the gather mode.
|
inlinenoexcept |
Set the number of leading dimensions of indices tensor to be handled elementwise.
The gathering of indexing starts from the dimension of data[NbElementWiseDims:]. The NbElementWiseDims must be less than the Rank of the data input.
| elementWiseDims | number of dims to be handled as elementwise. |
Default: 0
The value of nbElementWiseDims and GatherMode are checked during network validation:
GatherMode::kDEFAULT: nbElementWiseDims can be 0 or 1. GatherMode::kND: nbElementWiseDims can be between 0 and one less than rank(data). GatherMode::kELEMENT: nbElementWiseDims must be 0
|
protected |
Copyright © 2024 NVIDIA Corporation
Privacy Policy |
Manage My Privacy |
Do Not Sell or Share My Data |
Terms of Service |
Accessibility |
Corporate Policies |
Product Security |
Contact