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/npu_serialisation.py b/ethosu/vela/npu_serialisation.py
index 4542c25..29ede84 100644
--- a/ethosu/vela/npu_serialisation.py
+++ b/ethosu/vela/npu_serialisation.py
@@ -18,13 +18,15 @@
 # Description:
 # Serialises and packs an NPU subgraph into tensors.
 
+import struct
+
+import numpy as np
+
+from . import driver_actions
 from .nn_graph import PassPlacement
 from .tensor import MemArea, Tensor, TensorPurpose, TensorFormat
 from .operation import Operation
 from .data_type import DataType
-import numpy as np
-from . import driver_actions
-import struct
 
 
 def make_memory_tensor(name, mem_area, sz, want_values, arch):
@@ -75,7 +77,7 @@
     nng.total_size[scratch_area] = nng.total_size.get(scratch_area, 0) - scratch_size
     nng.total_elements[scratch_area] = nng.total_elements.get(scratch_area, 0) - scratch_size
 
-    if flash_tens == scratch_tens == None:
+    if flash_tens == scratch_tens is None:
         # First Npu subgraph, create scratch and flash tensors
         sg.scratch_tensor = make_memory_tensor(sg.name + "_scratch", scratch_area, scratch_size, False, arch)
         sg.scratch_tensor.purpose = TensorPurpose.Scratch
@@ -88,7 +90,7 @@
 
     for cps in sg.cascaded_passes:
         for ps in cps.passes:
-            if ps.placement == PassPlacement.Npu and ps.weight_tensor != None:
+            if ps.placement == PassPlacement.Npu and ps.weight_tensor is not None:
                 # For DMA ops, ps.weight_tensor is referring to the SRAM weight tensor and therefore the address
                 # is pointing at the destination address of where the weights should be placed in SRAM.
                 # This ensures that the Flash weight tensor is used instead and thus gets the correct address.