Add pre-commit support for sanity checks
Use pre-commit framework [1] to run black and flake8 before the commit.
black and flake8 are managed by the pre-commit framework and they can be
run manually by the user using `pre-commit run` command.
Fix the code base with the help of black and flake8.
Fix import statements according to PEP8 guidelines [1]
Both tools have the following settings (specified in the pre-commit
configuration file):
* line length: 120 characters
* directory to exclude: ethosu/vela/tflite/ and ethosu/vela/ethos_u55_regs
Updated README.md on how to install pre-commit and how to run sanity checks.
Pipenv files have been updated including new dependencies for pre-commit.
[1]: https://www.python.org/dev/peps/pep-0008/#imports
[2]: https://github.com/pre-commit/pre-commit
Change-Id: I304d9fffdf019d390ffa396a529c8a7c2437f63d
Signed-off-by: Diego Russo <diego.russo@arm.com>
diff --git a/ethosu/vela/tflite_reader.py b/ethosu/vela/tflite_reader.py
index 535847d..4456d5a 100644
--- a/ethosu/vela/tflite_reader.py
+++ b/ethosu/vela/tflite_reader.py
@@ -18,14 +18,15 @@
# Description:
# Functions used to read from a TensorFlow Lite format file.
-from .tflite.Model import Model
-from .tflite.BuiltinOperator import BuiltinOperator
+import os.path
import numpy as np
-import os.path
-from .nn_graph import Graph, Operation, Subgraph
-from .tensor import Tensor, QuantizationParameters
+from .tflite.Model import Model
+from .tflite.BuiltinOperator import BuiltinOperator
+from .nn_graph import Graph, Subgraph
+from .operation import Operation
+from .tensor import Tensor, QuantizationParameters
from .tflite_mapping import builtin_operator_map, datatype_map, datatype_map_numpy, DataType
@@ -184,12 +185,7 @@
class TFLiteGraph:
def __init__(
- self,
- filename,
- batch_size=1,
- feed_dict={},
- output_node_names=[],
- initialisation_nodes=[],
+ self, filename, batch_size=1, feed_dict={}, output_node_names=[], initialisation_nodes=[],
):
self.op_times = {}
@@ -238,15 +234,9 @@
def read_tflite(
- filename,
- batch_size=1,
- feed_dict={},
- output_node_names=[],
- initialisation_nodes=[],
+ filename, batch_size=1, feed_dict={}, output_node_names=[], initialisation_nodes=[],
):
- tflite_graph = TFLiteGraph(
- filename, batch_size, feed_dict, output_node_names, initialisation_nodes
- )
+ tflite_graph = TFLiteGraph(filename, batch_size, feed_dict, output_node_names, initialisation_nodes)
nng = tflite_graph.nng
nng.refresh_after_modification()
return nng