diff options
author | Raul Farkas <raul.farkas@arm.com> | 2023-01-16 16:52:18 +0000 |
---|---|---|
committer | Raul Farkas <raul.farkas@arm.com> | 2023-02-09 15:38:02 +0000 |
commit | 428a8d54f574a73804274e53e61f711aebc25a0a (patch) | |
tree | 251bb0a54234fb9a62b8a22a9ba9f82e2b5f3ca5 /ethosu/vela | |
parent | 59b9ab9121d17793b5a240f7c51028b6b37a7a6e (diff) | |
download | ethos-u-vela-428a8d54f574a73804274e53e61f711aebc25a0a.tar.gz |
MLBEDSW-6982: Move to setup.cfg and pyproject.toml3.7.0.rc1
- Move all static information from setup.py to newly added
pyproject.toml
- Add setup.cfg used for static information that cannot be added to
pyproject.toml due to it still being in beta.
- Modify mlw_codec to to throw a real python exception when importing
NumPy arrays instead of just printing them to stdout.
- Surround mlw_codec import with try catch statement to catch NumPy C
API mismatch errors and throw them again with a more detailed message.
- Update README.md with documentation about known issue with changing
used NumPy version after installing ethos-u-vela.
Change-Id: I1eeee5536be7c1744e30d6088f7069fbb1403e06
Signed-off-by: Raul Farkas <raul.farkas@arm.com>
Diffstat (limited to 'ethosu/vela')
-rw-r--r-- | ethosu/vela/weight_compressor.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/ethosu/vela/weight_compressor.py b/ethosu/vela/weight_compressor.py index e3e318c3..e56cc5e5 100644 --- a/ethosu/vela/weight_compressor.py +++ b/ethosu/vela/weight_compressor.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright 2020-2022 Arm Limited and/or its affiliates <open-source-office@arm.com> +# SPDX-FileCopyrightText: Copyright 2020-2023 Arm Limited and/or its affiliates <open-source-office@arm.com> # # SPDX-License-Identifier: Apache-2.0 # @@ -37,7 +37,28 @@ from .scaling import reduced_quantise_scale from .tensor import Tensor from .tensor import TensorFormat from .tensor import TensorPurpose -from ethosu import mlw_codec + +# Handle any errors thrown by NumPy while importing mlw_codec module +try: + from ethosu import mlw_codec +except RuntimeError as ex: + if "mlw_codec error: module compiled against API version" in str(ex): + # Extract API versions from error message + matches = [s for s in str(ex).split() if "0x" in s] + if len(matches) == 2: + # Raise new exception with more detailed message + raise ImportError( # pylint: disable=W0707 + "NumPy C API version mismatch " + f"(Build-time version: {matches[0]}, " + f"Run-time version: {matches[1]})" + "\nThis is a known issue most likely caused by a change in the API " + "version in NumPy after installing ethos-u-vela.\nYou can find more " + "information about the issue and possible solutions in the " + "'Known Issues' section at https://review.mlplatform.org/" + "plugins/gitiles/ml/ethos-u/ethos-u-vela/+/refs/heads/main/" + "README.md#known-issues" + ) + raise # Contains meta info for a weight compression. If two tensors have identical weight compression config, |