lib/onnxruntime/ffi.rb in onnxruntime-0.3.3 vs lib/onnxruntime/ffi.rb in onnxruntime-0.4.0

- old
+ new

@@ -1,15 +1,10 @@ module OnnxRuntime module FFI extend ::FFI::Library - begin - ffi_lib Array(OnnxRuntime.ffi_lib) - rescue LoadError => e - raise e if ENV["ONNXRUNTIME_DEBUG"] - raise LoadError, "Could not find ONNX Runtime" - end + ffi_lib Array(OnnxRuntime.ffi_lib) # https://github.com/microsoft/onnxruntime/blob/master/include/onnxruntime/core/session/onnxruntime_c_api.h # keep same order # enums @@ -23,18 +18,18 @@ :GetErrorMessage, callback(%i[pointer], :pointer), :CreateEnv, callback(%i[int string pointer], :pointer), :CreateEnvWithCustomLogger, callback(%i[], :pointer), :EnableTelemetryEvents, callback(%i[pointer], :pointer), :DisableTelemetryEvents, callback(%i[pointer], :pointer), - :CreateSession, callback(%i[pointer string pointer pointer], :pointer), + :CreateSession, callback(%i[pointer pointer pointer pointer], :pointer), :CreateSessionFromArray, callback(%i[pointer pointer size_t pointer pointer], :pointer), :Run, callback(%i[pointer pointer pointer pointer size_t pointer size_t pointer], :pointer), :CreateSessionOptions, callback(%i[pointer], :pointer), - :SetOptimizedModelFilePath, callback(%i[pointer string], :pointer), + :SetOptimizedModelFilePath, callback(%i[pointer pointer], :pointer), :CloneSessionOptions, callback(%i[], :pointer), :SetSessionExecutionMode, callback(%i[], :pointer), - :EnableProfiling, callback(%i[pointer string], :pointer), + :EnableProfiling, callback(%i[pointer pointer], :pointer), :DisableProfiling, callback(%i[pointer], :pointer), :EnableMemPattern, callback(%i[pointer], :pointer), :DisableMemPattern, callback(%i[pointer], :pointer), :EnableCpuMemArena, callback(%i[pointer], :pointer), :DisableCpuMemArena, callback(%i[pointer], :pointer), @@ -140,11 +135,13 @@ :CreateEnvWithGlobalThreadPools, callback(%i[], :pointer), :DisablePerSessionThreads, callback(%i[], :pointer), :CreateThreadingOptions, callback(%i[], :pointer), :ReleaseThreadingOptions, callback(%i[], :pointer), :ModelMetadataGetCustomMetadataMapKeys, callback(%i[pointer pointer pointer pointer], :pointer), - :AddFreeDimensionOverrideByName, callback(%i[], :pointer) + :AddFreeDimensionOverrideByName, callback(%i[], :pointer), + :GetAvailableProviders, callback(%i[pointer pointer], :pointer), + :ReleaseAvailableProviders, callback(%i[pointer int], :pointer) end class ApiBase < ::FFI::Struct # use uint32 instead of uint32_t # to prevent "unable to resolve type" error on Ubuntu @@ -152,7 +149,15 @@ :GetApi, callback(%i[uint32], Api.by_ref), :GetVersionString, callback(%i[], :pointer) end attach_function :OrtGetApiBase, %i[], ApiBase.by_ref + + if Gem.win_platform? + class Libc + extend ::FFI::Library + ffi_lib ::FFI::Library::LIBC + attach_function :mbstowcs, %i[pointer string size_t], :size_t + end + end end end