From 3a72932c4a4afc2e72c6b3bfc17b3c0a248e6232 Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Sun, 30 May 2021 21:12:32 -0700 Subject: [PATCH] Don't hold onto unnecessary numpy references while binding numpy objectas as inputs (#7881) --- onnxruntime/python/onnxruntime_inference_collection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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):