Example #1
0
        internal OnnxSession(Byte[] model, ONNX.SessionOptions options)
        {
            _Session = new ONNX.InferenceSession(model, options);

            _InputMeta  = _Session.InputMetadata.ToArray();
            _OutputMeta = _Session.OutputMetadata.ToArray();

            _Inputs      = _InputMeta.Select(item => item.Value.CreateNamedOnnexValue(item.Key)).ToArray();
            _Outputs     = _OutputMeta.Select(item => item.Value.CreateNamedOnnexValue(item.Key)).ToArray();
            _OutputNames = _Outputs.Select(item => item.Name).ToArray();
        }
Example #2
0
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="session"></param>
 /// <param name="memInfo"></param>
 public OrtAllocator(InferenceSession session, OrtMemoryInfo memInfo)
     : base(IntPtr.Zero, true)
 {
     NativeApiStatus.VerifySuccess(NativeMethods.OrtCreateAllocator(session.Handle, memInfo.Pointer, out handle));
     _owned = true;
 }
Example #3
0
 /// <summary>
 /// Use InferenceSession.CreateIoBinding()
 /// </summary>
 /// <param name="session"></param>
 internal OrtIoBinding(InferenceSession session)
     : base(IntPtr.Zero, true)
 {
     NativeApiStatus.VerifySuccess(NativeMethods.OrtCreateIoBinding(session.Handle, out handle));
 }
Example #4
0
 /// <summary>
 /// Use InferenceSession.CreateIoBinding()
 /// </summary>
 /// <param name="session"></param>
 internal OrtIoBinding(InferenceSession session)
 {
     NativeApiStatus.VerifySuccess(NativeMethods.OrtCreateIoBinding(session.Handle, out _handle));
 }