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/architecture_features.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/architecture_features.py')
-rw-r--r-- | ethosu/vela/architecture_features.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/ethosu/vela/architecture_features.py b/ethosu/vela/architecture_features.py index 51c632e0..69f95fa2 100644 --- a/ethosu/vela/architecture_features.py +++ b/ethosu/vela/architecture_features.py @@ -18,13 +18,17 @@ # Description: # Holds a container for Ethos-U55/System architecture parameters. -from .nn_graph import MemArea, TensorPurpose, NpuBlockType, TensorFormat -from .numeric_util import round_up, round_up_divide +import enum from collections import namedtuple from configparser import ConfigParser -from .supported_operators import SupportedOperators + import numpy as np -import enum + +from .tensor import MemArea, TensorPurpose, TensorFormat +from .operation import NpuBlockType +from .numeric_util import round_up, round_up_divide +from .supported_operators import SupportedOperators + PointXY = namedtuple("PointXY", "x y") PointXYZ = namedtuple("PointXYZ", "x y z") @@ -151,7 +155,7 @@ Note the difference between ArchitectureFeatures and CompilerOptions accelerator_config = accelerator_config.lower() self.vela_config = vela_config self.accelerator_config = accelerator_config - if not self.accelerator_config in ArchitectureFeatures.accelerator_configs: + if self.accelerator_config not in ArchitectureFeatures.accelerator_configs: raise Exception("Unknown accelerator configuration " + self.accelerator_config) accel_config = ArchitectureFeatures.accelerator_configs[self.accelerator_config] self.config = accel_config @@ -450,7 +454,6 @@ Note the difference between ArchitectureFeatures and CompilerOptions ) # Calculate how many IFM blocks this OFM block requires (i.e how many jobs) - ifm_block = self.get_ifm_block_size(ifm_block_depth, ofm_block, kernel, self.ofm_block_max) ifm_depth_blocks = round_up_divide(ifm.size().depth, ifm_block_depth) ifm_depth_blocks = 1 # Overwrite with 1 to force OFM block dependency, not IFM @@ -476,7 +479,6 @@ Note the difference between ArchitectureFeatures and CompilerOptions # Iterate over the next BLOCKDEP inputs, checking to see if a sliding window # of IFM area overlaps with any previous OFM block generation. elapsed_jobs = 0 - ifm_depth = ifm.size().depth for forward_offset in range(ArchitectureFeatures.MAX_BLOCKDEP): # This is the IFM block we want to sample from in_area = self.get_first_job_input_volume( @@ -533,7 +535,7 @@ Note the difference between ArchitectureFeatures and CompilerOptions n_elements = op.inputs[0].elements() cycles = intercept + n_elements * slope return cycles - except: + except Exception: print("Error: Reading CPU cycle estimate in vela configuration file, section {}".format(section)) raise @@ -554,7 +556,7 @@ Note the difference between ArchitectureFeatures and CompilerOptions print("Warning: Using default values for system configuration") else: section_key = "SysConfig." + self.system_config - if not section_key in self.vela_config: + if section_key not in self.vela_config: raise Exception("Unknown system configuration " + self.system_config) try: @@ -585,7 +587,7 @@ Note the difference between ArchitectureFeatures and CompilerOptions + " (must be 'OnChipFlash' or 'OffChipFlash'). To store the weights and other constant data in SRAM" " select 'OnChipFlash'" ) - except: + except Exception: print("Error: Reading System Configuration in vela configuration file, section {}".format(section_key)) raise |