TensorDesc#
- class tensorrt.plugin.TensorDesc(shape_expr: Optional[tensorrt.plugin._tensor.ShapeExprs] = None, dtype: Optional[tensorrt.tensorrt.DataType] = None, format: Optional[tensorrt.tensorrt.TensorFormat] = None, scale: Optional[float] = None)#
Descriptor for a tensor A TensorDesc never contains nor refers to any tensor data.
- Parameters
shape_expr (ShapeExprs) – The data with which to initialize the tensor.
dtype (trt.DataType) – The data type of the tensor.
format (trt.TensorFormat) – Format (layout) of the tensor.
scale (float) – Scale for INT8 data type.
1tensor = trt.TensorDesc((10, 2, 32, 32), dtype=trt.float32)
1tensor = trt.from_shape_expr(other.shape_expr, dtype=trt.float32)
- aliased() tensorrt.plugin._tensor.TensorDesc #
- Returns
Returns a TensorDesc which has identical properties and is aliased to this tensor (would result in a Tensor during enqueue sharing the same data buffer). Returned TensorDesc is immutable.
1@tensorrt.plugin.register("my::plugin") 2def _(inp: tensorrt.plugin.TensorDesc) -> tensorrt.plugin.TensorDesc: 3 return inp.aliased()
- property dtype: tensorrt.tensorrt.DataType#
Data type of the tensor.
- property format: tensorrt.tensorrt.TensorFormat#
The format of the tensor.
Warning
Only accessible when TensorDesc.has_shape is true.
- get_aliased() tensorrt.plugin._tensor.TensorDesc #
- Returns
Returns a TensorDesc for the tensor which this tensor is aliased to. Returns None is this tensor is not aliased to any other tensor.
- property has_shape: bool#
True if this tensor has concrete shape information, False otherwise.
- property has_shape_expr: bool#
True if this tensor has symbolic shape expressions, False otherwise.
- property is_aliased: bool#
True if this tensor is aliased to another tensor, False otherwise.
- property is_dynamic: bool#
True if this tensor has at least one dynamic dimension, False otherwise.
- like() tensorrt.plugin._tensor.TensorDesc #
- Returns
Returns a TensorDesc which has identical properties to this tensor, and is mutable.
1@tensorrt.plugin.register("my::plugin") 2def _(inp: tensorrt.plugin.TensorDesc) -> tensorrt.plugin.TensorDesc: 3 return inp.like()
- property ndim: int#
Number of dimensions
- numel() int #
- Returns
Returns an int with the number of elements of the tensor.
Warning
Should only be called when TensorDesc.has_shape is true. If a symbolic expression for the number of elements is required, query TensorDesc.shape_expr.numel().
- property scale: float#
Scale for INT8 data type.
Warning
Only accessible when TensorDesc.has_shape is true.
- property shape: tensorrt.plugin._tensor.Shape#
The (concrete) shape of the tensor.
Warning
Only accessible when TensorDesc.has_shape is true.
- property shape_expr: tensorrt.plugin._tensor.ShapeExprs#
Symbolic expressions for the tensor shape.
- class tensorrt.plugin.SizeTensorDesc(opt: tensorrt.plugin._tensor.ShapeExpr, upper_bound: tensorrt.plugin._tensor.ShapeExpr)#
Extends
TensorDesc
Descriptor for a size tensor: a scalar of either INT32 or INT64 data type used to express the extent of a data-dependent dimension.
- Parameters
Note
It is recommended to construct a size tensor using
size_tensor()
instead of using this constructor directly- expr() tensorrt.plugin._tensor.SizeTensorShapeExpr #
Symbolic expression for this size tensor
- property index: int#
Output index at which this size tensor resides
- property opt: tensorrt.plugin._tensor.ShapeExpr#
Symbolic expression for the extent of this size tensor to use in the autotune process of the engine build
- property upper_bound: tensorrt.plugin._tensor.ShapeExpr#
Symbolic expression for the upper-bound of this size tensor