From f5b293d0927506c2a979a091bf0d07ecc78fa181 Mon Sep 17 00:00:00 2001 From: Dmitrii Agibov Date: Thu, 8 Sep 2022 14:24:39 +0100 Subject: 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 --- tests/test_nn_tensorflow_optimizations_clustering.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/test_nn_tensorflow_optimizations_clustering.py') 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: -- cgit v1.2.1