tensorrt.infer¶
The infer
package contains an interface for libnvinfer. This module is used for graph definition,
engine building and inference execution.
Foundational Types¶
Weights¶
-
class
tensorrt.infer.
Weights
¶ An array of weights used as a layer parameter.
The weights are held by reference until the engine has been built. Therefore the data referenced by values field should be preserved until the build is complete.
-
* `type`
DataType – The type of the weights.
-
* `values`
const void * – The weight values, in a contiguous array.
-
* `count`
int64_t – The number of weights in the array.
-
C++ includes
NvInfer.h
-
count
¶
-
type
¶
-
values
¶
-
Dims¶
-
class
tensorrt.infer.
Dims
¶ Structure to define the dimensions of a tensor.
note: : Currently the following formats are supported for layer inputs and outputs:
- zero or more index dimensions followed by one channel and two spatial dimensions (e.g. CHW)
- one time series dimension followed by one index dimension followed by one channel dimension (i.e. TNC)
-
* `MAX_DIMS`
const int – The maximum number of dimensions supported for a tensor.
-
* `nbDims`
int – The number of dimensions.
-
* `d`
int – The extent of each dimension.
-
* `type`
DimensionType – The type of each dimension.
-
C++ includes
NvInfer.h
-
d
¶
-
nbDims
¶
-
type
¶
DimsHW¶
DimsCHW¶
-
class
tensorrt.infer.
DimsCHW
¶ Descriptor for data with one channel dimension and two spatial dimensions.
C++ includes: NvInfer.h
-
c
()¶ c() const -> int
Get the channel count.
Returns: Return type: The channel count.
-
h
()¶ h() const -> int
Get the height.
Returns: Return type: The height.
-
w
()¶ w() const -> int
Get the width.
Returns: Return type: The width.
-
DimsNCHW¶
-
class
tensorrt.infer.
DimsNCHW
¶ Descriptor for data with one index dimension, one channel dimension and two spatial dimensions.
C++ includes: NvInfer.h
-
c
()¶ c() const -> int
Get the channel count.
Returns: Return type: The channel count.
-
h
()¶ h() const -> int
Get the height.
Returns: Return type: The height.
-
n
()¶ n() const -> int
Get the index count.
Returns: Return type: The index count.
-
w
()¶ w() const -> int
Get the width.
Returns: Return type: The width.
-
Engine and Inference¶
Builder¶
-
class
tensorrt.infer.
Builder
¶ Builds an engine from a network definition.
C++ includes: NvInfer.h
-
build_cuda_engine
()¶ buildCudaEngine(nvinfer1::INetworkDefinition &network)=0 -> nvinfer1::ICudaEngine *
Build a CUDA engine from a network definition.
See also: INetworkDefinition ICudaEngine
-
create_network
()¶ createNetwork()=0 -> nvinfer1::INetworkDefinition *
Create a network definition object.
See also: INetworkDefinition
-
destroy
()¶ destroy()=0
Destroy this object.
-
get_average_find_iterations
()¶ getAverageFindIterations() const =0 -> int
Query the number of averaging iterations.
See also: setAverageFindIterations()
-
get_debug_sync
()¶ getDebugSync() const =0 -> bool
Query whether the builder will use debug synchronization.
See also: setDebugSync()
-
get_fp16_mode
()¶ getFp16Mode() const =0 -> bool
Query whether 16-bit kernels are permitted.
See also: setFp16Mode()
-
get_half2_mode
()¶ getHalf2Mode() const =0 -> bool
Query whether half2 mode is used.
See also: setHalf2Mode() Deprecated This function is superseded by getFp16Mode.
-
get_int8_mode
()¶ getInt8Mode() const =0 -> bool
Query whether Int8 mode is used.
See also: setInt8Mode()
-
get_max_batch_size
()¶ getMaxBatchSize() const =0 -> int
Get the maximum batch size.
Returns: - The maximum batch size.
- See also (setMaxBatchSize())
-
get_max_workspace_size
()¶ getMaxWorkspaceSize() const =0 -> std::size_t
Get the maximum workspace size.
Returns: - The maximum workspace size.
- See also (setMaxWorkspaceSize())
-
get_min_find_iterations
()¶ getMinFindIterations() const =0 -> int
Query the number of minimzation iterations.
See also: setMinFindIterations()
-
platform_has_fast_fp16
()¶ platformHasFastFp16() const =0 -> bool
Determine whether the platform has fast native fp16.
-
platform_has_fast_int8
()¶ platformHasFastInt8() const =0 -> bool
Determine whether the platform has fast native int8.
-
set_average_find_iterations
()¶ setAverageFindIterations(int avgFind)=0
Set the number of minimization iterations used when timing layers.
When timing layers, the builder minimizes over a set of average times for layer execution. This parameter controls the number of iterations used in averaging.
See also: getAverageFindIterations()
-
set_debug_sync
()¶ setDebugSync(bool sync)=0
Set whether the builder should use debug synchronization.
If this flag is true, the builder will synchronize after timing each layer, and report the layer name. It can be useful when diagnosing issues at build time.
-
set_fp16_mode
()¶ setFp16Mode(bool mode)=0
Set whether or not 16-bit kernels are permitted.
During engine build fp16 kernels will also be tried when this mode is enabled.
Parameters: - mode (*) – Whether 16-bit kernels are permitted.
- also (See) –
-
set_gpu_allocator
()¶ setGpuAllocator(IGpuAllocator *allocator)=0
Set the GPU allocator.
Parameters: - allocator (*) – Set the GPU allocator to be used by the builder. All GPU memory acquired will use this allocator. If NULL is passed, the default allocator will be used.
- Default (uses cudaMalloc/cudaFree.) –
- note (This allocator will be passed to any engines created via the builder; thus the lifetime of the allocator must span the lifetime of those engines as well as that of the builder. If nullptr is) – passed, the default allocator will be used.
-
set_half2_mode
()¶ setHalf2Mode(bool mode)=0
Set whether half2 mode is used.
half2 mode is a paired-image mode that is significantly faster for batch sizes greater than one on platforms with fp16 support.
Parameters: - mode (*) – Whether half2 mode is used.
- also (See) –
- Deprecated –
- function is superseded by setFp16Mode. (This) –
-
set_int8_calibrator
()¶ setInt8Calibrator(IInt8Calibrator *calibrator)=0
Set Int8 Calibration interface.
-
set_int8_mode
()¶ setInt8Mode(bool mode)=0
Set the maximum value for a region.
Used for INT8 mode compression.
-
set_max_batch_size
()¶ setMaxBatchSize(int batchSize)=0
Set the maximum batch size.
Parameters: - batchSize (*) – The maximum batch size which can be used at execution time, and also the batch size for which the engine will be optimized.
- also (See) –
-
set_max_workspace_size
()¶ setMaxWorkspaceSize(std::size_t workspaceSize)=0
Set the maximum workspace size.
Parameters: - workspaceSize (*) – The maximum GPU temporary memory which the engine can use at execution time.
- also (See) –
-
set_min_find_iterations
()¶ setMinFindIterations(int minFind)=0
Set the number of minimization iterations used when timing layers.
When timing layers, the builder minimizes over a set of average times for layer execution. This parameter controls the number of iterations used in minimzation.
See also: getMinFindIterations()
-
CudaEngine¶
-
class
tensorrt.infer.
CudaEngine
¶ An engine for executing inference on a built network.
C++ includes: NvInfer.h
-
binding_is_input
()¶ bindingIsInput(int bindingIndex) const =0 -> bool
Determine whether a binding is an input binding.
Parameters: bindingIndex (*) – The binding index. Returns: - True if the index corresponds to an input binding and the index is in range.
- See also (getBindingIndex())
-
create_execution_context
()¶ createExecutionContext()=0 -> IExecutionContext *
Create an execution context.
See also: IExecutionContext.
-
create_execution_context_without_device_memory
()¶ createExecutionContextWithoutDeviceMemory()=0 -> IExecutionContext *
create an execution context without any device memory allocated
The memory for execution of this device context must be supplied by the application.
See also: getDeviceMemorySize() IExecutionContext::setDeviceMemory()
-
destroy
()¶ destroy()=0
Destroy this object;.
-
get_binding_data_type
()¶ getBindingDataType(int bindingIndex) const =0 -> DataType
Determine the required data type for a buffer from its binding index.
Parameters: bindingIndex (*) – The binding index. Returns: - The type of the data in the buffer.
- See also (getBindingIndex())
-
get_binding_dimensions
()¶ getBindingDimensions(int bindingIndex) const =0 -> Dims
Get the dimensions of a binding.
Parameters: bindingIndex (*) – The binding index. Returns: - The dimensions of the binding if the index is in range, otherwise (0,0,0).
- See also (getBindingIndex())
-
get_binding_index
()¶ getBindingIndex(const char *name) const =0 -> int
Retrieve the binding index for a named tensor.
IExecutionContext::enqueue() and IExecutionContext::execute() require an array of buffers.
Engine bindings map from tensor names to indices in this array. Binding indices are assigned at engine build time, and take values in the range [0 … n-1] where n is the total number of inputs and outputs.
Parameters: name (*) – The tensor name. Returns: - The binding index for the named tensor, or -1 if the name is not found.
- see getNbBindings() getBindingIndex()
-
get_binding_name
()¶ getBindingName(int bindingIndex) const =0 -> const char *
Retrieve the name corresponding to a binding index.
This is the reverse mapping to that provided by getBindingIndex().
Parameters: bindingIndex (*) – The binding index. Returns: - The name corresponding to the index, or nullptr if the index is out of range.
- See also (getBindingIndex())
-
get_device_memory_size
()¶ getDeviceMemorySize() const =0 -> size_t
Return the amount of device memory required by an execution context.
See also: IExecutionContext::setDeviceMemory()
-
get_location
()¶ getLocation(int bindingIndex) const =0 -> TensorLocation
Get location of binding.
This lets you know whether the binding should be a pointer to device or host memory.
See also: ITensor::setLocation() ITensor::getLocation()
Parameters: bindingIndex (*) – The binding index. Returns: Return type: The location of the bound tensor with given index.
-
get_max_batch_size
()¶ getMaxBatchSize() const =0 -> int
Get the maximum batch size which can be used for inference.
Returns: - The maximum batch size for this engine.
- See also (getBindingIndex())
-
get_nb_bindings
()¶ getNbBindings() const =0 -> int
Get the number of binding indices.
See also: getBindingIndex();
-
get_nb_layers
()¶ getNbLayers() const =0 -> int
Get the number of layers in the network.
The number of layers in the network is not necessarily the number in the original network definition, as layers may be combined or eliminated as the engine is optimized. This value can be useful when building per-layer tables, such as when aggregating profiling data over a number of executions.
Returns: Return type: The number of layers in the network.
-
get_workspace_size
()¶ getWorkspaceSize() const =0 -> std::size_t
Get the amount of workspace the engine uses.
The workspace size will be no greater than the value provided to the builder when the engine was built, and will typically be smaller. Workspace will be allocated for each execution context.
-
serialize
()¶ serialize() const =0 -> IHostMemory *
Serialize the network to a stream.
Returns: - A IHostMemory object that contains the serialized engine.
- The network may be deserialized with IRuntime::deserializeCudaEngine()
- See also (IRuntime::deserializeCudaEngine())
-
ExecutionContext¶
-
class
tensorrt.infer.
ExecutionContext
¶ Context for executing inference using an engine.
Multiple execution contexts may exist for one ICudaEngine instance, allowing the same engine to be used for the execution of multiple batches simultaneously.
C++ includes: NvInfer.h
-
destroy
()¶ destroy()=0
Destroy this object.
-
enqueue
()¶ enqueue(int batchSize, void **bindings, cudaStream_t stream, cudaEvent_t *inputConsumed)=0 -> bool
Asynchronously execute inference on a batch.
This method requires a array of input and output buffers. The mapping from tensor names to indices can be queried using ICudaEngine::getBindingIndex()
Parameters: - batchSize (*) – The batch size. This is at most the value supplied when the engine was built.
- bindings (*) – An array of pointers to input and output buffers for the network.
- stream (*) – A cuda stream on which the inference kernels will be enqueued
- inputConsumed (*) – An optional event which will be signaled when the input buffers can be refilled with new data
Returns: - True if the kernels were enqueued successfully.
- See also (ICudaEngine::getBindingIndex() ICudaEngine::getMaxBatchSize())
-
execute
()¶ execute(int batchSize, void **bindings)=0 -> bool
Synchronously execute inference on a batch.
This method requires a array of input and output buffers. The mapping from tensor names to indices can be queried using ICudaEngine::getBindingIndex()
Parameters: - batchSize (*) – The batch size. This is at most the value supplied when the engine was built.
- bindings (*) – An array of pointers to input and output buffers for the network.
Returns: - True if execution succeeded.
- See also (ICudaEngine::getBindingIndex() ICudaEngine::getMaxBatchSize())
-
get_debug_sync
()¶ getDebugSync() const =0 -> bool
Get the debug sync flag.
See also: setDebugSync()
-
get_engine
()¶ getEngine() const =0 -> const ICudaEngine &
Get the associated engine.
See also: ICudaEngine
-
get_name
()¶ getName() const =0 -> const char *
Return the name of the execution context.
See also: setName()
-
get_profiler
()¶ getProfiler() const =0 -> IProfiler *
Get the profiler.
See also: IProfiler setProfiler()
-
set_debug_sync
()¶ setDebugSync(bool sync)=0
Set the debug sync flag.
If this flag is set to true, the engine will log the successful execution for each kernel during execute(). It has no effect when using enqueue().
See also: getDebugSync()
-
set_device_memory
()¶ setDeviceMemory(void *memory)=0
set the device memory for use by this execution context.
The memory must be aligned on a 256-byte boundary, and its size must be at least that returned by getDeviceMemorySize(). If using enqueue() to run the network, The memory is in use from the invocation of enqueue() until network execution is complete. If using execute(), it is in use until execute() returns. Releasing or otherwise using the memory for other purposes during this time will result in undefined behavior.
See also: ICudaEngine::getDeviceMemorySize() ICudaEngine::createExecutionContextWithoutDeviceMemory()
-
set_name
()¶ setName(const char *name)=0
Set the name of the execution context.
This method copies the name string.
See also: getName()
-
set_profiler
()¶ setProfiler(IProfiler *)=0
Set the profiler.
See also: IProfiler getProfiler()
-
Runtime¶
-
class
tensorrt.infer.
Runtime
¶ Allows a serialized engine to be deserialized.
C++ includes: NvInfer.h
-
deserialize_cuda_engine
()¶ deserializeCudaEngine(const void *blob, std::size_t size, IPluginFactory *pluginFactory)=0 -> nvinfer1::ICudaEngine *
Deserialize an engine from a stream.
Parameters: - blob (*) – The memory that holds the serialized engine.
- size (*) – The size of the memory.
- pluginFactory (*) – The plugin factory, if any plugins are used by the network, otherwise nullptr.
Returns: Return type: The engine, or nullptr if it could not be deserialized.
-
destroy
()¶ destroy()=0
Destroy this object.
-
set_gpu_allocator
()¶ setGpuAllocator(IGpuAllocator *allocator)=0
Set the GPU allocator.
Parameters: - allocator (*) – Set the GPU allocator to be used by the runtime. All GPU memory acquired will use this allocator. If NULL is passed, the default allocator will be used.
- Default (uses cudaMalloc/cudaFree.) –
- nullptr is passed, the default allocator will be used. (If) –
-
HostMemory¶
-
class
tensorrt.infer.
HostMemory
¶ Class to handle library allocated memory that is accessible to the user.
The memory allocated via the host memory object is owned by the library and will be de-allocated when the destroy method is called.
C++ includes: NvInfer.h
-
data
()¶ data() const =0 -> void *
A pointer to the raw data that is owned by the library.
-
destroy
()¶ destroy()=0
Destroy the allocated memory.
-
size
()¶ size() const =0 -> std::size_t
The size in bytes of the data that was allocated.
-
type
()¶ type() const =0 -> DataType
The type of the memory that was allocated.
-
Graph Definition¶
NetworkDefinition¶
-
class
tensorrt.infer.
NetworkDefinition
¶ A network definition for input to the builder.
C++ includes: NvInfer.h
-
add_activation
()¶ addActivation(ITensor &input, ActivationType type)=0 -> IActivationLayer *
Add an activation layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- type (*) – The type of activation function to apply.
- also (See) –
Returns: Return type: The new activation layer, or null if it could not be created.
-
add_concatenation
()¶ addConcatenation(ITensor *const *inputs, int nbInputs)=0 -> IConcatenationLayer *
Add a concatenation layer to the network.
Parameters: - inputs (*) – The input tensors to the layer.
- nbInputs (*) – The number of input tensors.
- also (See) –
Returns: - The new concatenation layer, or null if it could not be created.
- **Warning** (All tensors must have the same dimensions for all dimensions except for channel.)
-
add_constant
()¶ addConstant(Dims dimensions, Weights weights)=0 -> IConstantLayer *
Add a constant layer to the network.
Parameters: - dimensions (*) – The dimensions of the constant.
- weights (*) – The constant value, represented as weights.
- also (See) –
Returns: Return type: The new constant layer, or null if it could not be created.
-
add_convolution
()¶ addConvolution(ITensor &input, int nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights)=0 -> IConvolutionLayer *
Add a convolution layer to the network.
Parameters: - input (*) – The input tensor to the convolution.
- nbOutputMaps (*) – The number of output feature maps for the convolution.
- kernelSize (*) – The HW-dimensions of the convolution kernel.
- kernelWeights (*) – The kernel weights for the convolution.
- biasWeights (*) – The optional bias weights for the convolution.
- also (See) –
Returns: Return type: The new convolution layer, or null if it could not be created.
-
add_deconvolution
()¶ addDeconvolution(ITensor &input, int nbOutputMaps, DimsHW kernelSize, Weights kernelWeights, Weights biasWeights)=0 -> IDeconvolutionLayer *
Add a deconvolution layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- nbOutputMaps (*) – The number of output feature maps.
- kernelSize (*) – The HW-dimensions of the convolution kernel.
- kernelWeights (*) – The kernel weights for the convolution.
- biasWeights (*) – The optional bias weights for the convolution.
- also (See) –
Returns: Return type: The new deconvolution layer, or null if it could not be created.
-
add_element_wise
()¶ addElementWise(ITensor &input1, ITensor &input2, ElementWiseOperation op)=0 -> IElementWiseLayer *
Add an elementwise layer to the network.
Parameters: - input1 (*) – The first input tensor to the layer.
- input2 (*) – The second input tensor to the layer.
- op (*) – The binary operation that the layer applies.
- also (See) –
Returns: Return type: The new elementwise layer, or null if it could not be created.
-
add_fully_connected
()¶ addFullyConnected(ITensor &input, int nbOutputs, Weights kernelWeights, Weights biasWeights)=0 -> IFullyConnectedLayer *
Add a fully connected layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- nbOutputs (*) – The number of outputs of the layer.
- kernelWeights (*) – The kernel weights for the convolution.
- biasWeights (*) – The optional bias weights for the convolution.
- also (See) –
Returns: Return type: The new fully connected layer, or null if it could not be created.
-
add_gather
()¶ addGather(ITensor &data, ITensor &indices, int axis)=0 -> IGatherLayer *
Add a gather layer to the network.
Parameters: - data (*) – The tensor to gather values from.
- indices (*) – The tensor to get indices from to populate the output tensor.
- axis (*) – The non-batch dimension axis in the data tensor to gather on.
- also (See) –
Returns: Return type: The new gather layer, or null if it could not be created.
-
add_input
()¶ addInput(const char *name, DataType type, Dims dimensions)=0 -> ITensor *
Add an input tensor to the network.
The name of the input tensor is used to find the index into the buffer array for an engine built from the network.
Parameters: - name (*) – The name of the tensor.
- type (*) – The type of the data held in the tensor.
- dimensions (*) – The dimensions of the tensor.
:param Only DataType::kFLOAT and DataType::kHALF are valid input tensor types. The volume of the dimension, including the maximum batch size, must be less than 2^30 elements.: :param See also: :type See also: ITensor
Returns: Return type: The new tensor or nullptr if there is an error.
-
add_lrn
()¶ addLRN(ITensor &input, int window, float alpha, float beta, float k)=0 -> ILRNLayer *
Add a LRN layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- window (*) – The size of the window.
- alpha (*) – The alpha value for the LRN computation.
- beta (*) – The beta value for the LRN computation.
- k (*) – The k value for the LRN computation.
- also (See) –
Returns: Return type: The new LRN layer, or null if it could not be created.
-
add_matrix_multiply
()¶ addMatrixMultiply(ITensor &input0, bool transpose0, ITensor &input1, bool transpose1)=0 -> IMatrixMultiplyLayer *
Add a MatrixMultiply layer to the network.
Parameters: - input0 (*) – The first input tensor (commonly A).
- transpose0 (*) – If true, op(input0)=transpose(input0), else op(input0)=input0.
- input1 (*) – The second input tensor (commonly B).
- transpose1 (*) – If true, op(input1)=transpose(input1), else op(input1)=input1.
- also (See) –
Returns: Return type: The new matrix multiply layer, or null if it could not be created.
-
add_padding
()¶ addPadding(ITensor &input, DimsHW prePadding, DimsHW postPadding)=0 -> IPaddingLayer *
Add a padding layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- prePadding (*) – The padding to apply to the start of the tensor.
- postPadding (*) – The padding to apply to the end of the tensor.
- also (See) –
Returns: Return type: the new padding layer, or null if it could not be created.
-
add_plugin
()¶ addPlugin(ITensor *const *inputs, int nbInputs, IPlugin &plugin)=0 -> IPluginLayer *
Add a plugin layer to the network.
Parameters: - inputs (*) – The input tensors to the layer.
- nbInputs (*) – The number of input tensors.
- plugin (*) – The layer plugin.
- also (See) –
Returns: Return type: the new plugin layer, or null if it could not be created.
-
add_plugin_ext
()¶ addPluginExt(ITensor *const *inputs, int nbInputs, IPluginExt &plugin)=0 -> IPluginLayer *
Add a plugin layer to the network using an IPluginExt interface.
Parameters: - inputs (*) – The input tensors to the layer.
- nbInputs (*) – The number of input tensors.
- plugin (*) – The layer plugin.
- also (See) –
Returns: Return type: The new plugin layer, or null if it could not be created.
-
add_pooling
()¶ addPooling(ITensor &input, PoolingType type, DimsHW windowSize)=0 -> IPoolingLayer *
Add a pooling layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- type (*) – The type of pooling to apply.
- windowSize (*) – The size of the pooling window.
- also (See) –
Returns: Return type: The new pooling layer, or null if it could not be created.
-
add_ragged_soft_max
()¶ addRaggedSoftMax(ITensor &input, ITensor &bounds)=0 -> IRaggedSoftMaxLayer *
Add a RaggedSoftMax layer to the network.
Parameters: - input (*) – The ZxS input tensor.
- bounds (*) – The Zx1 bounds tensor.
- also (See) –
Returns: Return type: The new RaggedSoftMax layer, or null if it could not be created.
-
add_reduce
()¶ addReduce(ITensor &input, ReduceOperation operation, uint32_t reduceAxes, bool keepDimensions)=0 -> IReduceLayer *
Add a reduce layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- operation (*) – The reduction operation to perform.
- reduceAxes (*) – The reduction dimensions. Bit 0 of the uint32_t type corresponds to the non-batch dimension 0 boolean and so on. If a bit is set, then the corresponding dimension will be reduced. Let’s say we have an NCHW tensor as input (three non-batch dimensions). Bit 0 corresponds to the C dimension boolean. Bit 1 corresponds to the H dimension boolean. Bit 2 corresponds to the W dimension boolean. Note that reduction is not permitted over the batch size dimension.
- keepDimensions (*) – The boolean that specifies whether or not to keep the reduced dimensions in the output of the layer.
- also (See) –
Returns: Return type: The new reduce layer, or null if it could not be created.
-
add_rnn
()¶ addRNN(ITensor &inputs, int layerCount, std::size_t hiddenSize, int maxSeqLen, RNNOperation op, RNNInputMode mode, RNNDirection dir, Weights weights, Weights bias)=0 -> IRNNLayer *
Add an layerCount deep RNN layer to the network with a sequence length of maxSeqLen and hiddenSize internal state per layer.
Parameters: - inputs (*) – The input tensor to the layer.
- layerCount (*) – The number of layers in the RNN.
- hiddenSize (*) – The size of the internal hidden state for each layer.
- maxSeqLen (*) – The maximum length of the time sequence.
- op (*) – The type of RNN to execute.
- mode (*) – The input mode for the RNN.
- dir (*) – The direction to run the RNN.
- weights (*) – The weights for the weight matrix parameters of the RNN.
- bias (*) – The weights for the bias vectors parameters of the RNN.
:param The input tensors must be of the type DataType::kFLOAT or DataType::kHALF.: :param See IRNNLayer::setWeights() and IRNNLayer::setBias() for details on the required input format for weights and bias.: :param The layout for the input tensor should be {1, S_max, N, E}, where: :param * S_max is the maximum allowed sequence length (number of RNN iterations): :param * N is the batch size: :param * E specifies the embedding length (unless kSKIP is set, in which case it should match getHiddenSize()).: :param The first output tensor is the output of the final RNN layer across all timesteps, with dimensions {S_max, N, H}: :param * S_max is the maximum allowed sequence length (number of RNN iterations): :param * N is the batch size: :param * H is an output hidden state (equal to getHiddenSize() or 2x getHiddenSize()): :param The second tensor is the final hidden state of the RNN across all layers, and if the RNN is an LSTM (i.e. getOperation() is kLSTM), then the third tensor is the final cell state of the RNN across all: :param layers. Both the second and third output tensors have dimensions {L, N, H}: :param * L is equal to getLayerCount() if getDirection is kUNIDIRECTION, and 2*getLayerCount() if getDirection is kBIDIRECTION. In the bi-directional case, layer l’s final forward hidden state is: stored in L = 2*l, and final backward hidden state is stored in L = 2*l + 1. :param * N is the batch size: :param * H is getHiddenSize().: :param Note that in bidirectional RNNs, the full “hidden state” for a layer l is the concatenation of its forward hidden state and its backward hidden state, and its size is 2*H.: :param Deprecated: :param IRNNLayer is superseded by IRNNv2Layer. Use addRNNv2() instead.:
Returns: - The new RNN layer, or null if it could not be created.
- See also (IRNNLayer)
-
add_rnnv2
()¶ addRNNv2(ITensor &input, int32_t layerCount, int32_t hiddenSize, int32_t maxSeqLen, RNNOperation op)=0 -> IRNNv2Layer *
Add an layerCount deep RNN layer to the network with hiddenSize internal states that can take a batch with fixed or variable sequence lengths.
Parameters: - input (*) – The input tensor to the layer (see below).
- layerCount (*) – The number of layers in the RNN.
- hiddenSize (*) – Size of the internal hidden state for each layer.
- maxSeqLen (*) – Maximum sequence length for the input.
- op (*) – The type of RNN to execute.
:param By default, the layer is configured with RNNDirection::kUNIDIRECTION and RNNInputMode::kLINEAR. To change these settings, use IRNNv2Layer::setDirection() and IRNNv2Layer::setInputMode().: :param Weights and biases for the added layer should be set using IRNNv2Layer::setWeightsForGate() and IRNNv2Layer::setBiasForGate() prior to building an engine using this network.: :param The input tensors must be of the type DataType::kFLOAT or DataType::kHALF. The layout of the weights is row major and must be the same datatype as the input tensor. weights contain 8 matrices and: :param bias contains 8 vectors.: :param See IRNNv2Layer::setWeightsForGate() and IRNNv2Layer::setBiasForGate() for details on the required input format for weights and bias.: :param The input ITensor should contain zero or more index dimensions {N1, …, Np}, followed by two dimensions, defined as follows: :param * S_max is the maximum allowed sequence length (number of RNN iterations): :param * E specifies the embedding length (unless kSKIP is set, in which case it should match getHiddenSize()).: :param By default, all sequences in the input are assumed to be size maxSeqLen. To provide explicit sequence lengths for each input sequence in the batch, use IRNNv2Layer::setSequenceLengths().: :param The RNN layer outputs up to three tensors.: :param The first output tensor is the output of the final RNN layer across all timesteps, with dimensions {N1, …, Np, S_max, H}: :param * N1..Np are the index dimensions specified by the input tensor: :param * S_max is the maximum allowed sequence length (number of RNN iterations): :param * H is an output hidden state (equal to getHiddenSize() or 2x getHiddenSize()): :param The second tensor is the final hidden state of the RNN across all layers, and if the RNN is an LSTM (i.e. getOperation() is kLSTM), then the third tensor is the final cell state of the RNN across all: :param layers. Both the second and third output tensors have dimensions {N1, …, Np, L, H}: :param * N1..Np are the index dimensions specified by the input tensor: :param * L is the number of layers in the RNN, equal to getLayerCount(): :param * H is the hidden state for each layer, equal to getHiddenSize() if getDirection is kUNIDIRECTION, and 2x getHiddenSize() otherwise.:
Returns: - The new RNN layer, or null if it could not be created.
- See also (IRNNv2Layer)
-
add_scale
()¶ addScale(ITensor &input, ScaleMode mode, Weights shift, Weights scale, Weights power)=0 -> IScaleLayer *
Add a Scale layer to the network.
Parameters: - input (*) – The input tensor to The layer. This tensor is required to have a minimum of 3 dimensions.
- mode (*) – The scaling mode.
- shift (*) – The shift value.
- scale (*) – The scale value.
- power (*) – The power value.
- the weights are available, then the size of weights are dependent on the on the ScaleMode. For kUNIFORM, the number of weights is equal to 1. For kCHANNEL, the number of weights is equal to the (If) –
- dimension. For kELEMENTWISE, the number of weights is equal to the volume of the input. (channel) –
- also (See) –
Returns: Return type: The new Scale layer, or null if it could not be created.
-
add_shuffle
()¶ addShuffle(ITensor &input)=0 -> IShuffleLayer *
Add a shuffle layer to the network.
Parameters: input (*) – The input tensor to the layer. Returns: Return type: The new shuffle layer, or null if it could not be created.
-
add_softmax
()¶ addSoftMax(ITensor &input)=0 -> ISoftMaxLayer *
Add a SoftMax layer to the network.
See also: ISoftMaxLayer
Returns: Return type: The new SoftMax layer, or null if it could not be created.
-
add_top_k
()¶ addTopK(ITensor &input, TopKOperation op, int k, uint32_t reduceAxes)=0 -> ITopKLayer *
Add a TopK layer to the network.
The TopK layer has two outputs of the same dimensions. The first contains data values, the second contains index positions for the values. Output values are sorted, largest first for operation kMAX and smallest first for operation kMIN.
Currently only values of K up to 1024 are supported.
Parameters: - input (*) – The input tensor to the layer.
- op (*) – Operation to perform.
- k (*) – Number of elements to keep.
- reduceAxes (*) – The reduction dimensions. Bit 0 of the uint32_t type corresponds to the non-batch dimension 0 boolean and so on. If a bit is set, then the corresponding dimension will be reduced. Let’s say we have an NCHW tensor as input (three non-batch dimensions). Bit 0 corresponds to the C dimension boolean. Bit 1 corresponds to the H dimension boolean. Bit 2 corresponds to the W dimension boolean. Note that TopK reduction is currently only permitted over one dimension.
-
add_unary
()¶ addUnary(ITensor &input, UnaryOperation operation)=0 -> IUnaryLayer *
Add a unary layer to the network.
Parameters: - input (*) – The input tensor to the layer.
- operation (*) – The operation to apply.
- also (See) –
Returns: Return type: The new unary layer, or null if it could not be created
-
destroy
()¶ destroy()=0
Destroy this INetworkDefinition object.
-
get_convolution_output_dimensions_formula
()¶ getConvolutionOutputDimensionsFormula() const =0 -> IOutputDimensionsFormula &
Get the convolution output dimensions formula.
Deprecated This method does not currently work reliably and will be removed in a future release.
Returns: - The formula from computing the convolution output dimensions.
- See also (IOutputDimensionsFormula setConvolutionOutputDimensionsFormula())
-
get_deconvolution_output_dimensions_formula
()¶ getDeconvolutionOutputDimensionsFormula() const =0 -> IOutputDimensionsFormula &
Get the deconvolution output dimensions formula.
Returns: - The formula from computing the deconvolution output dimensions.
- Deprecated
- This method does not currently work reliably and will be removed in a future release.
- See also (IOutputDimensionsFormula setDeconvolutionOutputDimensionsFormula())
-
get_input
()¶ getInput(int index) const =0 -> ITensor *
Get the input tensor specified by the given index.
Parameters: index (*) – The index of the input tensor. Returns: - The input tensor, or null if the index is out of range.
- See also (getNbInputs())
-
get_layer
()¶ getLayer(int index) const =0 -> ILayer *
Get the layer specified by the given index.
Parameters: index (*) – The index of the layer. Returns: - The layer, or null if the index is out of range.
- See also (getNbLayers())
-
get_nb_inputs
()¶ getNbInputs() const =0 -> int
Get the number of inputs in the network.
Returns: - The number of inputs in the network.
- See also (getInput())
-
get_nb_layers
()¶ getNbLayers() const =0 -> int
Get the number of layers in the network.
Returns: - The number of layers in the network.
- See also (getLayer())
-
get_nb_outputs
()¶ getNbOutputs() const =0 -> int
Get the number of outputs in the network.
Returns: - The number of outputs in the network.
- See also (getOutput())
-
get_output
()¶ getOutput(int index) const =0 -> ITensor *
Get the output tensor specified by the given index.
Parameters: index (*) – The index of the output tensor. Returns: - The output tensor, or null if the index is out of range.
- See also (getNbOutputs())
-
get_pooling_output_dimensions_formula
()¶ getPoolingOutputDimensionsFormula() const =0 -> IOutputDimensionsFormula &
Get the pooling output dimensions formula.
Returns: - The formula from computing the pooling output dimensions.
- See also (IOutputDimensionsFormula setPoolingOutputDimensionsFormula())
-
mark_output
()¶ markOutput(ITensor &tensor)=0
Mark a tensor as a network output.
Parameters: tensor (*) – The tensor to mark as an output tensor.
-
set_convolution_output_dimensions_formula
()¶ setConvolutionOutputDimensionsFormula(IOutputDimensionsFormula *formula)=0
Set the convolution output dimensions formula.
Deprecated This method does not currently work reliably and will be removed in a future release.
Parameters: - formula (*) – The formula from computing the convolution output dimensions. If null is passed, the default formula is used.
- default formula in each dimension is (inputDim + padding * 2 - kernelSize) / stride + 1. (The) –
- also (See) –
-
set_deconvolution_output_dimensions_formula
()¶ setDeconvolutionOutputDimensionsFormula(IOutputDimensionsFormula *formula)=0
Set the deconvolution output dimensions formula.
Deprecated This method does not currently work reliably and will be removed in a future release.
Parameters: - formula (*) – The formula from computing the deconvolution output dimensions. If null is passed, the default formula is used.
- default formula in each dimension is (inputDim - 1) * stride + kernelSize - 2 * padding. (The) –
- also (See) –
-
set_pooling_output_dimensions_formula
()¶ setPoolingOutputDimensionsFormula(IOutputDimensionsFormula *formula)=0
Set the pooling output dimensions formula.
Parameters: - formula (*) – The formula from computing the pooling output dimensions. If null is passed, the default formula is used.
- default formula in each dimension is (inputDim + padding * 2 - kernelSize) / stride + 1. (The) –
- also (See) –
-
Tensor¶
-
class
tensorrt.infer.
Tensor
¶ A tensor in a network definition.
C++ includes: NvInfer.h
-
get_broadcast_across_batch
()¶ getBroadcastAcrossBatch() const =0 -> bool
Check if tensor is broadcast across the batch.
When a tensor is broadcast across a batch, it has the same value for every member in the batch. Memory is only allocated once for the single member.
Returns: - True if tensor is broadcast across the batch, false otherwise.
- See also (setBroadcastAcrossBatch())
-
get_dimensions
()¶ getDimensions() const =0 -> Dims
Get the dimensions of a tensor.
Returns: - The dimensions of the layer.
- See also (setDimensions())
-
get_location
()¶ getLocation() const =0 -> TensorLocation
Get the storage location of a tensor.
Returns: - The location of tensor data.
- See also (setLocation())
-
get_name
()¶ getName() const =0 -> const char *
Get the tensor name.
Returns: - The name, as a pointer to a NULL-terminated character sequence.
- See also (setName())
-
get_type
()¶ getType() const =0 -> DataType
Get the data type of a tensor.
Returns: - The data type of the tensor.
- See also (setType())
-
is_network_input
()¶ isNetworkInput() const =0 -> bool
Whether the tensor is a network input.
-
is_network_output
()¶ isNetworkOutput() const =0 -> bool
Whether the tensor is a network output.
-
set_broadcast_across_batch
()¶ setBroadcastAcrossBatch(bool broadcastAcrossBatch)=0
Set whether to enable broadcast of tensor across the batch.
When a tensor is broadcast across a batch, it has the same value for every member in the batch. Memory is only allocated once for the single member.
This method is only valid for network input tensors, since the flags of layer output tensors are inferred based on layer inputs and parameters. If this state is modified for a tensor in the network, the states of all dependent tensors will be recomputed.
Parameters: - broadcastAcrossBatch (*) – Whether to enable broadcast of tensor across the batch.
- also (See) –
-
set_dimensions
()¶ setDimensions(Dims dimensions)=0
Set the dimensions of a tensor.
For a network input the name is assigned by the application. For a network output it is computed based on the layer parameters and the inputs to the layer. If a tensor size or a parameter is modified in the network, the dimensions of all dependent tensors will be recomputed.
This call is only legal for network input tensors, since the dimensions of layer output tensors are inferred based on layer inputs and parameters.
Parameters: - dimensions (*) – The dimensions of the tensor.
- also (See) –
-
set_location
()¶ setLocation(TensorLocation location)=0
Set the storage location of a tensor.
Parameters: - location (*) – the location of tensor data
- input tensors for storing sequence lengths for RNNv2 are supported. Using host storage for layers that do not support it will generate errors at build time. (Only) –
- also (See) –
-
set_name
()¶ setName(const char *name)=0
Set the tensor name.
For a network input, the name is assigned by the application. For tensors which are layer outputs, a default name is assigned consisting of the layer name followed by the index of the output in brackets.
This method copies the name string.
Parameters: - name (*) – The name.
- also (See) –
-
set_type
()¶ setType(DataType type)=0
Set the data type of a tensor.
Parameters: - type (*) – The data type of the tensor.
- type is unchanged if the type is invalid for the given tensor. (The) –
:param If the tensor is a network input or output, then the tensor type cannot be DataType::kINT8.: :param See also: :type See also: getType()
-
Layer¶
-
class
tensorrt.infer.
Layer
¶ Base class for all layer classes in a network definition.
C++ includes: NvInfer.h
-
get_input
()¶ getInput(int index) const =0 -> ITensor *
Get the layer input corresponding to the given index.
Parameters: index (*) – The index of the input tensor. Returns: Return type: The input tensor, or nullptr if the index is out of range.
-
get_name
()¶ getName() const =0 -> const char *
Return the name of a layer.
See also: setName()
-
get_nb_inputs
()¶ getNbInputs() const =0 -> int
Get the number of inputs of a layer.
-
get_nb_outputs
()¶ getNbOutputs() const =0 -> int
Get the number of outputs of a layer.
-
get_output
()¶ getOutput(int index) const =0 -> ITensor *
Get the layer output corresponding to the given index.
Returns: Return type: The indexed output tensor, or nullptr if the index is out of range.
-
get_type
()¶ getType() const =0 -> LayerType
Return the type of a layer.
See also: LayerType
-
set_name
()¶ setName(const char *name)=0
Set the name of a layer.
This method copies the name string.
See also: getName()
-
ConvolutionLayer¶
-
class
tensorrt.infer.
ConvolutionLayer
¶ A convolution layer in a network definition.
This layer performs a correlation operation between 3-dimensional filter with a 4-dimensional tensor to produce another 4-dimensional tensor.
The HW output size of the convolution is set according to the INetworkCustomDimensions set in INetworkDefinition::setCustomConvolutionDimensions().
An optional bias argument is supported, which adds a per-channel constant to each value in the output.
C++ includes: NvInfer.h
-
get_bias_weights
()¶ getBiasWeights() const =0 -> Weights
Get the bias weights for the convolution.
See also: setBiasWeights()
-
get_dilation
()¶ getDilation() const =0 -> DimsHW
Get the dilation for a convolution.
See also: setDilation()
-
get_kernel_size
()¶ getKernelSize() const =0 -> DimsHW
Get the HW kernel size of the convolution.
See also: setKernelSize()
-
get_kernel_weights
()¶ getKernelWeights() const =0 -> Weights
Get the kernel weights for the convolution.
See also: setKernelWeights()
-
get_nb_groups
()¶ getNbGroups() const =0 -> int
Set the number of groups for a convolution.
See also: setNbGroups()
-
get_nb_output_maps
()¶ getNbOutputMaps() const =0 -> int
Get the number of output maps for the convolution.
See also: setNbOutputMaps()
-
get_padding
()¶ getPadding() const =0 -> DimsHW
Get the padding of the convolution.
See also: setPadding()
-
get_stride
()¶ getStride() const =0 -> DimsHW
Get the stride of the convolution.
-
set_bias_weights
()¶ setBiasWeights(Weights weights)=0
Set the bias weights for the convolution.
Bias is optional. To omit bias, set the count value of the weights structure to zero.
The bias is applied per-channel, so the number of weights (if non-zero) must be equal to the number of output feature maps.
See also: getBiasWeights()
-
set_dilation
()¶ setDilation(DimsHW dims)=0
Set the dilation for a convolution.
Default: (1,1)
See also: getDilation()
-
set_kernel_size
()¶ setKernelSize(DimsHW kernelSize)=0
Set the HW kernel size of the convolution.
See also: getKernelSize()
-
set_kernel_weights
()¶ setKernelWeights(Weights weights)=0
Set the kernel weights for the convolution.
The weights are specified as a contiguous array in GKCRS order, where G is the number of groups, K the number of output feature maps, C the number of input channels, and R and S are the height and width of the filter.
See also: getKernelWeights()
-
set_nb_groups
()¶ setNbGroups(int nbGroups)=0
Set the number of groups for a convolution.
The input tensor channels are divided into nbGroups groups, and a convolution is executed for each group, using a filter per group. The results of the group convolutions are concatenated to form the output.
note: When using groups in int8 mode, the size of the groups (i.e. the channel count divided by the group count) must be a multiple of 4 for both input and output.
Default: 1
See also: getNbGroups()
-
set_nb_output_maps
()¶ setNbOutputMaps(int nbOutputMaps)=0
Set the number of output maps for the convolution.
See also: getNbOutputMaps()
-
set_padding
()¶ setPadding(DimsHW padding)=0
Set the padding of the convolution.
The input will be zero-padded by this number of elements in the height and width directions. Padding is symmetric.
Default: (0,0)
See also: getPadding()
-
set_stride
()¶ setStride(DimsHW stride)=0
Get the stride of the convolution.
Default: (1,1)
See also: setStride()
-
FullyConnectedLayer¶
-
class
tensorrt.infer.
FullyConnectedLayer
¶ A fully connected layer in a network definition. This layer expects an input tensor of three or more non-batch dimensions. The input is automatically reshaped into an MxV tensor X, where V is a product of the last three dimensions and M is a product of the remaining dimensions (where the product over 0 dimensions is defined as 1). For example:
- If the input tensor has shape {C, H, W}, then the tensor is reshaped into {1, C*H*W}.
- If the input tensor has shape {P, C, H, W}, then the tensor is reshaped into {P, C*H*W}.
The layer then performs the following operation:
Where X is the MxV tensor defined above, W is the KxV weight tensor of the layer, and bias is a row vector size K that is broadcasted to MxK. K is the number of output channels, and configurable via setNbOutputChannels(). If bias is not specified, it is implicitly 0.
The MxK result Y is then reshaped such that the last three dimensions are {K, 1, 1} and the remaining dimensions match the dimensions of the input tensor. For example:
- If the input tensor has shape {C, H, W}, then the output tensor will have shape {K, 1, 1}.
- If the input tensor has shape {P, C, H, W}, then the output tensor will have shape {P, K, 1, 1}.
C++ includes: NvInfer.h
-
get_bias_weights
()¶ getBiasWeights() const =0 -> Weights
Get the bias weights.
See also: setBiasWeightsWeights()
-
get_kernel_weights
()¶ getKernelWeights() const =0 -> Weights
Get the kernel weights.
See also: setKernelWeights()
-
get_nb_output_channels
()¶ getNbOutputChannels() const =0 -> int
Get the number of output channels K from the fully connected layer.
See also: setNbOutputChannels()
-
set_bias_weights
()¶ setBiasWeights(Weights weights)=0
Set the bias weights.
Bias is optional. To omit bias, set the count value in the weights structure to zero.
See also: getBiasWeightsWeights()
-
set_kernel_weights
()¶ setKernelWeights(Weights weights)=0
Set the kernel weights, given as a KxC matrix in row-major order.
See also: getKernelWeights()
-
set_nb_output_channels
()¶ setNbOutputChannels(int nbOutputs)=0
Set the number of output channels K from the fully connected layer.
See also: getNbOutputChannels()
ActivationLayer¶
-
class
tensorrt.infer.
ActivationLayer
¶ An Activation layer in a network definition.
This layer applies a per-element activation function to its input.
The output has the same shape as the input.
C++ includes: NvInfer.h
-
get_activation_type
()¶ getActivationType() const =0 -> ActivationType
Get the type of activation to be performed.
See also: setActivationType(), ActivationType
-
set_activation_type
()¶ setActivationType(ActivationType type)=0
Set the type of activation to be performed.
See also: getActivationType(), ActivationType
-
ActivationType¶
-
class
tensorrt.infer.
ActivationType
¶ Type of activation function
- Base Class:
- IntEnum
PoolingLayer¶
-
class
tensorrt.infer.
PoolingLayer
¶ A Pooling layer in a network definition.
The layer applies a reduction operation within a window over the input.
The output size is determined from the input size using the formula set by INetworkDefinition::setCustomPoolingDimensions().
C++ includes: NvInfer.h
-
get_average_count_excludes_padding
()¶ getAverageCountExcludesPadding() const =0 -> bool
Get whether exclusive pooling uses as a denominator the overlap area betwen the window and the unpadded input.
See also: setAverageCountExcludesPadding()
-
get_blend_factor
()¶ getBlendFactor() const =0 -> float
Get the blending factor for the max_average_blend mode: max_average_blendPool = (1-blendFactor)*maxPool + blendFactor*avgPool blendFactor is a user value in [0,1] with the default value of 0.0 In modes other than kMAX_AVERAGE_BLEND, blendFactor is ignored.
See also: setBlendFactor()
-
get_padding
()¶ getPadding() const =0 -> DimsHW
Get the padding for pooling.
Default: 0
See also: getStride()
-
get_pooling_type
()¶ getPoolingType() const =0 -> PoolingType
Get the type of activation to be performed.
See also: setPoolingType(), PoolingType
-
get_stride
()¶ getStride() const =0 -> DimsHW
Get the stride for pooling.
See also: setStride()
-
get_window_size
()¶ getWindowSize() const =0 -> DimsHW
Get the window size for pooling.
See also: setWindowSize()
-
set_average_count_excludes_padding
()¶ setAverageCountExcludesPadding(bool exclusive)=0
Set whether average pooling uses as a denominator the overlap area between the window and the unpadded input. If this is not set, the denominator is the overlap between the pooling window and the padded input.
Default: true
See also: getAverageCountExcludesPadding()
-
set_blend_factor
()¶ setBlendFactor(float blendFactor)=0
Set the blending factor for the max_average_blend mode: max_average_blendPool = (1-blendFactor)*maxPool + blendFactor*avgPool blendFactor is a user value in [0,1] with the default value of 0.0 This value only applies for the kMAX_AVERAGE_BLEND mode.
See also: getBlendFactor()
-
set_padding
()¶ setPadding(DimsHW padding)=0
Set the padding for pooling.
Default: 0
See also: getStride()
-
set_pooling_type
()¶ setPoolingType(PoolingType type)=0
Set the type of activation to be performed.
See also: getPoolingType(), PoolingType
-
set_stride
()¶ setStride(DimsHW stride)=0
Set the stride for pooling.
Default: 1
See also: getStride()
-
set_window_size
()¶ setWindowSize(DimsHW windowSize)=0
Set the window size for pooling.
See also: getWindowSize()
-
LRNLayer¶
-
class
tensorrt.infer.
LRNLayer
¶ A LRN layer in a network definition.
The output size is the same as the input size.
C++ includes: NvInfer.h
-
get_alpha
()¶ getAlpha() const =0 -> float
Get the LRN alpha value.
See also: setAlpha()
-
get_beta
()¶ getBeta() const =0 -> float
Get the LRN beta value.
See also: setBeta()
-
get_k
()¶ getK() const =0 -> float
Get the LRN K value.
See also: setK()
-
get_window_size
()¶ getWindowSize() const =0 -> int
Get the LRN window size.
See also: getWindowStride()
-
set_alpha
()¶ setAlpha(float alpha)=0
Set the LRN alpha value.
The valid range is [-1e20, 1e20].
See also: getAlpha()
-
set_beta
()¶ setBeta(float beta)=0
Set the LRN beta value.
The valid range is [0.01, 1e5f].
See also: getBeta()
-
set_k
()¶ setK(float k)=0
Set the LRN K value.
The valid range is [1e-5, 1e10].
See also: getK()
-
set_window_size
()¶ setWindowSize(int windowSize)=0
Set the LRN window size.
The window size must be odd and in the range of [1, 15].
See also: setWindowStride()
-
ScaleLayer¶
-
class
tensorrt.infer.
ScaleLayer
¶ A Scale layer in a network definition.
This layer applies a per-element computation to its input:
output = (input* scale + shift)^ power
The coefficients can be applied on a per-tensor, per-channel, or per-element basis.
note: If the number of weights is 0, then a default value is used for shift, power, and scale. The default shift is 0, the default power is 1, and the default scale is 1.
The output size is the same as the input size.
note: The input tensor for this layer is required to have a minimum of 3 dimensions.
See also: ScaleMode
C++ includes: NvInfer.h
-
get_mode
()¶ getMode() const =0 -> ScaleMode
Set the scale mode.
See also: setMode()
-
get_power
()¶ getPower() const =0 -> Weights
Get the power value.
See also: setPower()
-
get_scale
()¶ getScale() const =0 -> Weights
Get the scale value.
See also: setScale()
-
get_shift
()¶ getShift() const =0 -> Weights
Get the shift value.
See also: setShift()
-
set_mode
()¶ setMode(ScaleMode mode)=0
Set the scale mode.
See also: getMode()
-
set_power
()¶ setPower(Weights power)=0
Set the power value.
See also: getPower()
-
set_scale
()¶ setScale(Weights scale)=0
Set the scale value.
See also: getScale()
-
set_shift
()¶ setShift(Weights shift)=0
Set the shift value.
See also: getShift()
-
SoftmaxLayer¶
-
class
tensorrt.infer.
SoftmaxLayer
¶ A Softmax layer in a network definition.
This layer applies a per-channel softmax to its input.
The output size is the same as the input size.
C++ includes: NvInfer.h
ConcatenationLayer¶
-
class
tensorrt.infer.
ConcatenationLayer
¶ A concatenation layer in a network definition.
The output channel size is the sum of the channel sizes of the inputs. The other output sizes are the same as the other input sizes, which must all match.
C++ includes: NvInfer.h
-
get_axis
()¶ getAxis() const =0 -> int
Get the axis along which concatenation occurs.
See also: setAxis()
-
set_axis
()¶ setAxis(int axis)=0
Set the axis along which concatenation occurs.
0 is the major axis (excluding the batch dimension). The default is the number of non-batch axes in the tensor minus three (e.g. for an NCHW input it would be 0), or 0 if there are fewer than 3 non- batch axes.
Parameters: axis (*) – The axis along which concatenation occurs.
-
DeconvolutionLayer¶
-
class
tensorrt.infer.
DeconvolutionLayer
¶ A deconvolution layer in a network definition.
The output size is defined using the formula set by INetworkDefinition::setDeconvolutionOutputDimensionsFormula().
C++ includes: NvInfer.h
-
get_bias_weights
()¶ getBiasWeights() const =0 -> Weights
Get the bias weights for the deconvolution.
See also: getBiasWeights()
-
get_kernel_size
()¶ getKernelSize() const =0 -> DimsHW
Get the HW kernel size of the deconvolution.
See also: setKernelSize()
-
get_kernel_weights
()¶ getKernelWeights() const =0 -> Weights
Get the kernel weights for the deconvolution.
See also: setNbGroups()
-
get_nb_groups
()¶ getNbGroups() const =0 -> int
Set the number of groups for a deconvolution.
See also: setNbGroups()
-
get_nb_output_maps
()¶ getNbOutputMaps() const =0 -> int
Get the number of output feature maps for the deconvolution.
See also: setNbOutputMaps()
-
get_padding
()¶ getPadding() const =0 -> DimsHW
Get the padding of the deconvolution.
See also: setPadding()
-
get_stride
()¶ getStride() const =0 -> DimsHW
Get the stride of the deconvolution.
Default: (1,1)
-
set_bias_weights
()¶ setBiasWeights(Weights weights)=0
Set the bias weights for the deconvolution.
Bias is optional. To omit bias, set the count value of the weights structure to zero.
The bias is applied per-feature-map, so the number of weights (if non-zero) must be equal to the number of output feature maps.
See also: getBiasWeights()
-
set_kernel_size
()¶ setKernelSize(DimsHW kernelSize)=0
Set the HW kernel size of the convolution.
See also: getKernelSize()
-
set_kernel_weights
()¶ setKernelWeights(Weights weights)=0
Set the kernel weights for the deconvolution.
The weights are specified as a contiguous array in CKRS order, where C the number of input channels, K the number of output feature maps, and R and S are the height and width of the filter.
See also: getWeights()
-
set_nb_groups
()¶ setNbGroups(int nbGroups)=0
Set the number of groups for a deconvolution.
The input tensor channels are divided into nbGroups groups, and a deconvolution is executed for each group, using a filter per group. The results of the group convolutions are concatenated to form the output.
note: When using groups in int8 mode, the size of the groups (i.e. the channel count divided by the group count) must be a multiple of 4 for both input and output.
Default: 1
See also: getNbGroups()
-
set_nb_output_maps
()¶ setNbOutputMaps(int nbOutputMaps)=0
Set the number of output feature maps for the deconvolution.
See also: getNbOutputMaps()
-
set_padding
()¶ setPadding(DimsHW padding)=0
Set the padding of the deconvolution.
The input will be zero-padded by this number of elements in the height and width directions. Padding is symmetric.
Default: (0,0)
See also: getPadding()
-
set_stride
()¶ setStride(DimsHW stride)=0
Get the stride of the deconvolution.
See also: setStride()
-
ElementWiseLayer¶
-
class
tensorrt.infer.
ElementWiseLayer
¶ A elementwise layer in a network definition.
This layer applies a per-element binary operation between corresponding elements of two tensors.
The input dimensions of the two input tensors must be equal, and the output tensor is the same size as each input.
C++ includes: NvInfer.h
-
get_operation
()¶ getOperation() const =0 -> ElementWiseOperation
Get the binary operation for the layer.
See also: setOperation(), ElementWiseOperation
setBiasWeights()
-
set_operation
()¶ setOperation(ElementWiseOperation type)=0
Set the binary operation for the layer.
See also: getOperation(), ElementWiseOperation
getBiasWeights()
-
ElementWiseOperation¶
-
class
tensorrt.infer.
ElementWiseOperation
¶ Type of operation for the layer
- Base Class:
- IntEnum
ShuffleLayer¶
-
class
tensorrt.infer.
ShuffleLayer
¶ Layer type for shuffling data.
This class shuffles data by applying in sequence: a transpose operation, a reshape operation and a second transpose operation. The dimension types of the output are those of the reshape dimension.
C++ includes: NvInfer.h
-
get_first_transpose
()¶ getFirstTranspose() const =0 -> Permutation
Get the permutation applied by the first transpose operation.
Returns: - The dimension permutation applied before the reshape.
- See also (setFirstTranspose)
-
get_reshape_dimensions
()¶ getReshapeDimensions() const =0 -> Dims
Get the reshaped dimensions.
Returns: Return type: The reshaped dimensions.
-
get_second_transpose
()¶ getSecondTranspose() const =0 -> Permutation
Get the permutation applied by the second transpose operation.
Returns: - The dimension permutation applied after the reshape.
- See also (setSecondTranspose)
-
set_first_transpose
()¶ setFirstTranspose(Permutation permutation)=0
Set the permutation applied by the first transpose operation.
Parameters: - permutation (*) – The dimension permutation applied before the reshape.
- default is the identity permutation. (The) –
- also (See) –
-
set_reshape_dimensions
()¶ setReshapeDimensions(Dims dimensions)=0
Set the reshaped dimensions.
Parameters: - dimensions (*) – The reshaped dimensions.
- special values can be used as dimensions. (Two) –
- 0 copies the corresponding dimension from input. This special value can be used more than once in the dimensions. If number of reshape dimensions is less than input, 0s are resolved by aligning (Value) –
- most significant dimensions of input. (the) –
- -1 infers that particular dimension by looking at input and rest of the reshape dimensions. Note that only a maximum of one dimension is permitted to be specified as -1. (Value) –
- product of the new dimensions must be equal to the product of the old. (The) –
-
set_second_transpose
()¶ setSecondTranspose(Permutation permutation)=0
Set the permutation applied by the second transpose operation.
Parameters: - permutation (*) – The dimension permutation applied after the reshape.
- default is the identity permutation. (The) –
- permutation is applied as outputDimensionIndex = permutation.order[inputDimensionIndex], so to permute from CHW order to HWC order, the required permutation is [1, 2, 0] (The) –
- also (See) –
-
Permutation¶
-
class
tensorrt.infer.
Permutation
¶ -
* `order`
int – The elements of the permutation. The permutation is applied as outputDimensionIndex = permutation.order[inputDimensionIndex], so to permute from CHW order to HWC order, the required permutation is [1, 2, 0], and to permute from HWC to CHW, the required permutation is [2, 0, 1].
-
order
¶
-
UnaryLayer¶
-
class
tensorrt.infer.
UnaryLayer
¶ Layer that represents an unary operation.
C++ includes: NvInfer.h
-
get_operation
()¶ getOperation() const =0 -> UnaryOperation
Get the unary operation for the layer.
See also: setOperation(), UnaryOperation
-
set_operation
()¶ setOperation(UnaryOperation op)=0
Set the unary operation for the layer.
See also: getOperation(), UnaryOperation
-
UnaryOperation¶
-
class
tensorrt.infer.
UnaryOperation
¶ Type of operation for the layer
- Base Class:
- IntEnum
PluginLayer¶
PaddingLayer¶
-
class
tensorrt.infer.
PaddingLayer
¶ Layer that represents a padding operation.
The padding layer adds zero-padding at the start and end of the input tensor. It only supports padding along the two innermost dimensions. Applying negative padding results in cropping of the input.
C++ includes: NvInfer.h
-
get_post_padding
()¶ getPostPadding() const =0 -> DimsHW
Set the padding that is applied at the end of the tensor.
See also: setPostPadding
-
get_pre_padding
()¶ getPrePadding() const =0 -> DimsHW
Set the padding that is applied at the start of the tensor.
See also: setPrePadding
-
set_post_padding
()¶ setPostPadding(DimsHW padding)=0
Set the padding that is applied at the end of the tensor.
Negative padding results in trimming the edge by the specified amount
See also: getPostPadding
-
set_pre_padding
()¶ setPrePadding(DimsHW padding)=0
Set the padding that is applied at the start of the tensor.
Negative padding results in trimming the edge by the specified amount
See also: getPrePadding
-
RNNLayer¶
-
class
tensorrt.infer.
RNNLayer
¶ A RNN layer in a network definition.
This layer applies an RNN operation on the inputs.
Deprecated This interface is superseded by IRNNv2Layer.
C++ includes: NvInfer.h
-
get_bias
()¶ getBias() const =0 -> Weights
Get the bias parameter vector for the RNN.
See also: setBias()
-
get_cell_state
()¶ getCellState() const =0 -> ITensor *
Get the initial cell state of the RNN.
Returns: Return type: nullptr if no initial cell tensor was specified, the initial cell data otherwise.
-
get_data_length
()¶ getDataLength() const =0 -> int
Get the length of the data being processed by the RNN for use in computing other values.
See also: setHiddenState(), setCellState()
-
get_direction
()¶ getDirection() const =0 -> RNNDirection
Get the direction of the RNN layer.
See also: setDirection(), RNNDirection
getHiddenSize() const =0 -> std::size_t
Get the size of the hidden layers.
The hidden size is the value of hiddenSize parameter passed into addRNN().
Returns: - The internal hidden layer size for the RNN.
- See also (getDirection(), addRNN())
getHiddenState() const =0 -> ITensor *
Get the initial hidden state of the RNN.
Returns: Return type: nullptr if no initial hidden tensor was specified, the initial hidden data otherwise.
-
get_input_mode
()¶ getInputMode() const =0 -> RNNInputMode
Get the operation of the RNN layer.
See also: setInputMode(), RNNInputMode
-
get_layer_count
()¶ getLayerCount() const =0 -> unsigned
Get the number of layers in the RNN.
Returns: Return type: The number of layers in the RNN.
-
get_operation
()¶ getOperation() const =0 -> RNNOperation
Get the operation of the RNN layer.
See also: setOperation(), RNNOperation
-
get_seq_length
()¶ getSeqLength() const =0 -> int
Get the sequence length.
The sequence length is the maximum number of time steps passed into the addRNN() function. This is also the maximum number of input tensors that the RNN can process at once.
Returns: Return type: the maximum number of time steps that can be executed by a single call RNN layer.
-
get_weights
()¶ getWeights() const =0 -> Weights
Get the W weights for the RNN.
See also: setWeights()
-
set_bias
()¶ setBias(Weights bias)=0
Set the bias parameters for the RNN.
Parameters: - bias (*) – The weight structure holding the bias parameters.
- trained weights for the bias parameter vectors of the RNN. The DataType for this structure must be kFLOAT or kHALF, and must be the same datatype as the input tensor. (The) –
- layout of the weight structure depends on the RNNOperation, RNNInputMode, and RNNDirection of the layer. The array specified by weights.values contains a sequence of bias vectors, where each (The) –
- vector is linearly appended after the previous without padding; e.g., if bias vector 0 and 1 have M and N elements respectively, then the layout of weights.values in memory looks like (bias) –
The ordering of bias vectors is similar to the ordering of weight matrices as described in setWeights(). To determine the order of bias vectors for a given RNN configuration, determine the ordered list of weight matrices [ W0, W1, …, Wn ]. Then replace each weight matrix with its corresponding bias vector, i.e. apply the following transform (for layer l, gate g):
- Wl[g] becomes Wbl[g]
- Rl[g] becomes Rbl[g]
For example:
an RNN with getLayerCount() == 3, getDirection() == kUNIDIRECTION, and getOperation() == kRELU has the following order:
[ Wb0[i], Rb0[i], Wb1[i], Rb1[i], Wb2[i], Rb2[i] ]
an RNN with getLayerCount() == 2, getDirection() == kUNIDIRECTION, and getOperation() == kGRU has the following order:
[ Wb0[z], Wb0[r], Wb0[h], Rb0[z], Rb0[r], Rb0[h], Wb1[z], Wb1[r], Wb1[h], Rb1[z], Rb1[r], Rb1[h] ]
an RNN with getLayerCount() == 2, getDirection() == kBIDIRECTION, and getOperation() == kRELU has the following order:
[ Wb0_fw[i], Rb0_fw[i], Wb0_bw[i], Rb0_bw[i], Wb1_fw[i], Rb1_fw[i], Wb1_bw[i], Rb1_bw[i] ]
(fw = “forward”, bw = “backward”)
Each bias vector has a fixed size, getHiddenSize().
See also: getBias(), RNNOperation
-
set_cell_state
()¶ setCellState(ITensor &cell)=0
Set the initial cell state of the RNN with the provided cell ITensor.
Parameters: - cell (*) – The initial cell state of the RNN.
- layout for cell is a linear layout of a 3D matrix (The) –
- C - The number of layers in the RNN, it must match getLayerCount() (*) –
- H - The number of mini-batches for each time sequence. (*) –
- W - The size of the per layer hidden states, it must match getHiddenSize() (*) –
- cell is not specified, then the initial cell state is set to zero. (If) –
- amount of space required is doubled if getDirection() is kBIDIRECTION with the bidirectional states coming after the unidirectional states. (The) –
- cell state only affects LSTM RNN's. (The) –
- also (See) –
-
set_direction
()¶ setDirection(RNNDirection op)=0
Set the direction of the RNN layer.
The direction determines if the RNN is run as a unidirectional(left to right) or bidirectional(left to right and right to left). In the kBIDIRECTION case the output is concatenated together, resulting in output size of 2x getHiddenSize().
See also: getDirection(), RNNDirection
setHiddenState(ITensor &hidden)=0
Set the initial hidden state of the RNN with the provided hidden ITensor.
Parameters: - hidden (*) – The initial hidden state of the RNN.
- layout for hidden is a linear layout of a 3D matrix (The) –
- C - The number of layers in the RNN, it must match getLayerCount() (*) –
- H - The number of mini-batches for each time sequence. (*) –
- W - The size of the per layer hidden states, it must match getHiddenSize() (*) –
- amount of space required is doubled if getDirection() is kBIDIRECTION with the bidirectional states coming after the unidirectional states. (The) –
- hidden is not specified, then the initial hidden state is set to zero. (If) –
- also (See) –
-
set_input_mode
()¶ setInputMode(RNNInputMode op)=0
Set the operation of the RNN layer.
See also: getInputMode(), RNNInputMode
-
set_operation
()¶ setOperation(RNNOperation op)=0
Set the operation of the RNN layer.
See also: getOperation(), RNNOperation
-
set_weights
()¶ setWeights(Weights weights)=0
Set the weight parameters for the RNN.
Parameters: - weights (*) – The weight structure holding the weight parameters.
- trained weights for the weight parameter matrices of the RNN. The DataType for this structure must be kFLOAT or kHALF, and must be the same datatype as the input tensor. (The) –
- layout of the weight structure depends on the RNNOperation, RNNInputMode, and RNNDirection of the layer. The array specified by weights.values contains a sequence of parameter matrices, where (The) –
- parameter matrix is linearly appended after the previous without padding; e.g., if parameter matrix 0 and 1 have M and N elements respectively, then the layout of weights.values in memory looks (each) –
- like –
The following sections describe the order of weight matrices and the layout of elements within a weight matrix. Order of weight matrices The parameter matrices are ordered as described below:
For example:
an RNN with getLayerCount() == 3, getDirection() == kUNIDIRECTION, and getOperation() == kRELU has the following order:
[ W0[i], R0[i], W1[i], R1[i], W2[i], R2[i] ]
an RNN with getLayerCount() == 2, getDirection() == kUNIDIRECTION, and getOperation() == kGRU has the following order:
[ W0[z], W0[r], W0[h], R0[z], R0[r], R0[h], W1[z], W1[r], W1[h], R1[z], R1[r], R1[h] ]
an RNN with getLayerCount() == 2, getDirection() == kBIDIRECTION, and getOperation() == kRELU has the following order:
[ W0_fw[i], R0_fw[i], W0_bw[i], R0_bw[i], W1_fw[i], R1_fw[i], W1_bw[i], R1_bw[i] ]
(fw = “forward”, bw = “backward”)
Layout of elements within a weight matrix Each parameter matrix is row-major in memory, and has the following dimensions:
In other words, the input weights of the first layer of the RNN (if not skipped) transform a getDataLength()-size column vector into a getHiddenSize()-size column vector. The input weights of subsequent layers transform a K*getHiddenSize()-size column vector into a getHiddenSize()-size column vector. K=2 in the bidirectional case to account for the full hidden state being the concatenation of the forward and backward RNN hidden states.
The recurrent weight matrices for all layers all have shape (H, H), both in the unidirectional and bidirectional cases. (In the bidirectional case, each recurrent weight matrix for the (forward or backward) RNN cell operates on the previous (forward or backward) RNN cell’s hidden state, which is size H).
See also: getWeights(), RNNOperation
-
Int8 Calibration¶
Int8Calibrator¶
-
class
tensorrt.infer.
Int8Calibrator
¶ Application-implemented interface for calibration.
Calibration is a step performed by the builder when deciding suitable scale factors for 8-bit inference.
It must also provide a method for retrieving representative images which the calibration process can use to examine the distribution of activations. It may optionally implement a method for caching the calibration result for reuse on subsequent runs.
C++ includes: NvInfer.h
-
get_algorithm
()¶ getAlgorithm()=0 -> CalibrationAlgoType
Get the algorithm used by this calibrator.
Returns: Return type: The algorithm used by the calibrator.
-
get_batch
()¶ getBatch(void *bindings[], const char *names[], int nbBindings)=0 -> bool
Get a batch of input for calibration.
The batch size of the input must match the batch size returned by getBatchSize().
Parameters: - bindings (*) – An array of pointers to device memory that must be set to the memory containing each network input data.
- names (*) – The names of the network input for each pointer in the binding array.
- nbBindings (*) – The number of pointers in the bindings array.
Returns: - False if there are no more batches for calibration.
- See also (getBatchSize())
-
get_batch_size
()¶ getBatchSize() const =0 -> int
Get the batch size used for calibration batches.
Returns: Return type: The batch size.
-
read_calibration_cache
()¶ readCalibrationCache(std::size_t &length)=0 -> const void *
Load a calibration cache.
Calibration is potentially expensive, so it can be useful to generate the calibration data once, then use it on subsequent builds of the network. The cache includes the regression cutoff and quantile values used to generate it, and will not be used if these do not batch the settings of the current calibrator. However, the network should also be recalibrated if its structure changes, or the input data set changes, and it is the responsibility of the application to ensure this.
Parameters: length (*) – The length of the cached data, that should be set by the called function. If there is no data, this should be zero. Returns: Return type: A pointer to the cache, or nullptr if there is no data.
-
write_calibration_cache
()¶ writeCalibrationCache(const void *ptr, std::size_t length)=0
Save a calibration cache.
Parameters: - ptr (*) – A pointer to the data to cache.
- length (*) – The length in bytes of the data to cache.
- also (See) –
-
Int8EntropyCalibrator¶
-
class
tensorrt.infer.
Int8EntropyCalibrator
¶ Entropy calibrator. This is the preferred calibrator, as it is less complicated than the legacy calibrator and produces better results.
C++ includes: NvInfer.h
Int8LegacyCalibrator¶
-
class
tensorrt.infer.
Int8LegacyCalibrator
¶ Legacy calibrator for compatibility with 2.0 EA. Will be removed in 2.2. Deprecated
C++ includes: NvInfer.h
-
get_algorithm
()¶ getAlgorithm() -> CalibrationAlgoType
Signal that this is the legacy calibrator.
-
get_quantile
()¶ getQuantile() const =0 -> double
The quantile (between 0 and 1) that will be used to select the region maximum when the quantile method is in use.
See the user guide for more details on how the quantile is used.
-
get_regression_cutoff
()¶ getRegressionCutoff() const =0 -> double
The fraction (between 0 and 1) of the maximum used to define the regression cutoff when using regression to determine the region maximum.
See the user guide for more details on how the regression cutoff is used
-
read_histogram_cache
()¶ readHistogramCache(std::size_t &length)=0 -> const void *
Load a histogram.
Histogram generation is potentially expensive, so it can be useful to generate the histograms once, then use them when exploring the space of calibrations. The histograms should be regenerated if the network structure changes, or the input data set changes, and it is the responsibility of the application to ensure this.
Parameters: length (*) – The length of the cached data, that should be set by the called function. If there is no data, this should be zero. Returns: Return type: A pointer to the cache, or nullptr if there is no data.
-
write_histogram_cache
()¶ writeHistogramCache(const void *ptr, std::size_t length)=0
Save a histogram cache.
Parameters: - ptr (*) – A pointer to the data to cache.
- length (*) – The length in bytes of the data to cache.
- also (See) –
-
Logger¶
Logger¶
-
class
tensorrt.infer.
Logger
¶ Application-implemented logging interface for the builder, engine and runtime.
Note that although a logger is passed on creation to each instance of a IBuilder or IRuntime interface, the logger is internally considered a singleton, and thus multiple instances of IRuntime and/or IBuilder must all use the same logger.
C++ includes: NvInfer.h
-
log
()¶ log(Severity severity, const char *msg)=0
A callback implemented by the application to handle logging messages;
Parameters: - severity (*) – The severity of the message.
- msg (*) – The log message, null terminated.
-
ConsoleLogger¶
Profiler¶
Profiler¶
-
class
tensorrt.infer.
Profiler
¶ Application-implemented interface for profiling.
When this class is added to an execution context, the profiler will be called once per layer for each invocation of execute(). Note that enqueue() does not currently support profiling.
The profiler will only be called after execution is complete.
C++ includes: NvInfer.h
-
report_layer_time
()¶ reportLayerTime(const char *layerName, float ms)=0
Layer time reporting callback.
Parameters: - layerName (*) – The name of the layer, set when constructing the network definition.
- ms (*) – The time in milliseconds to execute the layer.
-
ConsoleProfiler¶
-
class
tensorrt.infer.
ConsoleProfiler
¶ -
mProfile
¶
-
report_layer_time
()¶ reportLayerTime(const char *layerName, float ms)=0
Layer time reporting callback.
Parameters: - layerName (*) – The name of the layer, set when constructing the network definition.
- ms (*) – The time in milliseconds to execute the layer.
-
timing_iterations
¶
-


Header
Resize the browser window to see the responsive effect.
|
|
|
|
Resize the browser window to see the responsive effect.
|
|
|
|


Ruby's Crazy friend Javascript
Ruby has been my best friend since I started to program and when he introduce me to his crazy friend JavaScript, I said to myself if they are friends then JavaScritp and I will be friends. Trying to learn JavaScript this week has been both fun and painful journey. I've kept constantly comparing JavaScript to Ruby in order to keep my sanity. I came to realize that JavaScript isn't all that different from Ruby, yet the syntax is still unfamiliar and some of the logics are slightly complicated I want to point out a few similarities and differences that caught my attention.
=== vs ==
To start off in JavaScript, there is a 3 equal sign and a double equal sign and they slightly do different things. The 3 equal sign will help you determine if two objects are the same exact object. For example:( 3 === 3 will return true). While the double equal sign in Javascript will determine if the values match. For example:("3" == 3 will return true) because JavaScript will automatically convert the first string into a number in order to make the value match. In Ruby, you accomplish comparison using the double equal sign.
parseInt(); & .to_i
In Javascript in order to convert a string into an integer, you will have to use parseInt("10"); While in ruby you only use the method "10".to_i. The Javascript method is slightly difficult to remember because it does not read well.
Functions vs. Methods
In JavaScript functions are very similar to Ruby methods. The only difference is the syntax. For example in Javascript:
function string(){ // print anything to the console using the method below. console.log("I am a function in Javascript"); } // Calling a function to the console string(); #In Ruby you will create a method like this def string puts "I am a method using Ruby" end # Calling a method string
Each
Iterating through an array or objects is very important in programming. Like Ruby Javascript has its own each function that does the same exact thing. For Example:
var array = [1,2,3,4,5,6]; array.forEach(function(n){ console.log(n); }); #In Ruby you will use the each method array = [1,2,3,4,5,6] array.each do |n| puts n end
Prototypes vs. Classes
Javascript and Ruby are both object-oriented programming languages. Like Ruby classes you can create Javascript prototypes. For Example:
function myObject(str1,str2,number){ this.str1 = str1 this.str2 = str2 this.number = number } // This is how you create an object in JavaScript var newObject = new myObject("I","am",25) #In Ruby you create a class like this class my_object def initialize(str1,str2,number) @str1 = str1 @str2 = str2 @number = number end end #This is how you create an object in Ruby new_object = my_object.new("I","am",25)
So if you ever encounter Javascript you will soon realize that it is nothing more than a slightly crazy version of ruby. I hope that these comparisons in syntax help you understand the language better. Good Luck out there and like always keep on Coding.
Made with ♥ Brian Bier


CharIoT is a web platform that aims to leverage the "Internet of Things" to support people in managing their energy use particularly those affected by fuel poverty. The platform relies on a sensor kit to capture environmental data that is meaning in the context of fuel poverty (such as humidity and temperature), and explore ways in which to interrogate the data for the 'symptoms' of fuel poverty, such as damp and cold. Chariot is a collaboration between researchers at the University of Nottingham, the University of Southampton, and the Centre for Sustainable Energy. This project was funded by the Engineering and Physical Sciences Research Council (EPSRC).
Our algorithms and models predict how the home and its occupants will use gas and electricity.
Analyse multiple data stream form sensors deployed in the home to better understand "why" peaks in energy usage occur.
Understand whether unsused devices are left on or which applicances are consuming too much energy.
Algorithms model the heating efficiency of the home (on a per room level) and predict hte savings to be made from improvements to insulation or the central heating system.
All our algorithms and visualisations are open-source (only for non-commercial use) and can be extended to account for different heating systems.
Our visualisations have been co-developed with energy advisors to facilitate conversations with home occupants.


+++ title = "Andrea from Mona Vale" slug = "andrea-from-mona-vale" date = 2007-06-12T12:00:00+10:00 tags = ["eccentric-encounters", "fellow-travellers", "aussies"] locations = ["bolivia/rurrenabaque"] draft = false summary = """
Andrea's a half-Macedonian, half-Dutch young Aussie girl, who comes from a place just down the road from me in Sydney: Mona Vale. She's been travelling round the world since the age of 17, she has a degree in film production, and she speaks a bit of Hebrew (because she had an Israeli boyfriend, and she visited Israel for a few weeks). I met her down in Rurrenabaque, and ended up doing three days of action-packed pampas touring with her.
""" +++Andrea's a half-Macedonian, half-Dutch young Aussie girl, who comes from a place just down the road from me in Sydney: Mona Vale. She's been travelling round the world since the age of 17, she has a degree in film production, and she speaks a bit of Hebrew (because she had an Israeli boyfriend, and she visited Israel for a few weeks). I met her down in Rurrenabaque, and ended up doing three days of action-packed pampas touring with her.
{{< galleryphoto "2007-06-12-12-00-00--andrea-gives-us-the-thumbs-up-chris-can-t-help-butting.jpg" >}}


"Because of their special relationship with sheep, shepherds are disqualified..." [from playing Sheep & Tides.]
-- voiceover --
from DROWNING BY NUMBERS
DROWNING BY NUMBERS written and directed by Peter Greenaway
Starring Joan Plowright Bernard Hill
If THE COOK, THE THIEF, HIS WIFE AND HER LOVER is a necessity to see (which I think it is,) then DROWNING BY NUMBERS is a diversion.
Take a bit of Fellini and a bit of Agatha Christie and you get DBN: three generations of women plot to and eventually do destroy the men in their lives. But this isn't the fun part.
The fun part is in the detection necessary on the part of the viewer to find the numbers embedded in the scenes. But bear in mind that on a video rental, much detail will be lost and also the copy I saw was not letterboxed, so portions of the frame were missing from time to time. It is also a distraction to be sure, but the film _is_ about games. [After viewing it a second time, I still missed quite a few numbers, including #1 !]
DROWNING BY NUMBERS is a game and a good game at that. It's a combination of TEN LITTLE INDIANS and JULIETTE OF THE SPIRITS. If you follow Greenaway's work you'll want to catch up on this if you haven't seen it before.
I am drawn into these works and am glad I have made the effort to see all the Greenaway films of which I am aware. It seems that much of the superior filmmaking these days is once again being done by Europeans (Vincent Ward, Wim Wenders, and Greenaway.) And if it weren't for vid. stores we more than likely wouldn't have a chance to see any of them.
<EMAIL_ADDRESS>The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Loggerhead is a web-based interface for
Bazaar
branches. It is used by
Launchpad,
so if your code is hosted on Launchpad, you are using Loggerhead.
The repository browser URL for the root of the project.
For example, a Launchpad project called myproject would use
http://bazaar.launchpad.net/~myteam/myproject/mybranch.


Home
Work
Renderings
Maps
Illustrations
Computer Aided Designs
Web Designs
Graphic Designs
Professional Resume
Blog
urban.mateo
art.x.mateo
Articles
Shop
Mateo Van Thienen
mateovtn.at.gmail.com


Post-processing data¶
Plotting 3D data¶
Three dimensional flow fields are stored in Plot3D and/or VTK format and can be visualized using Paraview, or Tecplot.
Post-processing flow statistics¶
Mean flow statics are stored in raw format in the file stat.bin.
To post-process this, use the post-processing program available in the folder tools/postpro
.
Compile the tool by typing,
$ make
This will produce the executable postpro.exe.
Different files will be printed depending on the flow case that has been run.
Channel flow¶
Copy the executable postpro.exe to the case folder you want to post-process and run:
$ ./postpro.exe
This will print the post-processed flow statistics in the folder POSTPRO/
,
which will contain the files channinfo.dat
and channstat.prof
channinfo.dat¶
The file channinfo.dat
contains
\(Re_\tau=u_\tau h/\nu_w\), friction Reynolds number, where \(h\) is the channel half width and \(\nu_w\) the kinematic viscosity at the wall
\(\overline{\rho}_w\) mean wall density
\(u_\tau/u_b\), ratio between friction and bulk flow velocity
\(C_f=2\overline{\tau}_w/(\rho_b u_b^2)\) skin-friction coefficient based on the mean wall shear stress, bulk flow velocity and bulk fluid density
channstat.prof¶
The file channstat.prof
contains mean profiles of channel flow in the following format:
\(y/h,\quad\) wall-normal coordinate normalized with the channel half width
\(y^+,\quad\) wall-normal coordinate in viscous units
\(y_{TL}^+,\quad\) wall-normal coordinate transformed according to Trettel and Larsson [???] in viscous units
\(\widetilde{u}/u_b,\quad\) mean streamwise velocity normalized by the bulk flow velocity
\(u^+,\quad\) mean streamwise velocity in viscous units
\(u_{VD}^+,\quad\) mean streamwise velocity transformed according to van Driest [???] in viscous units
\(u_{TL}^+,\quad\) mean streamwise velocity transformed according to Trettel & Larsson [???] in viscous units
\(\overline{\rho}/\overline{\rho}_w,\quad\) mean density normalized by the mean wall density
\(\overline{\tau}_{11}/\tau_w,\quad\) normal Reynolds stress component 11, scaled by density, in viscous units
\(\overline{\tau}_{22}/\tau_w,\quad\) normal Reynolds stress component 22, scaled by density, in viscous units
\(\overline{\tau}_{33}/\tau_w,\quad\) normal Reynolds stress component 33, scaled by density, in viscous units
\(\overline{\tau}_{12}/\tau_w,\quad\) Reynolds shear stress component 12, scaled by density, in viscous units
\(\overline{T}/T_w,\quad\) mean temperature normalized by the wall temperature
\(\overline{\rho_w}/\rho_w,\quad\) mean density normalized by wall density
\(\overline{T^{'2}}/T_w^2,\quad\) temperature fluctuations normalized by the wall temperature
\((\overline{T}-T_w)/T_\tau,\quad\) mean temperature in viscous units
\(\overline{T^{'2}}/T_\tau^2,\quad\) temperature fluctuations in viscous units
\(y_{V}^+,\quad\) wall-normal coordinate transformed according to Volpiani et al. [???], in viscous units
\(u_{V}^+,\quad\) mean streamwise velocity transformed according to Volpiani et al. [???], in viscous units
Boundary layer¶
Copy the executable postpro.exe to the case folder you want to post-process.
Create an ASCII file named bl_profiles.dat
. The file should contain two lines: report the number
of profiles you want to extract on the first line, and the corresponding indices of the x coordinate on the second line.
For instance, the following file
2
500 1000
will extract boundary layer statistics at two locations, corresponding to locations \(x_{i=500}\) and \(x_{i=1000}\).
Run the post-processing tool by typing:
$ ./postpro.exe
The post-processing routine will create the folder POSTPRO
, containing the files cf.dat
and stat_nnnnn.dat
,
where nnnnn
is the number of profiles.
cf.dat¶
The file cf.dat
contains the boundary layer characteristics as a function of the streamwise direction:
\(x/\delta_0,\quad\) streamwise coordinate normalized by inflow boundary layer thickness
\(Cf=\overline{\tau}_w/(\rho_w U_\infty^2),\quad\) skin friction coefficient
\(Re_\tau=\delta_{99}/\delta_v,\quad\) friction Reynolds number
\(H,\quad\) shape factor
\(H_{inc},\quad\) incompressible shape factor
\(\delta_{99},\quad\) boundary layer thickness
\(\delta^*,\quad\) displacement thickness
\(\theta^*,\quad\) momentum thickness
\(u_\tau/U_\infty,\quad\) friction velocity normalized by free stream velocity
\({Re_\theta}_{inc}=\rho_\infty U_\infty\theta_{inc}/\mu_\infty,\quad\) Reynolds number based on incompressible momentum thickness
\({C_f}_{inc},\quad\) Skin friction coefficient transformed according to van Driest II transformation [???]
\({Re_\theta}=\rho_\infty u_\infty\theta/\mu_w\quad\), Reynolds number based on momentum thickness, and viscosity at the wall
\(p_{rms}/\tau_w\) Pressure rms at the wall in viscous units
stat_nnnnn.dat¶
The files stat_nnnnn.dat
contain the boundary layer profiles in the following format:
\(y/\delta_{99},\quad\) wall-distance normalized by local boundary layer thickness
\(y^+,\quad\) wall-distance in viscous units
\(\widetilde{u}^+,\quad\) streamwise velocity in viscous units
\(u_{VD}^+,\quad\) streamwise velocity transformed according to van Driest [???], in viscous units
\(\overline{\tau}_{11}/\tau_w,\quad\) normal Reynolds stress component 11, scaled by density, in viscous units
\(\overline{\tau}_{22}/\tau_w,\quad\) normal Reynolds stress component 22, scaled by density, in viscous units
\(\overline{\tau}_{33}/\tau_w,\quad\) normal Reynolds stress component 33, scaled by density, in viscous units
\(\overline{\tau}_{12}/\tau_w,\quad\) Reynolds shear stress component 12, scaled by density, in viscous units
\(\overline{\rho}/\overline{\rho}_w,\quad\) mean density scaled by the wall density
\(\overline{p^{'2}}/\tau_w,\quad\) pressure fluctuations in wall units
\(y_{TL}^+,\quad\) wall-normal coordinate transformed according to Trettel and Larsson [???], in viscous units
\(u_{TL}^+,\quad\) mean streamwise velocity transformed according to Trettel and Larsson [???], in viscous units
\(y_{V}^+,\quad\) wall-normal coordinate transformed according to Volpiani et al. [???], in viscous units
\(u_{V}^+,\quad\) mean streamwise velocity transformed according to Volpiani et al. [???], in viscous units


Identity of selected spots using liquid chromatography-tandem mass spectrometry (LC-MS/MS) analysis.
* indicates an increase of more than ten times that of healthy pulp. Database: NCBInr_human human_20150619 (182,730 sequences; 70,344,302 residues). Protein score is −10 *Log(P), where P is the probability that the observed match is a random event. Individual protein scores >26 indicate identity or extensive homology ( p < 0.05).


{% extends "pretixcontrol/base.html" %} {% load i18n %} {% load bootstrap3 %} {% load formset_tags %} {% block custom_header %} {{ block.super }} {% endblock %} {% block title %}{% trans "Organizer" %}{% endblock %} {% block content %}
{% blocktrans trimmed %} These settings will be used for the organizer page as well as for the default settings for all events in this account that do not have their own design settings. {% endblocktrans %}
{% blocktrans trimmed %} You can here define a set of metadata properties (i.e. variables) that you can later set for your events and re-use in places like ticket layouts. This is an useful timesaver if you create lots and lots of events. {% endblocktrans %}
{% trans "Add property" %}


PRINCESS CARABOO A film review by Mark R. Leeper Copyright 1994 Mark R. Leeper
Capsule review: Phoebe Cates stars in a fact-based tale told with an almost storybook style. A mysterious Pacific island Princess who shows up wandering in 1817 England. She soon becomes the subject of fame and controversy. Michael Austin creates a light comedy- drama that is more about a 19th Century England with a thirst for exotic land. Kevin Kline's role may have been pasted into the script, but it is the best in the film. The film is a little on the fluffy side. Rating: +1 (-4 to +4).
1817 in England was during a time of great awakening in England. The recently ended Napoleonic Wars had brought an awareness that there was a lot of world beyond the shores of Britain. Coleridge and Byron wrote about exotic lands and the aristocracy hungered to know more of faraway lands with poetic names. And in the midst of this craze for the foreign and exotic, Princess Caraboo shows up wandering in a field near an English village. The turbanned Caraboo speaks an unknown language, writes in totally unknown pictograms, and has seems to have fashion tastes molded on some Pacific Island or someplace in Asia. She is adopted by the affluent Mrs. Worrall (Wendy Hughes) and her less charitable husband (Jim Broadbent). Little by little the Princess's story comes out of how she was kidnapped by pirates and managed to escape from them off the coast of England. But nobody is sure if the story is true or a fraud.
Michael Austin's film is not so much about the title character but about the phenomenon and controversy that surrounded her appearance. The mysterious woman's fame soon spreads across England. Some believe her to be a Javanese princess, others believe her just a woman with a vivid imagination. But many of the experts who first doubt her are confounded by the evidence that she is the genuine article.
 In an interview at the Montreal Film Festival Michael Austin said that he first cast Phoebe Cates and since her husband Kevin Costner [sic] came along to tend their baby, the director gave him a part in the film also. Actually Kevin Kline really grabs the attention of the audience as Frixos, the Greek dandy who is the Worrall's insolent butler. As an early and overly candid sceptic of Caraboo his role is a comic gem. What was probably a minor or even non-existent role expanded just for his talents becomes the most engaging characterization in the film. Wendy Hughes is a good actress, but this film does not give sufficient depth to her character. Perhaps it was pushed aside by the Kline role, but she is a little too sweet and understanding, a bit too good to be true. Jim Broadbent has more to do as Mr. Worrall who married into the aristocracy without any touch of nobility. Stephen Rea is Gutch, who narrates the story. As a newspaperman Gutch is romantically attracted to Caraboo but also feels a responsibility to investigate the truth of her story. John Lithgow rounds out the cast as a linguistic expert won over in multiple ways by the princess.
A film with Freddie Francis's camerawork will always be worth seeing. His work goes back at least to THE INNOCENTS and his feel for creating a period atmosphere in films like THE FRENCH LIEUTENANT'S WOMAN is always excellent. Under Austin's direction his images here have more of a storybook feel than usual. But we do get a look at village life from the fancy manors to the town square with its ale houses and gibbets. The score by Richard Hartley often has majestic moments but is not memorable on first hearing.
The film is a light enjoyable look at an England that rarely is shown in historical films. It is short at 96 minutes, but also sweet. I give it a +1 on the -4 to +4 scale.
Mark R. Leeper<EMAIL_ADDRESS>.
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Free online Ocr
Easily convert scanned Amharic books, images, newspapers, business and legal documents into editable and searchable text format for free. All major file formats (PDF, JPG, BMP, PNG) are supported.
Free online Ocr
Easily convert scanned Amharic books, images, newspapers, business and legal documents into editable and searchable text format for free. All major file formats (PDF, JPG, BMP, PNG) are supported.


Combobox programmatically.
id: "combo-single", selectionMode: "single", autoFilter: false
id: "combo-single-autoFilter", selectionMode: "single", autoFilter: true
id: "combo-multiple", selectionMode: "multiple"
id: "combo-single-disabled", selectionMode: "single", autoFilter: false, disabled
id: "combo-single-autoFilter-disabled", selectionMode: "single", autoFilter: true, disabled
id: "combo-multiple-disabled", selectionMode: "multiple", disabled
id: "combo-custom-sel-single", selectionMode: "single", autoFilter: true, custom initial selection
id: "combo-custom-sel-multiple", selectionMode: "multiple", custom initial selection
id: "combo-single-autoFilter-readonly", selectionMode: "single", autoFilter: true, readonly
id: "combo-single-value", data items with value, , selectionMode: "single", autoFilter: false
id: "combo-multiple-value", data items with value, selectionMode: "multiple"
id: "combo-single-rtl", dir="rtl" selectionMode: "single", autoFilter: false
id: "combo-single-default-list", selectionMode: "single", autoFilter: false, default List (created by Combobox)