Class NativeTensorArray
Represents an area of native memory that's exposed to managed code.
Inheritance
NativeTensorArray
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
Fields
m_SafeHandle
Declaration
protected readonly SafeHandle m_SafeHandle
Field Value
Properties
Disposed
Whether the backing data is disposed.
Declaration
public bool Disposed { get; }
Property Value
Length
The number of allocated elements.
Declaration
public int Length { get; }
Property Value
LongLength
The number of allocated elements as a 64-bit integer.
Declaration
public long LongLength { get; }
Property Value
RawPtr
The raw pointer of the backing data.
Declaration
public virtual void *RawPtr { get; }
Property Value
SizeOfType
The size in bytes of an element of the stored type.
Declaration
public int SizeOfType { get; }
Property Value
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 Parameters
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
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
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
Copy(NativeTensorArray, NativeTensorArray, 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)
Parameters
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 Parameters
Copy<T>(T[], NativeTensorArray, 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)
where T : struct
Parameters
Type Parameters
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 Parameters
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
DataItemSize()
Declaration
protected int DataItemSize()
Returns
Dispose()
Disposes of the array and any associated memory.
Declaration
public virtual void Dispose()
Implements
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 Parameters
GetNativeArrayHandle<T>()
Returns the data converted to a NativeArray<T>
.
Declaration
public NativeArray<T> GetNativeArrayHandle<T>()
where T : struct
Returns
Type Parameters
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
ZeroMemory()
Clears the allocated memory to zero.
Declaration
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
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.