Tensor¶
- class tensorrt.plugin.Tensor¶
张量的表示,携带数据
Tensor
对象严格来说是带有底层数据缓冲区的张量的描述符。tensorrt.plugin 不提供任何对Tensor
执行标准数据更改操作的 API。支持 __cuda_array_interface__,以便与其他框架互操作。
- aliased(shape: Shape | Tuple[int] | PluginTensorDesc | None = None) Tensor ¶
返回一个
Tensor
,它具有与此相同的data_ptr
,但具有提供的 shape。- 参数:
shape (Union[Shape, Tuple[int], trt.PluginTensorDesc], optional) – 新张量的必需形状(必须具有相同的体积)。默认为相同形状。
- Raises:
ValueError – 如果 shape 不是支持的类型,或者不具有相同的体积
- property data_ptr: int¶
指向此张量的数据缓冲区的指针
- property dtype: DataType¶
张量的数据类型。
- property format: TensorFormat¶
张量的格式。
- property is_aliased¶
如果此张量别名指向另一个张量,则为 True,否则为 False。
- property is_data_dependent¶
如果此张量包含至少一个数据相关的维度,则为 True,否则为 False。
- property ndim: int¶
维度数量
- numel() int ¶
返回张量的元素数量
- Raises:
ValueError – 如果张量具有数据相关的维度。检查
is_data_dependent
以确定张量是否是数据相关的。- Returns:
张量的元素数量
- 返回类型:
int
- property scale: float¶
INT8 数据类型的比例。
- property strides: Tuple[int]¶
此张量的步幅。