Esempio n. 1
0
        /// <summary>
        ///  The below 2 are really properties but naming them is a challenge
        ///  as names would conflict with the returned type. Also, there are native
        ///  calls behind them so exposing them as Get() would be appropriate.
        /// </summary>
        /// <returns></returns>
        public OrtMemType GetMemoryType()
        {
            OrtMemType memoryType = OrtMemType.Default;

            NativeApiStatus.VerifySuccess(NativeMethods.OrtMemoryInfoGetMemType(handle, out memoryType));
            return(memoryType);
        }
Esempio n. 2
0
 /// <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)
 {
 }
Esempio n. 3
0
 /// <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)
     : base(IntPtr.Zero, true)
 {
     using (var pinnedName = new PinnedGCHandle(GCHandle.Alloc(utf8AllocatorName, GCHandleType.Pinned)))
     {
         NativeApiStatus.VerifySuccess(NativeMethods.OrtCreateMemoryInfo(pinnedName.Pointer,
                                                                         allocatorType,
                                                                         deviceId,
                                                                         memoryType,
                                                                         out handle));
     }
     _owned = true;
 }