Tensor#

class tensorrt.plugin.Tensor#

Representation of a tensor that carries data

Tensor objects are strictly descriptors of a tensor with an underlying data buffer. tensorrt.plugin does not provide any APIs that perform standard data-altering operations on Tensors.

Supports __cuda_array_interface__ for interoperability with other frameworks.

aliased(shape: Optional[Union[tensorrt.plugin._tensor.Shape, Tuple[int], tensorrt.tensorrt.PluginTensorDesc]] = None) tensorrt.plugin._tensor.Tensor#

Return a Tensor which has the same data_ptr as this but has the provided shape.

Parameters

shape (Union[Shape, Tuple[int], trt.PluginTensorDesc], optional) – Required shape of the new tensor (must have the same volume). Defaults to same shape.

Raises

ValueError – If shape is not a supported type or if it does not have the same volume

property data_ptr: int#

Pointer to the data buffer of this tensor

property dtype: tensorrt.tensorrt.DataType#

Data type of the tensor.

property format: tensorrt.tensorrt.TensorFormat#

The format of the tensor.

get_aliased() tensorrt.plugin._tensor.Tensor#
Returns

Returns Tensor of the tensor which this tensor is aliased to. Returns None is this tensor is not aliased to any other tensor.

property is_aliased#

True if this tensor is aliased to another tensor, False otherwise.

property is_data_dependent#

True if this tensor contains at least one data-dependent dimension, False otherwise.

property ndim: int#

Number of dimensions

numel() int#

Returns the number of elements of the tensor

Raises

ValueError – If the tensor has a data-dependent dimension. Examine is_data_dependent to determine whether the tensor is data-dependent.

Returns

Number of elements of the tensor

Return type

int

property scale: float#

Scale for INT8 data type.

property shape: tensorrt.plugin._tensor.Shape#

The (concrete) shape of the tensor.

property strides: Tuple[int]#

Strides of this tensor.