Class BurstTensorData
Represents Burst-specific internal data storage for a Tensor.
Inherited Members
Namespace: Unity.Sentis
Syntax
public class BurstTensorData : ITensorData, IDisposable, IDependableMemoryResource, IConvertibleToComputeTensorData, IConvertibleToArrayTensorData, IReadableTensorData
Constructors
BurstTensorData(ArrayTensorData)
Initializes and returns an instance of BurstTensorData from an ArrayTensorData.
Declaration
public BurstTensorData(ArrayTensorData sharedArray)
Parameters
| Type | Name | Description |
|---|---|---|
| ArrayTensorData | sharedArray | The |
BurstTensorData(SharedArrayTensorData)
Initializes and returns an instance of BurstTensorData from a SharedArrayTensorData.
Declaration
public BurstTensorData(SharedArrayTensorData sharedArray)
Parameters
| Type | Name | Description |
|---|---|---|
| SharedArrayTensorData | sharedArray | The |
BurstTensorData(TensorShape, Array)
Initializes and returns an instance of BurstTensorData from a TensorShape and an Array.
Declaration
public BurstTensorData(TensorShape shape, Array data)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | shape | The shape of the tensor data. |
| Array | data | The values of the tensor data as an |
BurstTensorData(TensorShape, Boolean)
Initializes and returns an instance of BurstTensorData, and allocates storage for a tensor with the shape of shape.
Declaration
public BurstTensorData(TensorShape shape, bool clearOnInit = true)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | shape | The shape of the tensor data to allocate. |
| Boolean | clearOnInit | Whether to zero the data on allocation. The default value is |
BurstTensorData(TensorShape, NativeTensorArray, Int32)
Initializes and returns an instance of BurstTensorData from a NativeTensorArray and an offset.
Declaration
public BurstTensorData(TensorShape shape, NativeTensorArray data, int offset = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | shape | The shape of the tensor data. |
| NativeTensorArray | data | The values of the tensor data as a |
| Int32 | offset | The integer offset for the backing data. |
Properties
array
The NativeTensorArray managed array containing the Tensor data.
Declaration
public NativeTensorArray array { get; }
Property Value
| Type | Description |
|---|---|
| NativeTensorArray |
count
The length of the tensor using this data.
Declaration
public int count { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
deviceType
On what device backend are the data elements stored.
Declaration
public virtual DeviceType deviceType { get; }
Property Value
| Type | Description |
|---|---|
| DeviceType |
Implements
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 |
Implements
maxCapacity
The maximum count of the stored data elements.
Declaration
public int maxCapacity { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Implements
offset
The integer offset for the backing data.
Declaration
public int offset { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
rawPtr
The raw memory pointer for the resource.
Declaration
public void *rawPtr { get; }
Property Value
| Type | Description |
|---|---|
| Void* |
Implements
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 |
Implements
shape
The shape of the tensor using this data as a TensorShape.
Declaration
public TensorShape shape { get; }
Property Value
| Type | Description |
|---|---|
| TensorShape |
Methods
AsyncReadbackRequest(Action<Boolean>)
Schedules asynchronous readback of the internal data.
Invokes callback when async readback is finished.
Boolean indicates if async readback is successful.
Declaration
public void AsyncReadbackRequest(Action<bool> callback = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<Boolean> | callback |
Implements
Clone()
Returns a deep copy of the internal storage.
Declaration
public ITensorData Clone()
Returns
| Type | Description |
|---|---|
| ITensorData |
Implements
CompleteAllPendingOperations()
Blocking call to make sure that internal data is correctly written to and available for CPU read back.
Declaration
public void CompleteAllPendingOperations()
Implements
ConvertToArrayTensorData(TensorShape)
Implement this method to convert to ArrayTensorData.
Declaration
public ArrayTensorData ConvertToArrayTensorData(TensorShape shape)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | shape |
Returns
| Type | Description |
|---|---|
| ArrayTensorData |
Implements
ConvertToComputeTensorData(TensorShape)
Implement this method to convert to ComputeTensorData.
Declaration
public ComputeTensorData ConvertToComputeTensorData(TensorShape shape)
Parameters
| Type | Name | Description |
|---|---|---|
| TensorShape | shape |
Returns
| Type | Description |
|---|---|
| ComputeTensorData |
Implements
Dispose()
Disposes of the BurstTensorData and any associated memory.
Declaration
public void Dispose()
Implements
Download<T>(Int32, Int32)
Returns data from internal storage.
Declaration
public NativeArray<T> Download<T>(int dstCount, int srcOffset = 0)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dstCount | |
| Int32 | srcOffset |
Returns
| Type | Description |
|---|---|
| NativeArray<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Implements
Finalize()
Finalizes the BurstTensorData.
Declaration
protected void Finalize()
Get<T>(Int32)
Returns a data element at index.
Declaration
public T Get<T>(int index)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index |
Returns
| Type | Description |
|---|---|
| T |
Type Parameters
| Name | Description |
|---|---|
| T |
Implements
GetReadOnlyNativeArrayHandle<T>(Int32, Int32)
Returns a ReadOnlyNativeArray handle on the linear memory data.
Declaration
public NativeArray<T>.ReadOnly GetReadOnlyNativeArrayHandle<T>(int dstCount, int srcOffset = 0)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dstCount | |
| Int32 | srcOffset |
Returns
| Type | Description |
|---|---|
| NativeArray.ReadOnly<> |
Type Parameters
| Name | Description |
|---|---|
| T |
Implements
IsAsyncReadbackRequestDone()
Checks if asynchronous readback request it done.
Returns true if async readback is successful.
Declaration
public bool IsAsyncReadbackRequestDone()
Returns
| Type | Description |
|---|---|
| Boolean |
Implements
Pin(Tensor, Boolean)
Moves a tensor into memory on the CPU backend device.
Declaration
public static BurstTensorData Pin(Tensor X, bool clearOnInit = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | The |
| Boolean | clearOnInit | Whether to initialize the backend data. The default value is |
Returns
| Type | Description |
|---|---|
| BurstTensorData |
Reserve(Int32)
Reserves storage for count elements.
Declaration
public void Reserve(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | count |
Implements
Set<T>(Int32, T)
Sets value data element at index.
Declaration
public void Set<T>(int index, T value)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | index | |
| T | value |
Type Parameters
| Name | Description |
|---|---|
| T |
Implements
ToArray<T>(Int32, Int32)
Returns a array that is a copy of the linear memory data.
Declaration
public T[] ToArray<T>(int dstCount, int srcOffset = 0)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dstCount | |
| Int32 | srcOffset |
Returns
| Type | Description |
|---|---|
| T[] |
Type Parameters
| Name | Description |
|---|---|
| T |
Implements
ToReadOnlySpan<T>(Int32, Int32)
Returns a ReadOnlySpan on the linear memory data.
Declaration
public ReadOnlySpan<T> ToReadOnlySpan<T>(int dstCount, int srcOffset = 0)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | dstCount | |
| Int32 | srcOffset |
Returns
| Type | Description |
|---|---|
| ReadOnlySpan<T> |
Type Parameters
| Name | Description |
|---|---|
| T |
Implements
ToString()
Returns a string that represents the BurstTensorData.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
Upload<T>(NativeArray<T>, Int32, Int32)
Uploads data to internal storage.
Declaration
public void Upload<T>(NativeArray<T> data, int srcCount, int srcOffset = 0)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| NativeArray<T> | data | |
| Int32 | srcCount | |
| Int32 | srcOffset |
Type Parameters
| Name | Description |
|---|---|
| T |