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
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.