diff options
author | Raul Farkas <raul.farkas@arm.com> | 2022-07-11 20:09:48 +0100 |
---|---|---|
committer | Diego Russo <diego.russo@arm.com> | 2022-07-22 10:59:29 +0000 |
commit | 625c280433fef3c9d1b64f58eab930ba0f89cd82 (patch) | |
tree | d7c1c9900abd76aa85515ad930572f9739a24dbe /src/mlia/nn/tensorflow/tflite_metrics.py | |
parent | 7a09acbd1bccc9a7f81d79ed57259a0d32aa6873 (diff) | |
download | mlia-625c280433fef3c9d1b64f58eab930ba0f89cd82.tar.gz |
MLIA-507 Upgrade Vela version
Upgrade Vela version from 3.3.0 to 3.4.0.
- Adapt code to use new typing notation by replacing `numpy.array` with `numpy.ndarray` where necessary.
Change-Id: I035e9564d448652aa09a52d79c71ef09663ea776
Diffstat (limited to 'src/mlia/nn/tensorflow/tflite_metrics.py')
-rw-r--r-- | src/mlia/nn/tensorflow/tflite_metrics.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mlia/nn/tensorflow/tflite_metrics.py b/src/mlia/nn/tensorflow/tflite_metrics.py index b29fab3..9befb2f 100644 --- a/src/mlia/nn/tensorflow/tflite_metrics.py +++ b/src/mlia/nn/tensorflow/tflite_metrics.py @@ -31,13 +31,13 @@ DEFAULT_IGNORE_LIST = [ ] -def calculate_num_unique_weights(weights: np.array) -> int: +def calculate_num_unique_weights(weights: np.ndarray) -> int: """Calculate the number of unique weights in the given weights.""" num_unique_weights = len(np.unique(weights)) return num_unique_weights -def calculate_num_unique_weights_per_axis(weights: np.array, axis: int) -> List[int]: +def calculate_num_unique_weights_per_axis(weights: np.ndarray, axis: int) -> List[int]: """Calculate unique weights per quantization axis.""" # Make quantized dimension the first dimension weights_trans = np.swapaxes(weights, 0, axis) @@ -57,7 +57,7 @@ class SparsityAccumulator: self.total_non_zero_weights: int = 0 self.total_weights: int = 0 - def __call__(self, weights: np.array) -> None: + def __call__(self, weights: np.ndarray) -> None: """Update the accumulator with the given weights.""" non_zero_weights = np.count_nonzero(weights) self.total_non_zero_weights += non_zero_weights @@ -69,7 +69,7 @@ class SparsityAccumulator: def calculate_sparsity( - weights: np.array, accumulator: Optional[SparsityAccumulator] = None + weights: np.ndarray, accumulator: Optional[SparsityAccumulator] = None ) -> float: """ Calculate the sparsity for the given weights. |