Class CPUTensorData
Represents Burst-specific internal data storage for a Tensor.
Inherited Members
Namespace: Unity.InferenceEngine
Assembly: Unity.InferenceEngine.dll
Syntax
[MovedFrom("Unity.Sentis")]
public class CPUTensorData : ITensorData, IDisposable
  Constructors
CPUTensorData(int, bool)
Initializes and returns an instance of CPUTensorData, and allocates storage for a tensor with the shape of shape.
Declaration
public CPUTensorData(int count, bool clearOnInit = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| int | count | The number of elements.  | 
      
| bool | clearOnInit | Whether to zero the data on allocation. The default value is   | 
      
CPUTensorData(NativeTensorArray)
Initializes and returns an instance of CPUTensorData from a NativeTensorArray.
Declaration
public CPUTensorData(NativeTensorArray data)
  Parameters
| Type | Name | Description | 
|---|---|---|
| NativeTensorArray | data | The elements of the tensor data as a   | 
      
Properties
array
The NativeTensorArray managed array containing the Tensor data.
Declaration
public NativeTensorArray array { get; }
  Property Value
| Type | Description | 
|---|---|
| NativeTensorArray | 
backendType
On what backend are the data elements stored.
Declaration
public BackendType backendType { get; }
  Property Value
| Type | Description | 
|---|---|
| BackendType | 
fence
A read fence job handle. You can use fence as a dependsOn argument when you schedule a job that reads data. The job will start when the tensor data is ready for read access.
Declaration
public JobHandle fence { get; set; }
  Property Value
| Type | Description | 
|---|---|
| JobHandle | 
maxCapacity
The maximum count of the stored data elements.
Declaration
public int maxCapacity { get; }
  Property Value
| Type | Description | 
|---|---|
| int | 
rawPtr
The raw memory pointer for the resource.
Declaration
public void* rawPtr { get; }
  Property Value
| Type | Description | 
|---|---|
| void* | 
reuse
A write fence job handle. You can use reuse as a dependsOn argument when you schedule a job that reads data. The job will start when the tensor data is ready for write access.
Declaration
public JobHandle reuse { get; set; }
  Property Value
| Type | Description | 
|---|---|
| JobHandle | 
Methods
CompleteAllPendingOperations()
Blocking call to make sure that internal data is correctly written to and available for CPU read back.
Declaration
public void CompleteAllPendingOperations()
  ConvertToComputeTensorData(int)
Implement this method to convert to ComputeTensorData.
Declaration
public ComputeTensorData ConvertToComputeTensorData(int count)
  Parameters
| Type | Name | Description | 
|---|---|---|
| int | count | 
Returns
| Type | Description | 
|---|---|
| ComputeTensorData | Converted   | 
      
Dispose()
Disposes of the CPUTensorData and any associated memory.
Declaration
public void Dispose()
  DownloadAsync<T>(int)
Awaitable contiguous block of data from internal storage.
Declaration
public Awaitable<NativeArray<T>> DownloadAsync<T>(int dstCount) where T : unmanaged
  Parameters
| Type | Name | Description | 
|---|---|---|
| int | dstCount | The number of elements to download.  | 
      
Returns
| Type | Description | 
|---|---|
| Awaitable<NativeArray<T>> | A awaitable native array of downloaded elements.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The data type of the elements.  | 
      
Download<T>(int)
Blocking call that returns a contiguous block of data from internal storage.
Declaration
public NativeArray<T> Download<T>(int dstCount) where T : unmanaged
  Parameters
| Type | Name | Description | 
|---|---|---|
| int | dstCount | The number of elements to download.  | 
      
Returns
| Type | Description | 
|---|---|
| NativeArray<T> | A native array of downloaded elements.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The data type of the elements.  | 
      
~CPUTensorData()
Finalizes the CPUTensorData.
Declaration
protected ~CPUTensorData()
  IsReadbackRequestDone()
Checks if asynchronous readback request is done.
Declaration
public bool IsReadbackRequestDone()
  Returns
| Type | Description | 
|---|---|
| bool | Whether async readback is successful.  | 
      
Pin(Tensor, bool)
Moves a tensor into memory on the CPU backend device.
Declaration
public static CPUTensorData Pin(Tensor X, bool clearOnInit = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Tensor | X | The   | 
      
| bool | clearOnInit | Whether to initialize the backend data. The default value is   | 
      
Returns
| Type | Description | 
|---|---|
| CPUTensorData | The pinned   | 
      
ReadbackRequest()
Schedules asynchronous readback of the internal data.
Declaration
public void ReadbackRequest()
  ToString()
Returns a string that represents the CPUTensorData.
Declaration
public override string ToString()
  Returns
| Type | Description | 
|---|---|
| string | The string summary of the   | 
      
Overrides
Upload<T>(NativeArray<T>, int)
Uploads a contiguous block of tensor data to internal storage.
Declaration
public void Upload<T>(NativeArray<T> data, int srcCount) where T : unmanaged
  Parameters
| Type | Name | Description | 
|---|---|---|
| NativeArray<T> | data | The data to upload.  | 
      
| int | srcCount | The number of elements to upload.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of data to upload.  |