Class SharedArrayTensorData
Represents internal Tensor
data backed by a managed array and shared between multiple tensors.
Inherited Members
Namespace: Unity.Sentis
Syntax
public class SharedArrayTensorData : ITensorData, IDisposable, IConvertibleToBurstTensorData, IConvertibleToComputeTensorData, IConvertibleToArrayTensorData
Constructors
SharedArrayTensorData(TensorShape, Array)
Initializes and returns an instance of SharedArrayTensorData
with a given array of data.
Declaration
public SharedArrayTensorData(TensorShape shape, Array data)
Parameters
Type | Name | Description |
---|---|---|
TensorShape | shape | The shape of the tensor data. |
Array | data | The data to use as backing data. |
SharedArrayTensorData(TensorShape, NativeTensorArray, Int32)
Initializes and returns an instance of SharedArrayTensorData
with a given NativeTensorArray
of data.
Declaration
public SharedArrayTensorData(TensorShape shape, NativeTensorArray data, int offset = 0)
Parameters
Type | Name | Description |
---|---|---|
TensorShape | shape | The shape of the tensor data. |
NativeTensorArray | data | The allocated data to use as backing data. |
Int32 | offset | The integer offset to use for the data. |
Properties
array
The data storage array
Declaration
public NativeTensorArray array { get; }
Property Value
Type | Description |
---|---|
NativeTensorArray |
count
The number of data elements.
Declaration
public int count { get; }
Property Value
Type | Description |
---|---|
Int32 |
deviceType
On what device backend are the data elements stored
Declaration
public DeviceType deviceType { get; }
Property Value
Type | Description |
---|---|
DeviceType |
Implements
maxCapacity
The maximum count of the stored data elements.
Declaration
public virtual int maxCapacity { get; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
offset
Offset in the storage array.
Declaration
public int offset { get; }
Property Value
Type | Description |
---|---|
Int32 |
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
ConvertToBurstTensorData(TensorShape)
Implement this method to convert to BurstTensorData
.
Declaration
public BurstTensorData ConvertToBurstTensorData(TensorShape shape)
Parameters
Type | Name | Description |
---|---|---|
TensorShape | shape |
Returns
Type | Description |
---|---|
BurstTensorData |
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 SharedArrayTensorData
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 SharedArrayTensorData
.
Declaration
protected void Finalize()
Reserve(Int32)
Reserves memory for count
elements.
Declaration
public void Reserve(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count |
Implements
ScheduleAsyncDownload()
Schedules asynchronous download of the 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 SharedArrayTensorData
.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
Upload<T>(T[], Int32, Int32)
Uploads the tensor 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 |