diff options
author | Dmitrii Agibov <dmitrii.agibov@arm.com> | 2022-09-08 14:24:39 +0100 |
---|---|---|
committer | Dmitrii Agibov <dmitrii.agibov@arm.com> | 2022-09-09 17:21:48 +0100 |
commit | f5b293d0927506c2a979a091bf0d07ecc78fa181 (patch) | |
tree | 4de585b7cb6ed34da8237063752270189a730a41 /tests/test_nn_tensorflow_optimizations_clustering.py | |
parent | cde0c6ee140bd108849bff40467d8f18ffc332ef (diff) | |
download | mlia-f5b293d0927506c2a979a091bf0d07ecc78fa181.tar.gz |
MLIA-386 Simplify typing in the source code
- Enable deferred annotations evaluation
- Use builtin types for type hints whenever possible
- Use | syntax for union types
- Rename mlia.core._typing into mlia.core.typing
Change-Id: I3f6ffc02fa069c589bdd9e8bddbccd504285427a
Diffstat (limited to 'tests/test_nn_tensorflow_optimizations_clustering.py')
-rw-r--r-- | tests/test_nn_tensorflow_optimizations_clustering.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/test_nn_tensorflow_optimizations_clustering.py b/tests/test_nn_tensorflow_optimizations_clustering.py index c12a1e8..13dfb31 100644 --- a/tests/test_nn_tensorflow_optimizations_clustering.py +++ b/tests/test_nn_tensorflow_optimizations_clustering.py @@ -1,9 +1,9 @@ # SPDX-FileCopyrightText: Copyright 2022, Arm Limited and/or its affiliates. # SPDX-License-Identifier: Apache-2.0 """Test for module optimizations/clustering.""" +from __future__ import annotations + from pathlib import Path -from typing import List -from typing import Optional import pytest import tensorflow as tf @@ -21,7 +21,7 @@ from tests.utils.common import train_model def _prune_model( - model: tf.keras.Model, target_sparsity: float, layers_to_prune: Optional[List[str]] + model: tf.keras.Model, target_sparsity: float, layers_to_prune: list[str] | None ) -> tf.keras.Model: x_train, y_train = get_dataset() batch_size = 1 @@ -47,7 +47,7 @@ def _prune_model( def _test_num_unique_weights( metrics: TFLiteMetrics, target_num_clusters: int, - layers_to_cluster: Optional[List[str]], + layers_to_cluster: list[str] | None, ) -> None: clustered_uniqueness_dict = metrics.num_unique_weights( ReportClusterMode.NUM_CLUSTERS_PER_AXIS @@ -71,7 +71,7 @@ def _test_num_unique_weights( def _test_sparsity( metrics: TFLiteMetrics, target_sparsity: float, - layers_to_cluster: Optional[List[str]], + layers_to_cluster: list[str] | None, ) -> None: pruned_sparsity_dict = metrics.sparsity_per_layer() num_sparse_layers = 0 @@ -95,7 +95,7 @@ def _test_sparsity( def test_cluster_simple_model_fully( target_num_clusters: int, sparsity_aware: bool, - layers_to_cluster: Optional[List[str]], + layers_to_cluster: list[str] | None, tmp_path: Path, test_keras_model: Path, ) -> None: |