Class TensorByte
Represents data in a multidimensional array-like structure.
Ownership and lifetime:
- Disposed needs to be called on the main thread.
- Ownership is always to the owner of the object.
Data Representation:
- TensorShape represents the data layout of the tensor
- Data is held by a tensorData (ITensorData) which can be on a given backend
- Data is stored in a flattened row major format
- Data can be pending (ie computation is being done in parallel)
- call CompleteAllPendingOperations for a blocking call to finish computing the tensor's data
- call CompleteOperationsAndDownloadAsync/ReadbackRequest for a non blocking call to finish computing the tensor's data Data can be in a non readable type (GPU/NPU)
- Call CompleteOperationsAndDownload to make the tensor readable (this will fetch the data on the backend and convert it to a readable format)
- CompleteOperationsAndDownload is a blocking call if called on its own. for a non blocking call, make sure that CompleteOperationsAndDownloadAsync/ReadbackRequest have been called previously you can check that with IsReadbackRequestDone
Data manipulation
- ToReadOnlyArray returns a copy of the tensor's data
- dataOnBackend can be manipulated directly to avoid a unnecessary copy see ComputeTensorData/BurstTensorData for info
Implements
Inherited Members
Namespace: Unity.Sentis
Assembly: Unity.Sentis.dll
Syntax
public class TensorByte : Tensor, IDisposable
Properties
count
The length of the tensor.
Declaration
public override int count { get; }
Property Value
Type | Description |
---|---|
int |
Overrides
dataType
The data type of the elements of the tensor.
Declaration
public override DataType dataType { get; }
Property Value
Type | Description |
---|---|
DataType |
Overrides
Methods
AllocZeros(TensorShape)
Initializes and returns a tensor with the specified shape
and filled with 0
.
Declaration
public static TensorByte AllocZeros(TensorShape shape)
Parameters
Type | Name | Description |
---|---|---|
TensorShape | shape | The shape of the tensor. |
Returns
Type | Description |
---|---|
TensorByte | The instantiated zero tensor. |
UploadToDevice(ITensorData)
Uploads the tensor data to the destination data location on device.
Declaration
public override void UploadToDevice(ITensorData destination)
Parameters
Type | Name | Description |
---|---|---|
ITensorData | destination | The data on device to upload the tensor data to. |