Class SharedArrayTensorData
Represents internal Tensor
data backed by a managed array and shared between multiple tensors.
Inheritance
SharedArrayTensorData
Syntax
public class SharedArrayTensorData : ITensorData, IDisposable, IConvertibleToBurstTensorData, IConvertibleToComputeTensorData, IConvertibleToArrayTensorData, IReadableTensorData
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
Declaration
public NativeTensorArray array { get; }
Property Value
count
The number of data elements.
Declaration
public int count { get; }
Property Value
deviceType
On what device backend are the data elements stored.
Declaration
public DeviceType deviceType { get; }
Property Value
Implements
maxCapacity
The maximum count of the stored data elements.
Declaration
public virtual int maxCapacity { get; }
Property Value
Implements
offset
Offset in the storage array.
Declaration
public int offset { get; }
Property Value
shape
The shape of the tensor using this data as a TensorShape
.
Declaration
public TensorShape shape { get; }
Property Value
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
Implements
Clone()
Returns a deep copy of the internal storage.
Declaration
public ITensorData Clone()
Returns
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
Returns
Implements
ConvertToBurstTensorData(TensorShape)
Implement this method to convert to BurstTensorData
.
Declaration
public BurstTensorData ConvertToBurstTensorData(TensorShape shape)
Parameters
Returns
Implements
ConvertToComputeTensorData(TensorShape)
Implement this method to convert to ComputeTensorData
.
Declaration
public ComputeTensorData ConvertToComputeTensorData(TensorShape shape)
Parameters
Returns
Implements
Dispose()
Disposes of the SharedArrayTensorData
and any associated memory.
Declaration
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 Parameters
Implements
Finalize()
Finalizes the SharedArrayTensorData
.
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 Parameters
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 Parameters
Implements
IsAsyncReadbackRequestDone()
Checks if asynchronous readback request it done.
Returns true if async readback is successful.
Declaration
public bool IsAsyncReadbackRequestDone()
Returns
Implements
Reserve(Int32)
Reserves memory 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
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 Parameters
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
Implements
ToString()
Returns a string that represents the SharedArrayTensorData
.
Declaration
public override string ToString()
Returns
Overrides
Upload<T>(NativeArray<T>, Int32, Int32)
Uploads the tensor data to internal storage.
Declaration
public void Upload<T>(NativeArray<T> data, int srcCount, int srcOffset = 0)
where T : struct
Parameters
Type Parameters
Implements