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
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
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 T[] Download<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
Finalize()
Finalizes the BurstTensorData.
Declaration
protected void Finalize()
Pin(Tensor, Boolean)
Moves a tensor into memory on the CPU backend device.
Declaration
public static BurstTensorData Pin(Tensor X, bool uploadCache = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Tensor | X | The |
| Boolean | uploadCache | Whether to also move the existing tensor data to the CPU. 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
ScheduleAsyncDownload()
Schedules asynchronous download of internal data.
Declaration
public bool ScheduleAsyncDownload()
Returns
| Type | Description |
|---|---|
| Boolean |
|
Implements
SharedAccess(out Int32)
Returns the backing data and outputs the offset.
Declaration
public NativeTensorArray SharedAccess(out int offset)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | offset | The integer offset in the backing data. |
Returns
| Type | Description |
|---|---|
| NativeTensorArray | The internal |
ToString()
Returns a string that represents the BurstTensorData.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
Upload<T>(T[], Int32, Int32)
Uploads data to internal storage.
Declaration
public void Upload<T>(T[] data, int srcCount, int srcOffset = 0)
where T : struct
Parameters
| Type | Name | Description |
|---|---|---|
| T[] | data | |
| Int32 | srcCount | |
| Int32 | srcOffset |
Type Parameters
| Name | Description |
|---|---|
| T |