docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class TextureTensorData

    Represents the data storage for a 'Tensor' as a render texture, for backends that use GPU pixel shaders.

    Sentis packs the tensor data into the pixels of an RGBA float4 texture.

    Sentis chooses a single tensor dimension as the blocked axis, across which data is chunked in float4 blocks.

    Tensor dimensions don't map directly to texture dimensions. Sentis creates the texture with dimensions large enough to fit all the data and pixel shaders index the data based on both the tensor and texture dimensions (see example below).

    Inheritance
    object
    TextureTensorData
    Implements
    ITensorData
    IDisposable
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.Sentis
    Assembly: Unity.Sentis.dll
    Syntax
    public class TextureTensorData : ITensorData, IDisposable

    Constructors

    TextureTensorData(DataType, TensorShape, int, bool)

    Initializes and returns an instance of TextureTensorData with given shape and blocked axis. A RenderTexture is allocated to the correct size.

    Declaration
    public TextureTensorData(DataType dataType, TensorShape shape, int axis, bool clearOnInit = false)
    Parameters
    Type Name Description
    DataType dataType

    The data type of the tensor.

    TensorShape shape

    The (unblocked) shape of the tensor.

    int axis

    The axis on which to block the shape.

    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

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

    Dispose()

    Disposes of the TextureTensorData and any associated memory.

    Declaration
    public void Dispose()

    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.

    ~TextureTensorData()

    Finalizes the TextureTensorData.

    Declaration
    protected ~TextureTensorData()

    IsReadbackRequestDone()

    Checks if asynchronous readback request is done.

    Declaration
    public bool IsReadbackRequestDone()
    Returns
    Type Description
    bool

    Whether async readback is successful.

    Pin(Tensor, int, bool)

    Moves the tensor into GPU memory on the GPUPixel back end device.

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

    The tensor to move to the compute backend.

    int blockAxis

    Which axis to block the tensor shape on.

    bool clearOnInit

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

    Returns
    Type Description
    TextureTensorData

    The pinned TextureTensorData.

    ReadbackRequest()

    Schedules asynchronous readback of the internal data.

    Declaration
    public void ReadbackRequest()

    ReadbackRequestAsync()

    Declaration
    public Task<bool> ReadbackRequestAsync()
    Returns
    Type Description
    Task<bool>

    ToString()

    Returns a string that represents the TextureTensorData.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    The summary string of the TextureTensorData.

    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 © 2024 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)