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/live_range.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/live_range.py')
-rw-r--r-- | ethosu/vela/live_range.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ethosu/vela/live_range.py b/ethosu/vela/live_range.py index 24f1f64c..54c15ba9 100644 --- a/ethosu/vela/live_range.py +++ b/ethosu/vela/live_range.py @@ -20,7 +20,7 @@ # Can work with either a pass packed subgraph or a scheduled subgraph. from .tensor import Tensor, MemArea -from .nn_graph import TensorPurpose, PassPlacement +from .nn_graph import PassPlacement from .high_level_command_stream_generator import calc_allowed_ofm_ifm_overlap_for_cascaded_pass @@ -90,9 +90,9 @@ class LiveRange: if tens.address == 0: tens.address = address # Also need to set the address to the tensor's cpu/npu clones - if tens.cpu_tensor != None: + if tens.cpu_tensor is not None: tens.cpu_tensor.address = address - if tens.npu_tensor != None: + if tens.npu_tensor is not None: tens.npu_tensor.address = address def get_alignment(self): @@ -115,8 +115,8 @@ def merge_memory_op_ranges(sg, lr_graph, tensor_should_be_ignored, target_mem_ar output_tensor = ps.outputs[0] # If the input or output tensor is tied to a Cpu tensor, i.e. a subgraph input # or output, fuse the live-range with the Cpu tensors' live-range instead. - input_tensor = input_tensor.cpu_tensor if input_tensor.cpu_tensor != None else input_tensor - output_tensor = output_tensor.cpu_tensor if output_tensor.cpu_tensor != None else output_tensor + input_tensor = input_tensor.cpu_tensor if input_tensor.cpu_tensor is not None else input_tensor + output_tensor = output_tensor.cpu_tensor if output_tensor.cpu_tensor is not None else output_tensor if not tensor_should_be_ignored(input_tensor, target_mem_area) and not tensor_should_be_ignored( output_tensor, target_mem_area ): @@ -221,7 +221,7 @@ def extract_live_ranges_from_cascaded_passes( ignore_subgraph_input_output_tensors=False, lr_graph=None, ): - if lr_graph == None: + if lr_graph is None: lr_graph = LiveRangeGraph() if sg in lr_graph.processed_subgraphs: |