aboutsummaryrefslogtreecommitdiff
path: root/src/mlia/nn
diff options
context:
space:
mode:
authorBenjamin Klimczak <benjamin.klimczak@arm.com>2022-07-11 12:33:42 +0100
committerBenjamin Klimczak <benjamin.klimczak@arm.com>2022-07-26 14:08:21 +0100
commit5d81f37de09efe10f90512e50252be9c36925fcf (patch)
treeb4d7cdfd051da0a6e882bdfcf280fd7ca7b39e57 /src/mlia/nn
parent7899b908c1fe6d86b92a80f3827ddd0ac05b674b (diff)
downloadmlia-5d81f37de09efe10f90512e50252be9c36925fcf.tar.gz
MLIA-551 Rework remains of AIET architecture
Re-factoring the code base to further merge the old AIET code into MLIA. - Remove last traces of the backend type 'tool' - Controlled systems removed, including SSH protocol, controller, RunningCommand, locks etc. - Build command / build dir and deploy functionality removed from Applications and Systems - Moving working_dir() - Replace module 'output_parser' with new module 'output_consumer' and merge Base64 parsing into it - Change the output consumption to optionally remove (i.e. actually consume) lines - Use Base64 parsing in GenericInferenceOutputParser, replacing the regex-based parsing and remove the now unused regex parsing - Remove AIET reporting - Pre-install applications by moving them to src/mlia/resources/backends - Rename aiet-config.json to backend-config.json - Move tests from tests/mlia/ to tests/ - Adapt unit tests to code changes - Dependencies removed: paramiko, filelock, psutil - Fix bug in corstone.py: The wrong resource directory was used which broke the functionality to download backends. - Use f-string formatting. - Use logging instead of print. Change-Id: I768bc3bb6b2eda57d219ad01be4a8e0a74167d76
Diffstat (limited to 'src/mlia/nn')
-rw-r--r--src/mlia/nn/tensorflow/tflite_metrics.py33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/mlia/nn/tensorflow/tflite_metrics.py b/src/mlia/nn/tensorflow/tflite_metrics.py
index 0fe36e0..2252c6b 100644
--- a/src/mlia/nn/tensorflow/tflite_metrics.py
+++ b/src/mlia/nn/tensorflow/tflite_metrics.py
@@ -194,9 +194,7 @@ class TFLiteMetrics:
aggregation_func = cluster_hist
else:
- raise NotImplementedError(
- "ReportClusterMode '{}' not implemented.".format(mode)
- )
+ raise NotImplementedError(f"ReportClusterMode '{mode}' not implemented.")
uniques = {
name: aggregation_func(details)
for name, details in self.filtered_details.items()
@@ -217,10 +215,10 @@ class TFLiteMetrics:
verbose: bool = False,
) -> None:
"""Print a summary of all the model information."""
- print("Model file: {}".format(self.tflite_file))
+ print(f"Model file: {self.tflite_file}")
print("#" * 80)
print(" " * 28 + "### TFLITE SUMMARY ###")
- print("File: {}".format(os.path.abspath(self.tflite_file)))
+ print(f"File: {os.path.abspath(self.tflite_file)}")
print("Input(s):")
self._print_in_outs(self.interpreter.get_input_details(), verbose)
print("Output(s):")
@@ -242,11 +240,11 @@ class TFLiteMetrics:
]
if report_sparsity:
sparsity = calculate_sparsity(weights, sparsity_accumulator)
- row.append("{:.2f}".format(sparsity))
+ row.append(f"{sparsity:.2f}")
rows.append(row)
if verbose:
# Print cluster centroids
- print("{} cluster centroids:".format(name))
+ print(f"{name} cluster centroids:")
# Types need to be ignored for this function call because
# np.unique does not have type annotation while the
# current context does.
@@ -259,9 +257,9 @@ class TFLiteMetrics:
sparsity_accumulator.total_weights
)
if report_sparsity:
- summary_row[header.index("Sparsity")] = "{:.2f}".format(
- sparsity_accumulator.sparsity()
- )
+ summary_row[
+ header.index("Sparsity")
+ ] = f"{sparsity_accumulator.sparsity():.2f}"
rows.append(summary_row)
# Report detailed cluster info
if report_cluster_mode is not None:
@@ -272,7 +270,7 @@ class TFLiteMetrics:
def _print_cluster_details(
self, report_cluster_mode: ReportClusterMode, max_num_clusters: int
) -> None:
- print("{}:\n{}".format(report_cluster_mode.name, report_cluster_mode.value))
+ print(f"{report_cluster_mode.name}:\n{report_cluster_mode.value}")
num_clusters = self.num_unique_weights(report_cluster_mode)
if (
report_cluster_mode == ReportClusterMode.NUM_CLUSTERS_HISTOGRAM
@@ -283,11 +281,9 @@ class TFLiteMetrics:
# histogram for unclustered layers.
for name, value in num_clusters.items():
if len(value) > max_num_clusters:
- num_clusters[name] = "More than {} unique values.".format(
- max_num_clusters
- )
+ num_clusters[name] = f"More than {max_num_clusters} unique values."
for name, nums in num_clusters.items():
- print("- {}: {}".format(self._prettify_name(name), nums))
+ print(f"- {self._prettify_name(name)}: {nums}")
@staticmethod
def _print_in_outs(ios: List[dict], verbose: bool = False) -> None:
@@ -296,9 +292,6 @@ class TFLiteMetrics:
pprint(item)
else:
print(
- "- {} ({}): {}".format(
- item["name"],
- np.dtype(item["dtype"]).name,
- item["shape"],
- )
+ f"- {item['name']} ({np.dtype(item['dtype']).name}): "
+ f"{item['shape']}"
)