跳到主要内容

Tensor

_class _Tensor(info : Optional[TensorInfo] = None, array : Optional[ndarray] = None, tensor : Optional[Tensor] = None)

Represents an input, output, or intermediate computation result.

Constructor for the Tensor class.

Parameters:

  • info (TensorInfo object) -- The information of the tensor.

  • array (numpy.ndarray) -- The data of the tensor.

  • tensor (pytcim.Tensor) -- The existed pytcim tensor. Info and array will be ignored when tensor is set.

Methods

__init__Constructor for the Tensor class.
as_formularCreates a new Tensor object with normalized TensorInfo.
astypeCreates a new tensor with the specified target data type, and optionally casts the data of original tensor with the target data type, stores casted data in the new tenor.
bufferRetrieves the buffer that holds the data of the tensor.
castCreates a new tensor with the specified target data type, and optionally casts the data of original tensor with the target data type, stores casted data in the new tenor.
cast_toConverts tensor data to special data type.
cloneAllocates memory for a new current Tensor object that is a copy of the current Tensor object if auto_copy is true.
copy_toCopies the tensor data of the current Tensor object to another Tensor object.
deviceRetrieves the device type on which the tensor data is stored.
device_idRetrieves the logical ID of the Houmo device on which the tensor is stored.
infoRetrieves the information of the tensor associated with the current Tensor object.
mem_sizeRetrieves the actual allocated memory size for the tensor.
numpyRetrieves the data of the tensor.
select_batchSelects a batch of elements along the batch dimension from the original Tensor object, and returns a new Tensor object that shares the underlying memory with the original Tensor object.
select_roiSelects a Region of Interest (ROI) from the current tensor and returns a new Tensor object that shares the underlying memory with the original Tensor object.
set_zeroZeros all elements of the tensor in-place.
split_yuvSplits a YUV-formatted tensor into separate Y and UV tensors without additional memory allocation.
to_hostRetrieves or creates a tensor in host memory with tensor data based on the current Tensor object.