aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/errors.py
diff options
context:
space:
mode:
authorMichael McGeagh <michael.mcgeagh@arm.com>2020-12-16 11:33:21 +0000
committerpatrik.gustavsson <patrik.gustavsson@arm.com>2020-12-18 15:02:32 +0000
commit528a56df829b65f7a2c61953650b123c461095f7 (patch)
treee616cdfff4b40a29d362bab51e6641ec364ae115 /ethosu/vela/errors.py
parent1a184e4a50ad2f3cc8c5bfcd23e0f875c089314c (diff)
downloadethos-u-vela-528a56df829b65f7a2c61953650b123c461095f7.tar.gz
vela: Move special error cases
Due to an issue with potential cyclical imports, especially when running individual parts of vela standalone for example with pytest, the specialised error functions are moved out of errors.py to their respective locations. The use of getattr over isinstance prevents the need to import the tensor/operator class causing the cyclical import issue. Signed-off-by: Michael McGeagh <michael.mcgeagh@arm.com> Change-Id: If8cee4b1a2562660c6a47e1c7aeb5d7fd4dd1fca
Diffstat (limited to 'ethosu/vela/errors.py')
-rw-r--r--ethosu/vela/errors.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/ethosu/vela/errors.py b/ethosu/vela/errors.py
index b241db8e..04468c90 100644
--- a/ethosu/vela/errors.py
+++ b/ethosu/vela/errors.py
@@ -15,8 +15,6 @@
# limitations under the License.
# Description:
# Defines custom exceptions.
-from .operation import Operation
-from .tensor import Tensor
class VelaError(Exception):
@@ -75,70 +73,3 @@ class AllocationError(VelaError):
def __init__(self, msg):
super().__init__(f"Allocation failed: {msg}")
-
-
-def OperatorError(op, msg):
- """
- 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
- """
-
- def _print_tensors(tensors):
- lines = []
- for idx, tens in enumerate(tensors):
- if isinstance(tens, Tensor):
- tens_name = tens.name
- else:
- tens_name = "Not a Tensor"
- lines.append(f" {idx} = {tens_name}")
- return lines
-
- assert isinstance(op, Operation)
-
- if op.op_index is None:
- lines = [f"Invalid {op.type} (name = {op.name}) operator in the internal representation. {msg}"]
- else:
- lines = [f"Invalid {op.type} (op_index = {op.op_index}) operator in the input network. {msg}"]
-
- lines += [" Input tensors:"]
- lines += _print_tensors(op.inputs)
-
- lines += [" Output tensors:"]
- lines += _print_tensors(op.outputs)
-
- raise VelaError("\n".join(lines))
-
-
-def TensorError(tens, msg):
- """
- 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
- """
-
- def _print_operators(ops):
- lines = []
- for idx, op in enumerate(ops):
- if isinstance(op, Operation):
- op_type = op.type
- op_id = f"({op.op_index})"
- else:
- op_type = "Not an Operation"
- op_id = ""
- lines.append(f" {idx} = {op_type} {op_id}")
- return lines
-
- assert isinstance(tens, Tensor)
-
- lines = [f"Invalid {tens.name} tensor. {msg}"]
-
- lines += [" Driving operators:"]
- lines += _print_operators(tens.ops)
-
- lines += [" Consuming operators:"]
- lines += _print_operators(tens.consumer_list)
-
- raise VelaError("\n".join(lines))