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/high_level_command_stream.py b/ethosu/vela/high_level_command_stream.py
index 952e203..bdb0490 100644
--- a/ethosu/vela/high_level_command_stream.py
+++ b/ethosu/vela/high_level_command_stream.py
@@ -18,8 +18,10 @@
# Description:
# Contains classes that hold commands for the high-level command stream (one command per DMA or NPU stripe).
-from enum import Enum, IntEnum
+from enum import IntEnum
+
import numpy as np
+
from .operation import NpuBlockType
from .numeric_util import round_up_divide
from .range_set import MemoryAccessSet, AccessDirection
@@ -42,12 +44,12 @@
new_start_coord[concat_axis] -= concat_offset
new_end_coord[concat_axis] -= concat_offset
- if split_offset != None:
+ if split_offset is not None:
for idx in range(len(split_offset)):
new_start_coord[idx] += split_offset[idx]
new_end_coord[idx] += split_offset[idx]
- if split_offset == None and npu_block_type in set((NpuBlockType.ConvolutionMxN, NpuBlockType.VectorProduct)):
+ if split_offset is None and npu_block_type in set((NpuBlockType.ConvolutionMxN, NpuBlockType.VectorProduct)):
# these types of operations do a "dot product" over the entire IFM
new_start_coord[-1] = 0
new_end_coord[-1] = ifm_shape[-1]