diff options
author | Diego Russo <diego.russo@arm.com> | 2020-04-14 18:41:58 +0100 |
---|---|---|
committer | Tim Hall <tim.hall@arm.com> | 2020-06-18 17:53:52 +0100 |
commit | ea6111a36e55501bbfb9ea022aaf8305b4d80183 (patch) | |
tree | f6787f7d07ea56a502616a8d6f36bc9c7e6e4efe /ethosu/vela/driver_actions.py | |
parent | 2213e90570af328418d4f4a0d54269ed21dc40bc (diff) | |
download | ethos-u-vela-ea6111a36e55501bbfb9ea022aaf8305b4d80183.tar.gz |
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>
Diffstat (limited to 'ethosu/vela/driver_actions.py')
-rw-r--r-- | ethosu/vela/driver_actions.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ethosu/vela/driver_actions.py b/ethosu/vela/driver_actions.py index 86c4a369..bd15af20 100644 --- a/ethosu/vela/driver_actions.py +++ b/ethosu/vela/driver_actions.py @@ -18,9 +18,11 @@ # Description: # Creates driver actions that are embedded in the custom operator payload. -import numpy as np from typing import List -from .ethos_u55_regs.ethos_u55_regs import * + +import numpy as np + +from .ethos_u55_regs.ethos_u55_regs import config_r, id_r, ARCH_VER class DACommands: @@ -43,8 +45,8 @@ def make_da_tag(id: int, reserved: int, param: int) -> int: def emit_fourcc(data: List[int], fourcc: str): - assert data != None - assert fourcc != None + assert data is not None + assert fourcc is not None assert len(fourcc) == 4 value: int = 0 value = fourcc[0].encode()[0] @@ -75,14 +77,14 @@ def build_config_word(arch): def emit_config(data: List[int], rel: int, patch: int, arch): - assert data != None + assert data is not None data.append(make_da_tag(DACommands.Config, 0, (patch << DACommands.Config_PatchShift) | rel)) data.append(build_config_word(arch)) data.append(build_id_word()) def emit_cmd_stream_header(data: List[int], length: int): - assert data != None + assert data is not None # Insert NOPs to align start of command stream to 16 bytes num_nops = 4 - ((len(data) + 1) % 4) for _ in range(num_nops): @@ -95,7 +97,7 @@ def emit_cmd_stream_header(data: List[int], length: int): def emit_reg_read(data: List[int], reg_index: int, reg_count: int = 1): - assert data != None + assert data is not None assert reg_index >= 0 assert reg_count >= 1 payload: int = (reg_index & DACommands.ReadAPB_IndexMask) | ((reg_count << DACommands.ReadAPB_CountShift) - 1) @@ -103,5 +105,5 @@ def emit_reg_read(data: List[int], reg_index: int, reg_count: int = 1): def emit_dump_shram(data: List[int]): - assert data != None + assert data is not None data.append(make_da_tag(DACommands.DumpSHRAM, 0, 0)) |