docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class ComputeTensorData

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

    Inheritance
    object
    ComputeTensorData
    Implements
    ITensorData
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.InferenceEngine
    Assembly: Unity.InferenceEngine.dll
    Syntax
    [MovedFrom("Unity.Sentis")]
    public class ComputeTensorData : ITensorData, IDisposable

    Constructors

    ComputeTensorData(int, bool)

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

    Declaration
    public ComputeTensorData(int count, bool clearOnInit = false)
    Parameters
    Type Name Description
    int count

    The number of elements.

    bool clearOnInit

    Whether to zero the data on allocation. The default value is false.

    Properties

    backendType

    On what backend are the data elements stored.

    Declaration
    public BackendType backendType { get; }
    Property Value
    Type Description
    BackendType

    buffer

    The data storage as a compute buffer.

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

    maxCapacity

    The maximum count of the stored data elements.

    Declaration
    public int maxCapacity { get; }
    Property Value
    Type Description
    int

    Methods

    CompleteAllPendingOperations()

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

    Declaration
    public void CompleteAllPendingOperations()

    ConvertToCPUTensorData(int)

    Implement this method to convert to CPUTensorData.

    Declaration
    public CPUTensorData ConvertToCPUTensorData(int dstCount)
    Parameters
    Type Name Description
    int dstCount

    The number of elements.

    Returns
    Type Description
    CPUTensorData

    Converted CPUTensorData.

    Dispose()

    Disposes of the ComputeTensorData and any associated memory.

    Declaration
    public void Dispose()

    DownloadAsync<T>(int)

    Awaitable contiguous block of data from internal storage.

    Declaration
    public Awaitable<NativeArray<T>> DownloadAsync<T>(int dstCount) where T : unmanaged
    Parameters
    Type Name Description
    int dstCount

    The number of elements to download.

    Returns
    Type Description
    Awaitable<NativeArray<T>>

    A awaitable native array of downloaded elements.

    Type Parameters
    Name Description
    T

    The data type of the elements.

    Download<T>(int)

    Blocking call that returns a contiguous block of data from internal storage.

    Declaration
    public NativeArray<T> Download<T>(int dstCount) where T : unmanaged
    Parameters
    Type Name Description
    int dstCount

    The number of elements to download.

    Returns
    Type Description
    NativeArray<T>

    A native array of downloaded elements.

    Type Parameters
    Name Description
    T

    The data type of the elements.

    ~ComputeTensorData()

    Finalizes the ComputeTensorData.

    Declaration
    protected ~ComputeTensorData()

    IsReadbackRequestDone()

    Checks if asynchronous readback request is done.

    Declaration
    public bool IsReadbackRequestDone()
    Returns
    Type Description
    bool

    Whether async readback is successful.

    Pin(Tensor, bool)

    Moves the tensor into GPU memory on the GPUCompute backend device.

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

    The tensor to move to the compute backend.

    bool clearOnInit

    Whether to zero the data on pinning. The default value is false.

    Returns
    Type Description
    ComputeTensorData

    The pinned ComputeTensorData.

    ReadbackRequest()

    Schedules asynchronous readback of the internal data.

    Declaration
    public void ReadbackRequest()

    ToString()

    Returns a string that represents the ComputeTensorData.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The string summary of the ComputeTensorData.

    Overrides
    object.ToString()

    Upload<T>(NativeArray<T>, int)

    Uploads a contiguous block of tensor data to internal storage.

    Declaration
    public void Upload<T>(NativeArray<T> data, int srcCount) where T : unmanaged
    Parameters
    Type Name Description
    NativeArray<T> data

    The data to upload.

    int srcCount

    The number of elements to upload.

    Type Parameters
    Name Description
    T

    The type of data to upload.

    Implements

    ITensorData
    IDisposable
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)