docs.unity3d.com
    Show / Hide Table of Contents

    Class NativeTensorArray

    Represents an area of native memory that's exposed to managed code.

    Inheritance
    Object
    NativeTensorArray
    NativeTensorArrayFromManagedArray
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: Unity.Sentis
    Syntax
    public class NativeTensorArray : IDisposable

    Constructors

    NativeTensorArray(Int32, Boolean, Allocator)

    Initializes and returns an instance of NativeTensorArray with a given length.

    Declaration
    public NativeTensorArray(int length, bool clearOnInit = true, Allocator allocator = Allocator.Persistent)
    Parameters
    Type Name Description
    Int32 length

    The integer number of elements to allocate.

    Boolean clearOnInit

    Whether to zero the data after allocating.

    Allocator allocator

    The allocation type to use as an Allocator.

    NativeTensorArray(SafeHandle, Int32)

    Declaration
    protected NativeTensorArray(SafeHandle safeHandle, int dataLength)
    Parameters
    Type Name Description
    SafeHandle safeHandle
    Int32 dataLength

    Fields

    m_SafeHandle

    Declaration
    protected readonly SafeHandle m_SafeHandle
    Field Value
    Type Description
    SafeHandle

    Properties

    Disposed

    Whether the backing data is disposed.

    Declaration
    public bool Disposed { get; }
    Property Value
    Type Description
    Boolean

    Length

    The number of allocated elements.

    Declaration
    public int Length { get; }
    Property Value
    Type Description
    Int32

    LongLength

    The number of allocated elements as a 64-bit integer.

    Declaration
    public long LongLength { get; }
    Property Value
    Type Description
    Int64

    RawPtr

    The raw pointer of the backing data.

    Declaration
    public virtual void *RawPtr { get; }
    Property Value
    Type Description
    Void*

    SizeOfType

    The size in bytes of an element of the stored type.

    Declaration
    public int SizeOfType { get; }
    Property Value
    Type Description
    Int32

    Methods

    AddressAt<T>(Int64)

    Returns the raw pointer of the backing data at a given index.

    Declaration
    public T*AddressAt<T>(long index)
        where T : struct
    Parameters
    Type Name Description
    Int64 index
    Returns
    Type Description
    T*
    Type Parameters
    Name Description
    T

    AsReadOnlySpan<T>(Int32, Int32)

    Declaration
    public ReadOnlySpan<T> AsReadOnlySpan<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

    BlockCopy(Byte[], Int32, NativeTensorArray, Int32, Int32)

    Copies the data from a source byte array to a destination NativeTensorArray up to a given length starting from given offsets.

    Declaration
    public static void BlockCopy(byte[] sourceArray, int sourceByteOffset, NativeTensorArray destinationArray, int destinationByteOffset, int lengthInBytes)
    Parameters
    Type Name Description
    Byte[] sourceArray
    Int32 sourceByteOffset
    NativeTensorArray destinationArray
    Int32 destinationByteOffset
    Int32 lengthInBytes

    BlockCopy(NativeTensorArray, Int32, Byte[], Int32, Int32)

    Copies the data from a source NativeTensorArray to a destination byte array up to a given length starting from given offsets.

    Declaration
    public static void BlockCopy(NativeTensorArray sourceArray, int sourceOffset, byte[] destinationArray, int destinationByteOffset, int lengthInBytes)
    Parameters
    Type Name Description
    NativeTensorArray sourceArray
    Int32 sourceOffset
    Byte[] destinationArray
    Int32 destinationByteOffset
    Int32 lengthInBytes

    Copy(NativeTensorArray, Int32, NativeTensorArray, Int32, Int32)

    Copies the data from a source NativeTensorArray to a destination NativeTensorArray up to a given length starting from given indexes.

    Declaration
    public static void Copy(NativeTensorArray sourceArray, int sourceIndex, NativeTensorArray destinationArray, int destinationIndex, int length)
    Parameters
    Type Name Description
    NativeTensorArray sourceArray
    Int32 sourceIndex
    NativeTensorArray destinationArray
    Int32 destinationIndex
    Int32 length

    Copy(NativeTensorArray, NativeTensorArray, Int32, Int32)

    Copies the data from a source NativeTensorArray to a destination NativeTensorArray up to a given length.

    Declaration
    public static void Copy(NativeTensorArray sourceArray, NativeTensorArray destinationArray, int length = -1, int srcIndex = 0)
    Parameters
    Type Name Description
    NativeTensorArray sourceArray
    NativeTensorArray destinationArray
    Int32 length
    Int32 srcIndex

    Copy<T>(T[], Int32, NativeTensorArray, Int32, Int32)

    Copies the data from a source array to a destination NativeTensorArray up to a given length starting from given indexes.

    Declaration
    public static void Copy<T>(T[] sourceArray, int sourceIndex, NativeTensorArray destinationArray, int destinationIndex, int length)
        where T : struct
    Parameters
    Type Name Description
    T[] sourceArray
    Int32 sourceIndex
    NativeTensorArray destinationArray
    Int32 destinationIndex
    Int32 length
    Type Parameters
    Name Description
    T

    Copy<T>(T[], NativeTensorArray, Int32, Int32)

    Copies the data from a source array to a destination NativeTensorArray up to a given length.

    Declaration
    public static void Copy<T>(T[] sourceArray, NativeTensorArray destinationArray, int length = -1, int srcIndex = 0)
        where T : struct
    Parameters
    Type Name Description
    T[] sourceArray
    NativeTensorArray destinationArray
    Int32 length
    Int32 srcIndex
    Type Parameters
    Name Description
    T

    Copy<T>(NativeArray<T>, Int32, NativeTensorArray, Int32, Int32)

    Declaration
    public static void Copy<T>(NativeArray<T> sourceArray, int sourceIndex, NativeTensorArray destinationArray, int destinationIndex, int length)
        where T : struct
    Parameters
    Type Name Description
    NativeArray<T> sourceArray
    Int32 sourceIndex
    NativeTensorArray destinationArray
    Int32 destinationIndex
    Int32 length
    Type Parameters
    Name Description
    T

    Copy<T>(NativeArray<T>, NativeTensorArray, Int32, Int32)

    Declaration
    public static void Copy<T>(NativeArray<T> sourceArray, NativeTensorArray destinationArray, int length = -1, int srcIndex = 0)
        where T : struct
    Parameters
    Type Name Description
    NativeArray<T> sourceArray
    NativeTensorArray destinationArray
    Int32 length
    Int32 srcIndex
    Type Parameters
    Name Description
    T

    Copy<T>(NativeArray<T>.ReadOnly, Int32, NativeTensorArray, Int32, Int32)

    Declaration
    public static void Copy<T>(NativeArray<T>.ReadOnly sourceArray, int sourceIndex, NativeTensorArray destinationArray, int destinationIndex, int length)
        where T : struct
    Parameters
    Type Name Description
    NativeArray.ReadOnly<> sourceArray
    Int32 sourceIndex
    NativeTensorArray destinationArray
    Int32 destinationIndex
    Int32 length
    Type Parameters
    Name Description
    T

    Copy<T>(NativeTensorArray, T[], Int32, Int32)

    Declaration
    public static void Copy<T>(NativeTensorArray sourceArray, T[] destinationArray, int length = -1, int srcIndex = 0)
        where T : struct
    Parameters
    Type Name Description
    NativeTensorArray sourceArray
    T[] destinationArray
    Int32 length
    Int32 srcIndex
    Type Parameters
    Name Description
    T

    Copy<T>(NativeTensorArray, Int32, T[], Int32, Int32)

    Copies the data from a source NativeTensorArray to a destination array up to a given length starting from given indexes.

    Declaration
    public static void Copy<T>(NativeTensorArray sourceArray, int sourceIndex, T[] destinationArray, int destinationIndex, int length)
        where T : struct
    Parameters
    Type Name Description
    NativeTensorArray sourceArray
    Int32 sourceIndex
    T[] destinationArray
    Int32 destinationIndex
    Int32 length
    Type Parameters
    Name Description
    T

    Copy<T>(NativeTensorArray, Int32, NativeArray<T>, Int32, Int32)

    Declaration
    public static void Copy<T>(NativeTensorArray sourceArray, int sourceIndex, NativeArray<T> destinationArray, int destinationIndex, int length)
        where T : struct
    Parameters
    Type Name Description
    NativeTensorArray sourceArray
    Int32 sourceIndex
    NativeArray<T> destinationArray
    Int32 destinationIndex
    Int32 length
    Type Parameters
    Name Description
    T

    CopyTo(NativeTensorArray, Int32)

    Copies all of the data to a NativeTensorArray starting from a given offset.

    Declaration
    public void CopyTo(NativeTensorArray dst, int dstOffset)
    Parameters
    Type Name Description
    NativeTensorArray dst
    Int32 dstOffset

    DataItemSize()

    Declaration
    protected int DataItemSize()
    Returns
    Type Description
    Int32

    Dispose()

    Disposes of the array and any associated memory.

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

    Get<T>(Int32)

    Returns the value of the backing data at a given 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

    GetNativeArrayHandle<T>()

    Returns the data converted to a NativeArray&lt;T>.

    Declaration
    public NativeArray<T> GetNativeArrayHandle<T>()
        where T : struct
    Returns
    Type Description
    NativeArray<T>
    Type Parameters
    Name Description
    T

    GetReadOnlyNativeArrayHandle<T>(Int32, Int32)

    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

    Set<T>(Int32, T)

    Sets the value of the backing data at a given 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

    ToArray<T>(Int32, Int32)

    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

    ZeroMemory()

    Clears the allocated memory to zero.

    Declaration
    public void ZeroMemory()
    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