Skip to content

Commit

Permalink
Fixed error with JRuby
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Sep 11, 2024
1 parent 329dd8c commit a385ba0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/onnxruntime/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
6 changes: 5 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit a385ba0

Please sign in to comment.