/// <summary> /// Returns alloctor type /// </summary> /// <returns></returns> public OrtAllocatorType GetAllocatorType() { OrtAllocatorType allocatorType = OrtAllocatorType.ArenaAllocator; NativeApiStatus.VerifySuccess(NativeMethods.OrtMemoryInfoGetType(handle, out allocatorType)); return(allocatorType); }
/// <summary> /// Create an instance of OrtMemoryInfo according to the specification /// Memory info instances are usually used to get a handle of a native allocator /// that is present within the current inference session object. That, in turn, depends /// of what execution providers are available within the binary that you are using and are /// registered with Add methods. /// </summary> /// <param name="utf8AllocatorName">Allocator name. Use of the predefined above.</param> /// <param name="allocatorType">Allocator type</param> /// <param name="deviceId">Device id</param> /// <param name="memoryType">Memory type</param> public OrtMemoryInfo(byte[] utf8AllocatorName, OrtAllocatorType allocatorType, int deviceId, OrtMemType memoryType) { using (var pinnedName = new PinnedGCHandle(GCHandle.Alloc(utf8AllocatorName, GCHandleType.Pinned))) { NativeApiStatus.VerifySuccess(NativeMethods.OrtCreateMemoryInfo(pinnedName.Pointer, allocatorType, deviceId, memoryType, out _pointer)); } _owned = true; }
/// <summary> /// Create an instance of OrtMemoryInfo according to the specification. /// </summary> /// <param name="allocatorName">Allocator name</param> /// <param name="allocatorType">Allocator type</param> /// <param name="deviceId">Device id</param> /// <param name="memoryType">Memory type</param> public OrtMemoryInfo(string allocatorName, OrtAllocatorType allocatorType, int deviceId, OrtMemType memoryType) : this(NativeOnnxValueHelper.StringToZeroTerminatedUtf8(allocatorName), allocatorType, deviceId, memoryType) { }