@@ -200,17 +200,20 @@ def create_from_onnx_value(out_ptr, output_type)
200200 out . read ( :size_t ) . times . map do |i |
201201 seq = ::FFI ::MemoryPointer . new ( :pointer )
202202 Utils . check_status FFI . api [ :GetValue ] . call ( out_ptr , i , Utils . allocator , seq )
203- create_from_onnx_value ( seq . read_pointer , output_type )
203+ seq = ::FFI ::AutoPointer . new ( seq . read_pointer , FFI . api [ :ReleaseValue ] )
204+ create_from_onnx_value ( seq , output_type )
204205 end
205206 when :map
206207 map_keys = ::FFI ::MemoryPointer . new ( :pointer )
207208 Utils . check_status FFI . api [ :GetValue ] . call ( out_ptr , 0 , Utils . allocator , map_keys )
209+ map_keys = ::FFI ::AutoPointer . new ( map_keys . read_pointer , FFI . api [ :ReleaseValue ] )
208210
209211 map_values = ::FFI ::MemoryPointer . new ( :pointer )
210212 Utils . check_status FFI . api [ :GetValue ] . call ( out_ptr , 1 , Utils . allocator , map_values )
213+ map_values = ::FFI ::AutoPointer . new ( map_values . read_pointer , FFI . api [ :ReleaseValue ] )
211214
212215 type_shape = ::FFI ::MemoryPointer . new ( :pointer )
213- Utils . check_status FFI . api [ :GetTensorTypeAndShape ] . call ( map_keys . read_pointer , type_shape )
216+ Utils . check_status FFI . api [ :GetTensorTypeAndShape ] . call ( map_keys , type_shape )
214217 type_shape = ::FFI ::AutoPointer . new ( type_shape . read_pointer , FFI . api [ :ReleaseTensorTypeAndShapeInfo ] )
215218
216219 elem_type = ::FFI ::MemoryPointer . new ( :int )
@@ -221,8 +224,8 @@ def create_from_onnx_value(out_ptr, output_type)
221224 case elem_type
222225 when :int64
223226 ret = { }
224- keys = create_from_onnx_value ( map_keys . read_pointer , output_type )
225- values = create_from_onnx_value ( map_values . read_pointer , output_type )
227+ keys = create_from_onnx_value ( map_keys , output_type )
228+ values = create_from_onnx_value ( map_values , output_type )
226229 keys . zip ( values ) . each do |k , v |
227230 ret [ k ] = v
228231 end
0 commit comments