diff --git a/onnxruntime/python/onnxruntime_inference_collection.py b/onnxruntime/python/onnxruntime_inference_collection.py index bb9d2cad6c..b2e98c23d5 100644 --- a/onnxruntime/python/onnxruntime_inference_collection.py +++ b/onnxruntime/python/onnxruntime_inference_collection.py @@ -355,7 +355,7 @@ class IOBinding: ''' def __init__(self, session): self._iobinding = C.SessionIOBinding(session._sess) - self._numpy_obj_references = [] + self._numpy_obj_references = {} def bind_cpu_input(self, name, arr_on_cpu): ''' @@ -366,7 +366,7 @@ class IOBinding: # Hold a reference to the numpy object as the bound OrtValue is backed # directly by the data buffer of the numpy object and so the numpy object # must be around until this IOBinding instance is around - self._numpy_obj_references.append(arr_on_cpu) + self._numpy_obj_references[name] = arr_on_cpu self._iobinding.bind_input(name, arr_on_cpu) def bind_input(self, name, device_type, device_id, element_type, shape, buffer_ptr):