ShapeExpr

class tensorrt.plugin.ShapeExpr(value: int | IDimensionExpr | ShapeExpr | None = None)

张量单维的符号表达式

参数:

value (Union[int, trt.IDimensionExpr, ShapeExpr], optional) – 常量或另一个符号表达式。默认为创建伪造的形状表达式。

constant_value() int

返回常量形状表达式的值。

Raises:

RuntimeError – 对于非常量形状表达式。检查 is_constant 以确定可访问性。

property is_constant: bool

True 如果此形状表达式是构建时常量,False 否则为否。

Raises:

RuntimeError – 对于伪造的 ShapeExpr。检查 is_fake 以确定可访问性。

property is_fake: bool

当在非形状计算上下文中访问 ShapeExpr 时,它可能是“伪造的”。除非需要 is_constantconstant_value,否则伪造的 `ShapeExpr` 在外部无法区分。

property is_size_tensor: bool

True 如果这表示大小张量,False 否则为否。

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

可迭代的 ShapeExpr 容器

参数:

length (int) – 张量的维度数

classmethod from_tuple(shape_exprs: Tuple[ShapeExpr | int]) ShapeExprs
参数:

shape_exprs (Tuple[Union[ShapeExpr, int]]) – 用于构建 ShapeExprs 的元组

numel() ShapeExpr

返回元素数量的符号表达式

class tensorrt.plugin.SizeTensorShapeExpr(size_tensor_desc: SizeTensorDesc)

扩展了 ShapeExpr

表示大小张量的形状表达式

注意

建议使用 SizeTensorDesc.expr 来获取表示大小张量的 SizeTensorShapeExpr