docs.unity3d.com
    Show / Hide Table of Contents

    Class ComputeTensorData

    Represents data storage for a Tensor as a compute buffer, for GPUCompute backend.

    Inheritance
    Object
    ComputeTensorData
    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 ComputeTensorData : ITensorData, IDisposable

    Constructors

    ComputeTensorData(TensorShape, Boolean)

    Initializes and returns an instance of ComputeTensorData, and allocates storage for a tensor with the shape of shape.

    Declaration
    public ComputeTensorData(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.

    ComputeTensorData(TensorShape, NativeTensorArray, Int32)

    Initializes and returns an instance of ComputeTensorData with given data and offset.

    Declaration
    public ComputeTensorData(TensorShape shape, NativeTensorArray array, int offset = 0)
    Parameters
    Type Name Description
    TensorShape shape

    The shape of the tensor data.

    NativeTensorArray array

    The allocated data to use as backing data.

    Int32 offset

    The integer offset from the start of the backing array. The default value is 0.

    Properties

    buffer

    The data storage as a compute buffer.

    Declaration
    public ComputeBuffer buffer { get; }
    Property Value
    Type Description
    ComputeBuffer

    deviceType

    On what device backend are the data elements stored.

    Declaration
    public DeviceType deviceType { get; }
    Property Value
    Type Description
    DeviceType
    Implements
    ITensorData.deviceType

    maxCapacity

    The maximum count of the stored data elements.

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

    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()

    Dispose()

    Disposes of the ComputeTensorData 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 ComputeTensorData.

    Declaration
    protected void Finalize()

    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 the tensor into GPU memory on the GPUCompute backend device.

    Declaration
    public static ComputeTensorData Pin(Tensor X, bool clearOnInit = true)
    Parameters
    Type Name Description
    Tensor X
    Boolean clearOnInit
    Returns
    Type Description
    ComputeTensorData

    Reserve(Int32)

    Reserves memory for count elements.

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

    ToString()

    Returns a string that represents the ComputeTensorData.

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

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