aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Klimczak <benjamin.klimczak@arm.com>2022-11-07 12:57:15 +0000
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2022-11-11 12:10:26 +0000
commitce9b17650d024886b24ad820f0f1815fc23b19f3 (patch)
treea7d113f751b8856aabcd021464edec16e23ba6f8
parente40a7adadd254e29d71af38f69a0a20ff4871eef (diff)
downloadmlia-ce9b17650d024886b24ad820f0f1815fc23b19f3.tar.gz
MLIA-701 Update dependencies
- Update TensorFlow dependencies for x86_64 - Adapt unit tests to new TensorFlow version - Update linters (including pre-commit hooks) and fix issues - Use conditional import to fix tflite compat code for aarch64 Change-Id: I1a9b080b900ab65e38f7f2552562822bbfdcd259
-rw-r--r--.pre-commit-config.yaml12
-rw-r--r--setup.cfg14
-rw-r--r--src/mlia/backend/common.py2
-rw-r--r--src/mlia/core/common.py8
-rw-r--r--src/mlia/core/helpers.py2
-rw-r--r--src/mlia/devices/cortexa/advice_generation.py2
-rw-r--r--src/mlia/devices/cortexa/data_analysis.py2
-rw-r--r--src/mlia/devices/ethosu/advice_generation.py2
-rw-r--r--src/mlia/devices/ethosu/data_analysis.py2
-rw-r--r--src/mlia/devices/tosa/advice_generation.py2
-rw-r--r--src/mlia/devices/tosa/data_analysis.py2
-rw-r--r--src/mlia/nn/tensorflow/tflite_compat.py10
-rw-r--r--src/mlia/utils/download.py2
-rw-r--r--tests/test_backend_application.py1
-rw-r--r--tests/test_backend_common.py2
-rw-r--r--tests/test_backend_execution.py1
-rw-r--r--tests/test_backend_fs.py1
-rw-r--r--tests/test_backend_proc.py2
-rw-r--r--tests/test_backend_source.py1
-rw-r--r--tests/test_core_events.py4
-rw-r--r--tests/test_nn_tensorflow_tflite_compat.py8
-rw-r--r--tox.ini12
22 files changed, 53 insertions, 41 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 2d87aa6..2de4fac 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -11,7 +11,7 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v4.2.0
+ rev: v4.3.0
hooks:
- id: check-yaml
@@ -32,30 +32,30 @@ repos:
exclude: src/mlia/resources
- repo: https://github.com/Lucas-C/pre-commit-hooks
- rev: v1.1.13
+ rev: v1.3.1
hooks:
- id: remove-tabs
args: [--whitespaces-count, '8']
- repo: https://github.com/asottile/reorder_python_imports
- rev: v3.0.1
+ rev: v3.9.0
hooks:
- id: reorder-python-imports
args: ["--application-directories", ".:src"]
- repo: https://github.com/asottile/pyupgrade
- rev: v2.38.0
+ rev: v3.2.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/psf/black
- rev: 22.3.0
+ rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
- rev: '4.0.1'
+ rev: '5.0.4'
hooks:
- id: flake8
diff --git a/setup.cfg b/setup.cfg
index 5d3a6af..f262484 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -35,10 +35,10 @@ packages = find_namespace:
# no numpy version conflict.
install_requires =
tensorflow-aarch64~=2.7.3; platform_machine=="aarch64"
- tensorflow~=2.8.2; platform_machine=="x86_64"
- tensorflow-model-optimization~=0.7.2
+ tensorflow~=2.9.2; platform_machine=="x86_64"
+ tensorflow-model-optimization~=0.7.3
ethos-u-vela~=3.3.0; platform_machine=="aarch64"
- ethos-u-vela~=3.4.0; platform_machine=="x86_64"
+ ethos-u-vela~=3.5.0; platform_machine=="x86_64"
requests
rich
sh
@@ -52,10 +52,10 @@ console_scripts =
[options.extras_require]
dev =
- pytest==7.1.1
- pytest-cov==3.0.0
- mypy==0.942
- pylint==2.13.7
+ pytest==7.2.0
+ pytest-cov==4.0.0
+ mypy==0.982
+ pylint==2.15.5
pre-commit
tosa =
tosa-checker==0.1.0
diff --git a/src/mlia/backend/common.py b/src/mlia/backend/common.py
index 697c2a0..0f04553 100644
--- a/src/mlia/backend/common.py
+++ b/src/mlia/backend/common.py
@@ -205,7 +205,7 @@ class Backend(ABC):
return self.variables[var_name]
- return var_pattern.sub(var_value, str_val) # type: ignore
+ return var_pattern.sub(var_value, str_val)
@classmethod
def _parse_params(
diff --git a/src/mlia/core/common.py b/src/mlia/core/common.py
index 63fb324..6c9dde1 100644
--- a/src/mlia/core/common.py
+++ b/src/mlia/core/common.py
@@ -29,7 +29,13 @@ class AdviceCategory(Flag):
OPERATORS = auto()
PERFORMANCE = auto()
OPTIMIZATION = auto()
- ALL = OPERATORS | PERFORMANCE | OPTIMIZATION
+ ALL = (
+ # pylint: disable=unsupported-binary-operation
+ OPERATORS
+ | PERFORMANCE
+ | OPTIMIZATION
+ # pylint: enable=unsupported-binary-operation
+ )
@classmethod
def from_string(cls, value: str) -> AdviceCategory:
diff --git a/src/mlia/core/helpers.py b/src/mlia/core/helpers.py
index f0c4474..f4a9df6 100644
--- a/src/mlia/core/helpers.py
+++ b/src/mlia/core/helpers.py
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
"""Module for various helper classes."""
-# pylint: disable=no-self-use, unused-argument
+# pylint: disable=unused-argument
from __future__ import annotations
from typing import Any
diff --git a/src/mlia/devices/cortexa/advice_generation.py b/src/mlia/devices/cortexa/advice_generation.py
index 34c51f8..186f489 100644
--- a/src/mlia/devices/cortexa/advice_generation.py
+++ b/src/mlia/devices/cortexa/advice_generation.py
@@ -23,7 +23,7 @@ class CortexAAdviceProducer(FactBasedAdviceProducer):
)
@singledispatchmethod
- def produce_advice(self, _data_item: DataItem) -> None:
+ def produce_advice(self, _data_item: DataItem) -> None: # type: ignore
"""Produce advice."""
@produce_advice.register
diff --git a/src/mlia/devices/cortexa/data_analysis.py b/src/mlia/devices/cortexa/data_analysis.py
index 9f6d82b..6a82dd0 100644
--- a/src/mlia/devices/cortexa/data_analysis.py
+++ b/src/mlia/devices/cortexa/data_analysis.py
@@ -21,7 +21,7 @@ class CortexADataAnalyzer(FactExtractor):
"""Cortex-A data analyzer."""
@singledispatchmethod
- def analyze_data(self, data_item: DataItem) -> None:
+ def analyze_data(self, data_item: DataItem) -> None: # type: ignore
"""Analyse the data."""
@analyze_data.register
diff --git a/src/mlia/devices/ethosu/advice_generation.py b/src/mlia/devices/ethosu/advice_generation.py
index 8a38d2c..1910460 100644
--- a/src/mlia/devices/ethosu/advice_generation.py
+++ b/src/mlia/devices/ethosu/advice_generation.py
@@ -22,7 +22,7 @@ class EthosUAdviceProducer(FactBasedAdviceProducer):
"""Ethos-U advice producer."""
@singledispatchmethod
- def produce_advice(self, data_item: DataItem) -> None:
+ def produce_advice(self, data_item: DataItem) -> None: # type: ignore
"""Produce advice."""
@produce_advice.register
diff --git a/src/mlia/devices/ethosu/data_analysis.py b/src/mlia/devices/ethosu/data_analysis.py
index 8d88cf7..70b6f65 100644
--- a/src/mlia/devices/ethosu/data_analysis.py
+++ b/src/mlia/devices/ethosu/data_analysis.py
@@ -83,7 +83,7 @@ class EthosUDataAnalyzer(FactExtractor):
"""Ethos-U data analyzer."""
@singledispatchmethod
- def analyze_data(self, data_item: DataItem) -> None:
+ def analyze_data(self, data_item: DataItem) -> None: # type: ignore
"""Analyse the data."""
@analyze_data.register
diff --git a/src/mlia/devices/tosa/advice_generation.py b/src/mlia/devices/tosa/advice_generation.py
index 7adfcb9..a3d8011 100644
--- a/src/mlia/devices/tosa/advice_generation.py
+++ b/src/mlia/devices/tosa/advice_generation.py
@@ -15,7 +15,7 @@ class TOSAAdviceProducer(FactBasedAdviceProducer):
"""TOSA advice producer."""
@singledispatchmethod
- def produce_advice(self, _data_item: DataItem) -> None:
+ def produce_advice(self, _data_item: DataItem) -> None: # type: ignore
"""Produce advice."""
@produce_advice.register
diff --git a/src/mlia/devices/tosa/data_analysis.py b/src/mlia/devices/tosa/data_analysis.py
index aa696a5..c18ac02 100644
--- a/src/mlia/devices/tosa/data_analysis.py
+++ b/src/mlia/devices/tosa/data_analysis.py
@@ -24,7 +24,7 @@ class TOSADataAnalyzer(FactExtractor):
"""TOSA data analyzer."""
@singledispatchmethod
- def analyze_data(self, data_item: DataItem) -> None:
+ def analyze_data(self, data_item: DataItem) -> None: # type: ignore
"""Analyse the data."""
@analyze_data.register
diff --git a/src/mlia/nn/tensorflow/tflite_compat.py b/src/mlia/nn/tensorflow/tflite_compat.py
index 960a5c3..6f183ca 100644
--- a/src/mlia/nn/tensorflow/tflite_compat.py
+++ b/src/mlia/nn/tensorflow/tflite_compat.py
@@ -11,12 +11,20 @@ from typing import Any
from typing import cast
from typing import List
+import tensorflow as tf
from tensorflow.lite.python import convert
-from tensorflow.lite.python.metrics import converter_error_data_pb2
from mlia.nn.tensorflow.utils import get_tflite_converter
from mlia.utils.logging import redirect_raw_output
+TF_VERSION_MAJOR, TF_VERSION_MINOR, _ = (int(s) for s in tf.version.VERSION.split("."))
+# pylint: disable=import-error,ungrouped-imports
+if (TF_VERSION_MAJOR == 2 and TF_VERSION_MINOR > 7) or TF_VERSION_MAJOR > 2:
+ from tensorflow.lite.python.metrics import converter_error_data_pb2
+else:
+ from tensorflow.lite.python.metrics_wrapper import converter_error_data_pb2
+# pylint: enable=import-error,ungrouped-imports
+
logger = logging.getLogger(__name__)
diff --git a/src/mlia/utils/download.py b/src/mlia/utils/download.py
index 9ef2d9e..c8d0b69 100644
--- a/src/mlia/utils/download.py
+++ b/src/mlia/utils/download.py
@@ -48,7 +48,7 @@ def download(
chunk_size: int = 8192,
) -> None:
"""Download the file."""
- with requests.get(url, stream=True) as resp:
+ with requests.get(url, stream=True, timeout=10.0) as resp:
resp.raise_for_status()
content_chunks = resp.iter_content(chunk_size=chunk_size)
diff --git a/tests/test_backend_application.py b/tests/test_backend_application.py
index 9606802..478658b 100644
--- a/tests/test_backend_application.py
+++ b/tests/test_backend_application.py
@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
-# pylint: disable=no-self-use
"""Tests for the application backend."""
from __future__ import annotations
diff --git a/tests/test_backend_common.py b/tests/test_backend_common.py
index 40a0cff..4f4853e 100644
--- a/tests/test_backend_common.py
+++ b/tests/test_backend_common.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
-# pylint: disable=no-self-use,protected-access
+# pylint: disable=protected-access
"""Tests for the common backend module."""
from __future__ import annotations
diff --git a/tests/test_backend_execution.py b/tests/test_backend_execution.py
index 6e1b30b..e56a1b0 100644
--- a/tests/test_backend_execution.py
+++ b/tests/test_backend_execution.py
@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
-# pylint: disable=no-self-use
"""Test backend execution module."""
from pathlib import Path
from typing import Any
diff --git a/tests/test_backend_fs.py b/tests/test_backend_fs.py
index 21226a9..292a7cc 100644
--- a/tests/test_backend_fs.py
+++ b/tests/test_backend_fs.py
@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
-# pylint: disable=no-self-use
"""Module for testing fs.py."""
from __future__ import annotations
diff --git a/tests/test_backend_proc.py b/tests/test_backend_proc.py
index 99e0bd5..d2c2cd4 100644
--- a/tests/test_backend_proc.py
+++ b/tests/test_backend_proc.py
@@ -1,6 +1,6 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
-# pylint: disable=attribute-defined-outside-init,no-self-use,not-callable
+# pylint: disable=attribute-defined-outside-init,not-callable
"""Pytests for testing mlia/backend/proc.py."""
from pathlib import Path
from typing import Any
diff --git a/tests/test_backend_source.py b/tests/test_backend_source.py
index 11f1781..c6ef26f 100644
--- a/tests/test_backend_source.py
+++ b/tests/test_backend_source.py
@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates.
# SPDX-License-Identifier: Apache-2.0
-# pylint: disable=no-self-use
"""Tests for the source backend module."""
from collections import Counter
from contextlib import ExitStack as does_not_raise
diff --git a/tests/test_core_events.py b/tests/test_core_events.py
index a531bab..d2b7c94 100644
--- a/tests/test_core_events.py
+++ b/tests/test_core_events.py
@@ -105,9 +105,7 @@ def test_event_dispatcher(capsys: pytest.CaptureFixture) -> None:
class SampleEventHandler(EventDispatcher):
"""Sample event handler."""
- def on_sample_event( # pylint: disable=no-self-use
- self, _event: SampleEvent
- ) -> None:
+ def on_sample_event(self, _event: SampleEvent) -> None:
"""Event handler for SampleEvent."""
print("Got sample event")
diff --git a/tests/test_nn_tensorflow_tflite_compat.py b/tests/test_nn_tensorflow_tflite_compat.py
index c330fdb..1bd4c34 100644
--- a/tests/test_nn_tensorflow_tflite_compat.py
+++ b/tests/test_nn_tensorflow_tflite_compat.py
@@ -8,8 +8,8 @@ from unittest.mock import MagicMock
import pytest
import tensorflow as tf
from tensorflow.lite.python import convert
-from tensorflow.lite.python.metrics import converter_error_data_pb2
+from mlia.nn.tensorflow.tflite_compat import converter_error_data_pb2
from mlia.nn.tensorflow.tflite_compat import TFLiteChecker
from mlia.nn.tensorflow.tflite_compat import TFLiteCompatibilityInfo
from mlia.nn.tensorflow.tflite_compat import TFLiteConversionError
@@ -21,7 +21,7 @@ def test_not_fully_compatible_model_flex_ops() -> None:
model = tf.keras.models.Sequential(
[
tf.keras.layers.Dense(units=1, input_shape=[1], batch_size=1),
- tf.keras.layers.Dense(units=16, activation="gelu"),
+ tf.keras.layers.Dense(units=16, activation="softsign"),
tf.keras.layers.Dense(units=1),
]
)
@@ -36,9 +36,9 @@ def test_not_fully_compatible_model_flex_ops() -> None:
conv_err = result.conversion_errors[0]
assert isinstance(conv_err, TFLiteConversionError)
- assert conv_err.message == "'tf.Erf' op is neither a custom op nor a flex op"
+ assert conv_err.message == "'tf.Softsign' op is neither a custom op nor a flex op"
assert conv_err.code == TFLiteConversionErrorCode.NEEDS_FLEX_OPS
- assert conv_err.operator == "tf.Erf"
+ assert conv_err.operator == "tf.Softsign"
assert len(conv_err.location) == 3
diff --git a/tox.ini b/tox.ini
index 017ee04..1a518d9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,7 @@ isolated_build = true
[testenv:test]
description = Run the unit tests.
deps =
- pytest==7.1.1
+ pytest==7.2.0
commands =
pytest {posargs:tests/}
@@ -15,7 +15,7 @@ commands =
description = Run the code coverage of the unit tests.
deps =
{[testenv:test]deps}
- pytest-cov==3.0.0
+ pytest-cov==4.0.0
commands =
pytest --cov=mlia --cov-report term-missing --cov-fail-under=95 tests/
@@ -26,8 +26,12 @@ description = Run and setup the pre-commit hooks.
envdir={toxworkdir}/lint
extras =
dev
-# Workaround to resolve an issue with markdownlint in a docker environment
-passenv = HOME
+# Pass the following environment variables:
+# - HOME: Workaround for an issue with markdownlint in a docker environment
+# - SKIP: Allows skipping of pre-commit hooks, e.g. "SKIP=reuse tox -e lint"
+passenv =
+ HOME
+ SKIP
commands =
lint_setup: pre-commit install-hooks
lint: pre-commit run --all-files --hook-stage=push {posargs}