From 780a5a6dd74e2b62cd8f0cd3daf3a8f1a4ebce9f Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 7 Oct 2025 15:33:53 +0200 Subject: [PATCH] [onert] Remove unused tensorinfo function from common module This commit removes unused and broken tensorinfo() function from the common Python module. >>> import onert >>> onert.tensorinfo() Traceback (most recent call last): File ".../onert/common/basesession.py", line 189, in tensorinfo return infer.nnfw_tensorinfo() ^^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'onert.native.libnnfw_api_pybind.infer' has no attribute 'nnfw_tensorinfo' Removing this function allows to properly use the native tensorinfo structure from the onert top level module. >>> import onert >>> onert.tensorinfo() ONE-DCO-1.0-Signed-off-by: Arkadiusz Bokowy --- runtime/onert/api/python/package/__init__.py | 2 +- .../api/python/package/common/basesession.py | 17 +---------------- .../minimal-python/inference_benchmark.py | 4 +--- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/runtime/onert/api/python/package/__init__.py b/runtime/onert/api/python/package/__init__.py index 2c5e133de3f..71b5512dd0f 100644 --- a/runtime/onert/api/python/package/__init__.py +++ b/runtime/onert/api/python/package/__init__.py @@ -5,7 +5,7 @@ from . import infer # Import and expose tensorinfo -from .common import tensorinfo as tensorinfo +from .common import tensorinfo # Import and expose the experimental module's functionalities from . import experimental diff --git a/runtime/onert/api/python/package/common/basesession.py b/runtime/onert/api/python/package/common/basesession.py index d651ddbf3d1..edad146e3ea 100644 --- a/runtime/onert/api/python/package/common/basesession.py +++ b/runtime/onert/api/python/package/common/basesession.py @@ -1,7 +1,7 @@ from typing import List import numpy as np -from ..native.libnnfw_api_pybind import infer, tensorinfo +from ..native.libnnfw_api_pybind import tensorinfo from ..native.libnnfw_api_pybind.exception import OnertError @@ -176,18 +176,3 @@ def _set_outputs(self, size): raise OnertError(f"Failed to get output #{i}: {e}") from e self.outputs.append(output_array) - - -def tensorinfo(): - """ - Shortcut to create a fresh tensorinfo instance. - Raises: - OnertError: If the C-API call fails. - """ - - try: - return infer.nnfw_tensorinfo() - except OnertError: - raise - except Exception as e: - raise OnertError(f"Failed to create tensorinfo: {e}") from e diff --git a/runtime/onert/sample/minimal-python/inference_benchmark.py b/runtime/onert/sample/minimal-python/inference_benchmark.py index 443f7a29d39..e1a00781182 100644 --- a/runtime/onert/sample/minimal-python/inference_benchmark.py +++ b/runtime/onert/sample/minimal-python/inference_benchmark.py @@ -3,9 +3,7 @@ import psutil import os from typing import List -from onert import infer -# TODO: Import tensorinfo from onert -from onert.native.libnnfw_api_pybind import tensorinfo +from onert import infer, tensorinfo def get_memory_usage_mb() -> float: