MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _ensure_safe

Method _ensure_safe

tensorflow/lite/python/interpreter.py:258–272  ·  view source on GitHub ↗

Makes sure no numpy arrays pointing to internal buffers are active. This should be called from any function that will call a function on _interpreter that may reallocate memory e.g. invoke(), ... Raises: RuntimeError: If there exist numpy objects pointing to internal memory

(self)

Source from the content-addressed store, hash-verified

256 return sys.getrefcount(self._interpreter) == 2
257
258 def _ensure_safe(self):
259 """Makes sure no numpy arrays pointing to internal buffers are active.
260
261 This should be called from any function that will call a function on
262 _interpreter that may reallocate memory e.g. invoke(), ...
263
264 Raises:
265 RuntimeError: If there exist numpy objects pointing to internal memory
266 then we throw.
267 """
268 if not self._safe_to_run():
269 raise RuntimeError("""There is at least 1 reference to internal data
270 in the interpreter in the form of a numpy array or slice. Be sure to
271 only hold the function returned from tensor() if you are using raw
272 data access.""")
273
274 def _get_tensor_details(self, tensor_index):
275 """Gets tensor details.

Callers 3

allocate_tensorsMethod · 0.95
resize_tensor_inputMethod · 0.95
invokeMethod · 0.95

Calls 1

_safe_to_runMethod · 0.95

Tested by

no test coverage detected