diff --git a/lib/onnxruntime/ffi.rb b/lib/onnxruntime/ffi.rb index 8755959..a59d434 100644 --- a/lib/onnxruntime/ffi.rb +++ b/lib/onnxruntime/ffi.rb @@ -247,7 +247,11 @@ class ApiBase < ::FFI::Struct attach_function :OrtGetApiBase, %i[], ApiBase.by_ref def self.api - @api ||= self.OrtGetApiBase[:GetApi].call(ORT_API_VERSION) + @api ||= begin + api = self.OrtGetApiBase[:GetApi].call(ORT_API_VERSION) + api = Api.by_ref.from_native(api, nil) if RUBY_PLATFORM == "java" + api + end end if Gem.win_platform? diff --git a/test/test_helper.rb b/test/test_helper.rb index 0284f1b..e60c9e9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -26,7 +26,11 @@ def assert_elements_in_delta(expected, actual) end def numo? - RUBY_PLATFORM != "java" + !jruby? + end + + def jruby? + RUBY_PLATFORM == "java" end def linux?