Show / Hide Table of Contents

Class OrtAllocator

The class exposes native internal allocator for Onnxruntime. This allocator enables you to allocate memory from the internal memory pools including device allocations. Useful for binding.

Inheritance
Object
CriticalFinalizerObject
SafeHandle
OrtAllocator
Implements
IDisposable
Inherited Members
SafeHandle.handle
SafeHandle.Close()
SafeHandle.DangerousAddRef(Boolean)
SafeHandle.DangerousGetHandle()
SafeHandle.DangerousRelease()
SafeHandle.Dispose()
SafeHandle.Dispose(Boolean)
SafeHandle.SetHandle(IntPtr)
SafeHandle.SetHandleAsInvalid()
SafeHandle.IsClosed
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Microsoft.ML.OnnxRuntime
Assembly: Microsoft.ML.OnnxRuntime.dll
Syntax
public class OrtAllocator : SafeHandle, IDisposable

Constructors

| Improve this Doc View Source

OrtAllocator(InferenceSession, OrtMemoryInfo)

Creates an instance of OrtAllocator according to the specifications in OrtMemorInfo. The requested allocator should be available within the given session instance. This means both, the native library was build with specific allocators (for instance CUDA) and the corresponding provider was added to SessionsOptions before instantiating the session object.

Declaration
public OrtAllocator(InferenceSession session, OrtMemoryInfo memInfo)
Parameters
Type Name Description
InferenceSession session
OrtMemoryInfo memInfo

Properties

| Improve this Doc View Source

DefaultInstance

Default CPU allocator instance

Declaration
public static OrtAllocator DefaultInstance { get; }
Property Value
Type Description
OrtAllocator
| Improve this Doc View Source

Info

OrtMemoryInfo instance owned by the allocator

Declaration
public OrtMemoryInfo Info { get; }
Property Value
Type Description
OrtMemoryInfo

Instance of OrtMemoryInfo describing this allocator

| Improve this Doc View Source

IsInvalid

Overrides SafeHandle.IsInvalid

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

returns true if handle is equal to Zero

Overrides
System.Runtime.InteropServices.SafeHandle.IsInvalid

Methods

| Improve this Doc View Source

Allocate(UInt32)

Allocate native memory. Returns a disposable instance of OrtMemoryAllocation

Declaration
public OrtMemoryAllocation Allocate(uint size)
Parameters
Type Name Description
UInt32 size

number of bytes to allocate

Returns
Type Description
OrtMemoryAllocation

Instance of OrtMemoryAllocation

| Improve this Doc View Source

ReleaseHandle()

Overrides SafeHandle.ReleaseHandle() to properly dispose of the native instance of OrtAllocator

Declaration
protected override bool ReleaseHandle()
Returns
Type Description
Boolean

always returns true

Overrides
System.Runtime.InteropServices.SafeHandle.ReleaseHandle()

Implements

System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top