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

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Constructors
      • NativeTensorArray(Int32, Boolean, Allocator)
      • NativeTensorArray(SafeHandle, Int32)
    • Fields
      • m_SafeHandle
    • Properties
      • Disposed
      • Length
      • LongLength
      • RawPtr
      • SizeOfType
    • Methods
      • AddressAt<T>(Int64)
      • AsReadOnlySpan<T>(Int32, Int32)
      • BlockCopy(Byte[], Int32, NativeTensorArray, Int32, Int32)
      • BlockCopy(NativeTensorArray, Int32, Byte[], Int32, Int32)
      • Copy(NativeTensorArray, Int32, NativeTensorArray, Int32, Int32)
      • Copy(NativeTensorArray, NativeTensorArray, Int32, Int32)
      • Copy<T>(T[], Int32, NativeTensorArray, Int32, Int32)
      • Copy<T>(T[], NativeTensorArray, Int32, Int32)
      • Copy<T>(NativeArray<T>, Int32, NativeTensorArray, Int32, Int32)
      • Copy<T>(NativeArray<T>, NativeTensorArray, Int32, Int32)
      • Copy<T>(NativeArray<T>.ReadOnly, Int32, NativeTensorArray, Int32, Int32)
      • Copy<T>(NativeTensorArray, T[], Int32, Int32)
      • Copy<T>(NativeTensorArray, Int32, T[], Int32, Int32)
      • Copy<T>(NativeTensorArray, Int32, NativeArray<T>, Int32, Int32)
      • CopyTo(NativeTensorArray, Int32)
      • DataItemSize()
      • Dispose()
      • Get<T>(Int32)
      • GetNativeArrayHandle<T>()
      • GetReadOnlyNativeArrayHandle<T>(Int32, Int32)
      • Set<T>(Int32, T)
      • ToArray<T>(Int32, Int32)
      • 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