Refitter
- class tensorrt.Refitter(self: tensorrt.tensorrt.Refitter, engine: tensorrt.tensorrt.ICudaEngine, logger: tensorrt.tensorrt.ILogger) None
Updates weights in an
ICudaEngine
.- Variables
error_recorder –
IErrorRecorder
Application-implemented error reporting interface for TensorRT objects.logger –
ILogger
The logger provided when creating the refitter.max_threads –
int
The maximum thread that can be used by theRefitter
.
- Parameters
engine – The engine to refit.
logger – The logger to use.
- __del__(self: tensorrt.tensorrt.Refitter) None
- __exit__(exc_type, exc_value, traceback)
Context managers are deprecated and have no effect. Objects are automatically freed when the reference count reaches 0.
- __init__(self: tensorrt.tensorrt.Refitter, engine: tensorrt.tensorrt.ICudaEngine, logger: tensorrt.tensorrt.ILogger) None
- Parameters
engine – The engine to refit.
logger – The logger to use.
- get_all(self: tensorrt.tensorrt.Refitter) Tuple[List[str], List[tensorrt.tensorrt.WeightsRole]]
Get description of all weights that could be refitted.
- Returns
The names of layers with refittable weights, and the roles of those weights.
- get_all_weights(self: tensorrt.tensorrt.Refitter) List[str]
Get names of all weights that could be refitted.
- Returns
The names of refittable weights.
- get_dynamic_range(self: tensorrt.tensorrt.Refitter, tensor_name: str) tuple
Gets the dynamic range of a tensor. If the dynamic range was never set, returns the range computed during calibration.
- Parameters
tensor_name – The name of the tensor whose dynamic range to retrieve.
- Returns
Tuple[float, float]
A tuple containing the [minimum, maximum] of the dynamic range.
- get_missing(self: tensorrt.tensorrt.Refitter) Tuple[List[str], List[tensorrt.tensorrt.WeightsRole]]
Get description of missing weights.
For example, if some Weights have been set, but the engine was optimized in a way that combines weights, any unsupplied Weights in the combination are considered missing.
- Returns
The names of layers with missing weights, and the roles of those weights.
- get_missing_weights(self: tensorrt.tensorrt.Refitter) List[str]
Get names of missing weights.
For example, if some Weights have been set, but the engine was optimized in a way that combines weights, any unsupplied Weights in the combination are considered missing.
- Returns
The names of missing weights, empty string for unnamed weights.
- get_tensors_with_dynamic_range(self: tensorrt.tensorrt.Refitter) List[str]
Get names of all tensors that have refittable dynamic ranges.
- Returns
The names of tensors with refittable dynamic ranges.
- refit_cuda_engine(self: tensorrt.tensorrt.Refitter) bool
Updates associated engine. Return
True
if successful.Failure occurs if
get_missing()
!= 0 before the call.
- set_dynamic_range(self: tensorrt.tensorrt.Refitter, tensor_name: str, range: List[float]) bool
Update dynamic range for a tensor.
- Parameters
tensor_name – The name of the tensor whose dynamic range to update.
range – The new range.
- Returns
True
if successful,False
otherwise.
Returns false if there is no Int8 engine tensor derived from a network tensor of that name. If successful, then
get_missing()
may report that some weights need to be supplied.
- set_named_weights(self: tensorrt.tensorrt.Refitter, name: str, weights: tensorrt.tensorrt.Weights) bool
Specify new weights of given name. Possible reasons for rejection are:
The name of weights is empty or does not correspond to any refittable weights.
The number of weights is inconsistent with the original specification.
Modifying the weights before method refit_cuda_engine() completes will result in undefined behavior.
- Parameters
name – The name of the weights to be refitted.
weights – The new weights to associate with the name.
- Returns
True
on success, orFalse
if new weights are rejected.
- set_weights(self: tensorrt.tensorrt.Refitter, layer_name: str, role: tensorrt.tensorrt.WeightsRole, weights: tensorrt.tensorrt.Weights) bool
Specify new weights for a layer of given name. Possible reasons for rejection are:
There is no such layer by that name.
The layer does not have weights with the specified role.
The number of weights is inconsistent with the layer’s original specification.
Modifying the weights before
refit_cuda_engine()
completes will result in undefined behavior.- Parameters
layer_name – The name of the layer.
role – The role of the weights. See
WeightsRole
for more information.weights – The weights to refit with.
- Returns
True
on success, orFalse
if new weights are rejected.