跳到主要内容

TensorInfo

_class _TensorInfo(info : Optional[TensorInfo] = None)

Represents information about a tensor, including its shape, data type, memory layout, and other relevant attributes. This class provides methods to retrieve tensor information.

Attributes:

  • tcim_numpy_map (dict) -- The supported data types of the tensor in the current TensorInfo object.

    • pytcim.INT8: np.int8

    • pytcim.UINT8: np.uint8

    • pytcim.INT16: np.int16

    • pytcim.UINT16: np.uint16

    • pytcim.INT32: np.int32

    • pytcim.UINT32: np.uint32

    • pytcim.FLOAT16: np.float16

    • pytcim.FLOAT32: np.float32

  • numpy_tcim_map (dict) -- The supported target data types that the tensor of the current TensorInfo object can be converted to.

    • np.int8: pytcim.INT8

    • np.uint8: pytcim.UINT8

    • np.int16: pytcim.INT16

    • np.uint16: pytcim.UINT16

    • np.int32: pytcim.INT32

    • np.uint32: pytcim.UINT32

    • np.float16: pytcim.FLOAT16

    • np.float32: pytcim.FLOAT32

Constructor for the TensorInfo class.

Methods

__init__Constructor for the TensorInfo class.
as_formularCreates a TensorInfo object with normalized shape and strides.
ascontiguousCreates a TensorInfo object with updated memory layout information to contiguous for the tensor.
astypeUpdates the data type of the tensor in the current TensorInfo object.
cloneCreates a copy of the current TensorInfo object.
create_ndCreates a TensorInfo object for a non-image (ND) tensor with the specified shape, data type, and stride.
create_yuvCreates a TensorInfo object for a YUV image with the specified batch size, width, height, and format.
dtypeRetrieves the data type of the tensor associated with the current TensorInfo object.
formatRetrieves the data format of the tensor associated with the current TensorInfo object.
is_contiguousChecks if the tensor data associated with the current TensorInfo has a contiguous memory layout.
is_matchChecks if the associated tensors match for mutual copying.
mem_sizeRetrieves the memory size (in bytes) allocated for the tensor associated with the current TensorInfo object.
merge_yuvCreates a TensorInfo object for a merged YUV tensor with the given tensor information of Y tensor (Y component) and UV tensor (UV component).
shapeRetrieves the shape of the tensor associated with the current TensorInfo object.
strideRetrieves the stride of the tensor associated with the current TensorInfo object.