TensorRT 10.8.0
|
基于偏移量和步幅将输入张量切片为输出张量。 更多...
#include <NvInfer.h>
公共成员函数 | |
void | setStart (Dims const &start) noexcept |
设置切片层用于创建输出切片的起始偏移量。 更多... | |
Dims | getStart () const noexcept |
获取切片层的起始偏移量。 更多... | |
void | setSize (Dims const &size) noexcept |
设置输出切片的维度。 更多... | |
Dims | getSize () const noexcept |
获取输出切片的维度。 更多... | |
void | setStride (Dims const &stride) noexcept |
设置用于计算输出切片数据的步幅。 更多... | |
Dims | getStride () const noexcept |
获取输出切片的步幅。 更多... | |
void | setMode (SampleMode mode) noexcept |
设置切片模式。 更多... | |
SampleMode | getMode () const noexcept |
获取切片模式。 更多... | |
void | setAxes (Dims const &axes) noexcept |
为此 ISliceLayer 设置轴。 更多... | |
Dims | getAxes () const noexcept |
获取此 ISliceLayer 的轴。 更多... | |
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 | ~ISliceLayer () 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::VSliceLayer * | mImpl |
![]() | |
apiv::VLayer * | mLayer |
基于偏移量和步幅将输入张量切片为输出张量。
切片层有两种变体:静态和动态。静态切片在层创建时通过 Dims 指定起始、大小和步幅维度,并且可以使用 ISliceLayer 的 get/set 访问器函数。静态切片层还可以选择性地通过 ISliceLayer 的 get/set 访问器函数指定轴。动态切片通过使用 ILayer::setInput 添加第二个、第三个、第四个或第六个输入,从而将起始、大小、步幅或轴中的一个或多个指定为 ITensor。如果输入缺失或为空,则使用相应的 Dims。
应用程序可以根据大小或轴输入是否存在且非空来确定 ISliceLayer 是否具有动态输出形状。
切片层为每个维度从输入张量中选择一个起始位置,并使用指定的步幅跨输入张量将元素复制到输出张量。如果未通过 Dims 指定,则起始、大小和步幅张量必须是 Int32 或 Int64 类型的 1D 张量。
在张量上使用切片的示例:输入 = {{0, 2, 4}, {1, 3, 5}} 起始 = {1, 0} 大小 = {1, 2} 步幅 = {1, 2} 输出 = {{1, 5}}
如果提供了轴,则起始、结束和步幅必须与轴的长度相同,并指定要切片的维度子集。如果未提供轴,则起始、结束和步幅的长度必须与输入张量的秩相同。
在使用轴指定的张量上使用切片的示例:输入 = {{0, 2, 4}, {1, 3, 5}} 起始 = {1} 大小 = {2} 步幅 = {1} 轴 = {1} 输出 = {{2, 4}, {3, 5}}
当 sampleMode 为 kCLAMP 或 kREFLECT 时,对于每个输入维度,如果其大小为 0,则相应的输出维度也必须为 0。
当 sampleMode 为 kFILL 时,切片层的第五个输入用于确定要填充超出边界索引的值。在任何其他 sampleMode 中指定第五个输入都是错误的。
如果满足以下条件,则切片层可以生成形状张量
如果输出是形状张量,则输入张量是形状张量。
必须满足以下约束才能在 DLA 上执行此层
|
protectedvirtualdefaultnoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
获取切片模式。
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
为此层追加或替换特定张量的输入。
index | 要修改的输入的索引。 |
tensor | 新的输入张量 |
对于切片层,值 0-4 有效。索引如下:
使用相应的 setter 会将输入重置为空。
如果使用大于 0 的值调用此函数,则函数 getNbInputs() 从返回 1 更改为 index + 1。
|
inlinenoexcept |
设置切片模式。
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
protected |
版权所有 © 2024 NVIDIA Corporation
隐私政策 | 管理我的隐私 | 请勿出售或分享我的数据 | 服务条款 | 无障碍功能 | 公司政策 | 产品安全 | 联系我们