docs.unity3d.com
    Show / Hide Table of Contents

    Class BurstTensorData

    Represents Burst-specific internal data storage for a Tensor.

    Inheritance
    Object
    BurstTensorData
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    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 ArrayTensorData to convert.

    BurstTensorData(SharedArrayTensorData)

    Initializes and returns an instance of BurstTensorData from a SharedArrayTensorData.

    Declaration
    public BurstTensorData(SharedArrayTensorData sharedArray)
    Parameters
    Type Name Description
    SharedArrayTensorData sharedArray

    The SharedArrayTensorData to convert.

    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 Array.

    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 true.

    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 NativeTensorArray.

    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
    ITensorData.deviceType

    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
    IDependableMemoryResource.fence

    maxCapacity

    The maximum count of the stored data elements.

    Declaration
    public int maxCapacity { get; }
    Property Value
    Type Description
    Int32
    Implements
    ITensorData.maxCapacity

    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
    IDependableMemoryResource.rawPtr

    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
    IDependableMemoryResource.reuse

    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
    ITensorData.AsyncReadbackRequest(Action<Boolean>)

    Clone()

    Returns a deep copy of the internal storage.

    Declaration
    public ITensorData Clone()
    Returns
    Type Description
    ITensorData
    Implements
    ITensorData.Clone()

    CompleteAllPendingOperations()

    Blocking call to make sure that internal data is correctly written to and available for CPU read back.

    Declaration
    public void CompleteAllPendingOperations()
    Implements
    ITensorData.CompleteAllPendingOperations()

    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
    IConvertibleToArrayTensorData.ConvertToArrayTensorData(TensorShape)

    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
    IConvertibleToComputeTensorData.ConvertToComputeTensorData(TensorShape)

    Dispose()

    Disposes of the BurstTensorData and any associated memory.

    Declaration
    public void Dispose()
    Implements
    IDisposable.Dispose()

    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
    ITensorData.Download<T>(Int32, Int32)

    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
    IReadableTensorData.Get<T>(Int32)

    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
    IReadableTensorData.GetReadOnlyNativeArrayHandle<T>(Int32, Int32)

    IsAsyncReadbackRequestDone()

    Checks if asynchronous readback request it done.

    Returns true if async readback is successful.

    Declaration
    public bool IsAsyncReadbackRequestDone()
    Returns
    Type Description
    Boolean
    Implements
    ITensorData.IsAsyncReadbackRequestDone()

    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 Tensor to move to the CPU.

    Boolean clearOnInit

    Whether to initialize the backend data. The default value is true.

    Returns
    Type Description
    BurstTensorData

    Reserve(Int32)

    Reserves storage for count elements.

    Declaration
    public void Reserve(int count)
    Parameters
    Type Name Description
    Int32 count
    Implements
    ITensorData.Reserve(Int32)

    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
    IReadableTensorData.Set<T>(Int32, T)

    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
    IReadableTensorData.ToArray<T>(Int32, Int32)

    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
    IReadableTensorData.ToReadOnlySpan<T>(Int32, Int32)

    ToString()

    Returns a string that represents the BurstTensorData.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    Object.ToString()

    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
    Implements
    ITensorData.Upload<T>(NativeArray<T>, Int32, Int32)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023