An ILoopOutputLayer is the sole way to get output from a loop.
The first input tensor must be defined inside the loop; the output tensor is outside the loop. The second input tensor, if present, must be defined outside the loop.
If getLoopOutput() is kLAST_VALUE, a single input must be provided, and that input must from a IRecurrenceLayer in the same loop.
If getLoopOutput() is kCONCATENATE or kREVERSE, a second input must be provided. The second input must be a scalar “shape tensor”, defined before the loop commences, that specifies the concatenation length of the output.
The output tensor has j more dimensions than the input tensor, where j == 0 if getLoopOutput() is kLAST_VALUE j == 1 if getLoopOutput() is kCONCATENATE or kREVERSE.
virtual void nvinfer1::ILoopOutputLayer::setAxis |
( |
int32_t |
axis | ) |
|
|
pure virtualnoexcept |
Set where to insert the contenation axis.
Ignored if getLoopOutput() is kLAST_VALUE.
For example, if the input tensor has dimensions [b,c,d], and getLoopOutput() is kCONCATENATE, the output has four dimensions. Let a be the value of the second input. setAxis(0) causes the output to have dimensions [a,b,c,d]. setAxis(1) causes the output to have dimensions [b,a,c,d]. setAxis(2) causes the output to have dimensions [b,c,a,d]. setAxis(3) causes the output to have dimensions [b,c,d,a]. Default is axis is 0.
void nvinfer1::ILoopOutputLayer::setInput |
( |
int32_t |
index, |
|
|
ITensor & |
tensor |
|
) |
| |
|
pure virtual |
Append or replace an input of this layer with a specific tensor.
- Parameters
-
index | the index of the input to modify. |
tensor | the new input tensor Sets the input tensor for the given index. The index must be 0 for a kLAST_VALUE loop output layer. Loop output layer is converted to a kCONCATENATE or kREVERSE loop output layer by calling setInput with an index 1. A kCONCATENATE or kREVERSE loop output layer cannot be converted back to a kLAST_VALUE loop output layer. |
For a kCONCATENATE or kREVERSE loop output layer, the values 0 and 1 are valid. The indices in the kCONCATENATE or kREVERSE cases are as follows:
- 0: Contribution to the output tensor. The contribution must come from inside the loop.
- 1: The concatenation length scalar value, must come from outside the loop, as a 0D Int32 shape tensor.
If this function is called with a value 1, then the function getNbInputs() changes from returning 1 to 2.
Implements nvinfer1::ILayer.
virtual void nvinfer1::ILayer::setOutputType |
( |
int32_t |
index, |
|
|
DataType |
dataType |
|
) |
| |
|
pure virtualinherited |
Set the output type of this layer.
Setting the output type constrains TensorRT to choose implementations which generate output data with the given type. If it is not set, TensorRT will select output type based on layer computational precision. TensorRT could still choose non-conforming output type based on fastest implementation. Use BuilderFlag::kSTRICT_TYPES to force choose requested output type. In case layer precision is not specified, output type would depend on chosen implementation based on performance considerations and the flags specified to the builder.
This method cannot be used to set the data type of the second output tensor of the TopK layer. The data type of the second output tensor of the topK layer is always Int32. Also the output type of all layers that are shape operations must be DataType::kINT32, and all attempts to set the output type to some other data type will be ignored except for issuing an error message.
Note that the layer output type is generally not identical to the data type of the output tensor, as TensorRT may insert implicit reformatting operations to convert the former to the latter. Calling layer->setOutputType(i, type) has no effect on the data type of the i-th output tensor of layer, and users need to call layer->getOutput(i)->setType(type) to change the tensor data type. This is particularly relevant if the tensor is marked as a network output, since only setType() [but not setOutputType()] will affect the data representation in the corresponding output binding.
- Parameters
-
index | the index of the output to set |
dataType | the type of the output |
- See also
- getOutputType() outputTypeIsSet() resetOutputType()