docs.unity3d.com
    Show / Hide Table of Contents

    Class ArrayTensorData

    Represents internal Tensor data backed by a managed array.

    Inheritance
    Object
    ArrayTensorData
    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 ArrayTensorData : ITensorData, IDisposable, IConvertibleToBurstTensorData, IConvertibleToComputeTensorData

    Constructors

    ArrayTensorData(TensorShape, Boolean)

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

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

    ArrayTensorData(TensorShape, NativeTensorArray, Int32, Boolean)

    Initializes and returns an instance of ArrayTensorData with given storage and offset.

    Declaration
    public ArrayTensorData(TensorShape shape, NativeTensorArray array, int offset = 0, bool clearOnInit = true)
    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.

    Boolean clearOnInit

    Whether to zero the data on instantiation. The default value is true.

    Properties

    array

    The NativeTensorArray managed array containing the Tensor data.

    Declaration
    public NativeTensorArray array { get; }
    Property Value
    Type Description
    NativeTensorArray

    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

    ConvertToBurstTensorData(TensorShape)

    Implement this method to convert to BurstTensorData.

    Declaration
    public BurstTensorData ConvertToBurstTensorData(TensorShape shape)
    Parameters
    Type Name Description
    TensorShape shape
    Returns
    Type Description
    BurstTensorData
    Implements
    IConvertibleToBurstTensorData.ConvertToBurstTensorData(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 ArrayTensorData and any associated memory.

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

    Download<T>(Int32, Int32)

    Returns data from internal storage.

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

    Pin(Tensor, Boolean)

    Moves the tensor into memory on the CPU backend device.

    Declaration
    public static ArrayTensorData Pin(Tensor X, bool uploadCache = true)
    Parameters
    Type Name Description
    Tensor X
    Boolean uploadCache

    Whether to also move the existing tensor data to the CPU. The default value is true.

    Returns
    Type Description
    ArrayTensorData

    Reserve(Int32)

    Reserves memory for count elements.

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

    ScheduleAsyncDownload()

    Schedules asynchronous download of the internal data.

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

    ToString()

    Returns a summary of the storage used by the tensor array, as a string.

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

    Upload<T>(T[], Int32, Int32)

    Uploads the tensor data to internal storage.

    Declaration
    public void Upload<T>(T[] data, int srCount, int srcOffset = 0)
        where T : struct
    Parameters
    Type Name Description
    T[] data
    Int32 srCount
    Int32 srcOffset
    Type Parameters
    Name Description
    T
    Implements
    ITensorData.Upload<T>(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