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