ShapeExpr#

class tensorrt.plugin.ShapeExpr(value: Optional[Union[int, tensorrt.tensorrt.IDimensionExpr, tensorrt.plugin._tensor.ShapeExpr]] = None)#

Symbolic expression for single dimension of a tensor

Parameters

value (Union[int, trt.IDimensionExpr, ShapeExpr], optional) – Constant or another symbolic expression. Defaults to creating a fake shape expression.

constant_value() int#

Return value of the constant shape expression.

Raises

RuntimeError – For non-constant shape expressions. Check is_constant to determine accessibility.

property is_constant: bool#

True if this shape expression is a build-time constant, False otherwise.

Raises

RuntimeError – For fake ShapeExprs. Check is_fake to determine accessibility.

property is_fake: bool#

A ShapeExpr may be “fake” when it is accessed in a non-shape calculation context. Fake ShapeExpr`s are externally indistinguishable unless `is_constant or constant_value is required.

property is_size_tensor: bool#

True if this represents a size tensor, False otherwise.

class tensorrt.plugin.ShapeExprs(length: int, _is_dummy: bool = False)#

Iterable holding ShapeExprs

Parameters

length (int) – Number of dimensions of the tensor

classmethod from_tuple(shape_exprs: Tuple[Union[tensorrt.plugin._tensor.ShapeExpr, int]]) tensorrt.plugin._tensor.ShapeExprs#
Parameters

shape_exprs (Tuple[Union[ShapeExpr, int]]) – Tuple to construct ShapeExprs from

numel() tensorrt.plugin._tensor.ShapeExpr#

Returns a symbolic expression for the number of elements

class tensorrt.plugin.SizeTensorShapeExpr(size_tensor_desc: tensorrt.plugin._tensor.SizeTensorDesc)#

Extends ShapeExpr

A shape expression that represent a size tensor

Note

It is recommended to use SizeTensorDesc.expr to get a SizeTensorShapeExpr representing a size tensor