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)
| 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. |
no test coverage detected