diff options
author | Tim Hall <tim.hall@arm.com> | 2020-11-01 20:59:36 +0000 |
---|---|---|
committer | Tim Hall <tim.hall@arm.com> | 2020-11-20 12:55:47 +0000 |
commit | 1bd531dec0b4eb745fb8856d14c1aba2b8a73026 (patch) | |
tree | a0265a0accd2395277fe88be27164d09541abc7f /ethosu/vela/errors.py | |
parent | c8a73868d40cf63380f634baeb51aa7aa993fc0c (diff) | |
download | ethos-u-vela-1bd531dec0b4eb745fb8856d14c1aba2b8a73026.tar.gz |
MLBEDSW-3249: Vela config file examples
- Added sample vela.ini config file
- Changed vela config format, split into system config and memory mode
- Removed unused CPU cycle performance estimation
- Added new CLI options for --memory-mode and --verbose-config
- Changed CLI option --config to take multiple files
- Removed CLI option --global-memory-clock-scales
- Changed error helper functions to raise a VelaError exception
- Refactored to create a new is_spilling_enabled function
Signed-off-by: Tim Hall <tim.hall@arm.com>
Change-Id: I27c41577e37a3859edb9524cd99784be10ef0a0d
Diffstat (limited to 'ethosu/vela/errors.py')
-rw-r--r-- | ethosu/vela/errors.py | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/ethosu/vela/errors.py b/ethosu/vela/errors.py index 1a30d546..2a635d0e 100644 --- a/ethosu/vela/errors.py +++ b/ethosu/vela/errors.py @@ -15,8 +15,6 @@ # limitations under the License. # Description: # Defines custom exceptions. -import sys - from .operation import Operation from .tensor import Tensor @@ -25,31 +23,52 @@ class VelaError(Exception): """Base class for vela exceptions""" def __init__(self, data): - self.data = data + self.data = "Error: " + data def __str__(self): return repr(self.data) class InputFileError(VelaError): - """Raised when reading the input file results in errors""" + """Raised when reading an input file results in errors""" def __init__(self, file_name, msg): - self.data = "Error reading input file {}: {}".format(file_name, msg) + self.data = "Reading input file {}: {}".format(file_name, msg) class UnsupportedFeatureError(VelaError): - """Raised when the input file uses non-supported features that cannot be handled""" + """Raised when the input network uses non-supported features that cannot be handled""" def __init__(self, data): - self.data = "The input file uses a feature that is currently not supported: {}".format(data) + self.data = "Input network uses a feature that is currently not supported: {}".format(data) + +class CliOptionError(VelaError): + """Raised for errors encountered with a command line option -class OptionError(VelaError): - """Raised when an incorrect command line option is used""" + :param option: str object that contains the name of the command line option + :param option_value: the command line option that resulted in the error + :param msg: str object that contains a description of the specific error encountered + """ def __init__(self, option, option_value, msg): - self.data = "Incorrect argument to CLI option: {} {}: {}".format(option, option_value, msg) + self.data = "Incorrect argument to CLI option: {} = {}: {}".format(option, option_value, msg) + + +class ConfigOptionError(VelaError): + """Raised for errors encountered with a configuration option + + :param option: str object that contains the name of the configuration option + :param option_value: the configuration option that resulted in the error + :param option_valid_values (optional): str object that contains the valid configuration option values + """ + + def __init__(self, option, option_value, option_valid_values=None): + self.data = "Invalid configuration of {} = {}".format(option, option_value) + if option_valid_values is not None: + self.data += " (must be {}).".format(option_valid_values) + else: + self.data += "." class AllocationError(VelaError): @@ -60,7 +79,12 @@ class AllocationError(VelaError): def OperatorError(op, msg): - """Called when parsing an operator results in errors""" + """ + Raises a VelaError exception for errors encountered when parsing an Operation + + :param op: Operation object that resulted in the error + :param msg: str object that contains a description of the specific error encountered + """ assert isinstance(op, Operation) @@ -91,12 +115,16 @@ def OperatorError(op, msg): data = data[:-1] # remove last newline - print("Error: {}".format(data)) - sys.exit(1) + raise VelaError(data) def TensorError(tens, msg): - """Called when parsing a tensor results in errors""" + """ + Raises a VelaError exception for errors encountered when parsing a Tensor + + :param tens: Tensor object that resulted in the error + :param msg: str object that contains a description of the specific error encountered + """ assert isinstance(tens, Tensor) @@ -126,5 +154,4 @@ def TensorError(tens, msg): data = data[:-1] # remove last newline - print("Error: {}".format(data)) - sys.exit(1) + raise VelaError(data) |