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 onTensor
s.Supports __cuda_array_interface__ for interoperability with other frameworks.
- aliased(shape: Shape | Tuple[int] | PluginTensorDesc | None = None) Tensor ¶
Return a
Tensor
which has the samedata_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: DataType¶
Data type of the tensor.
- property format: TensorFormat¶
The format of the tensor.
- get_aliased() 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 strides: Tuple[int]¶
Strides of this tensor.