MCPcopy Index your code
hub / github.com/apache/tvm / report_error

Method report_error

python/tvm/script/parser/core/parser.py:600–636  ·  view source on GitHub ↗

The error reporting when parsing. Parameters ---------- node : doc.AST The doc AST node with errors. err: Union[Exception, str] The error to report.

(self, node: doc.AST, err: Exception | str)

Source from the content-addressed store, hash-verified

598 return var_values
599
600 def report_error(self, node: doc.AST, err: Exception | str) -> None: # pylint: disable=no-self-use
601 """The error reporting when parsing.
602
603 Parameters
604 ----------
605 node : doc.AST
606 The doc AST node with errors.
607
608 err: Union[Exception, str]
609 The error to report.
610 """
611
612 # If the error is already being raised as a DiagnosticError,
613 # re-raise it without wrapping it in a DiagnosticContext.
614 if isinstance(err, DiagnosticError):
615 raise err
616
617 # Only take the last line of the error message
618 if isinstance(err, RuntimeError):
619 lines = list(filter(None, str(err).split("\n")))
620 msg = lines[-1] if lines else (str(err) or type(err).__name__)
621 elif isinstance(err, KeyError):
622 msg = "KeyError: " + str(err)
623 else:
624 msg = str(err)
625
626 try:
627 self.diag.error(node, msg)
628 except Exception as diag_err:
629 # Calling self.diag.error is guaranteed to throw an
630 # exception. When shown to a user, this error should
631 # reference the point of error within the provided
632 # TVMScript. However, when caught in pdb, the full
633 # traceback should be available for debugging.
634 if isinstance(err, Exception):
635 diag_err = diag_err.with_traceback(err.__traceback__)
636 raise diag_err
637
638 def visit(self, node: doc.AST) -> None:
639 """The general visiting method.

Callers 15

get_dispatch_tokenMethod · 0.95
_duplicate_lhs_checkMethod · 0.95
eval_assignMethod · 0.95
visitMethod · 0.95
visit_FunctionDefMethod · 0.95
visit_ClassDefMethod · 0.95
parseFunction · 0.95
bind_assign_valueFunction · 0.80
eval_struct_info_proxyFunction · 0.80
eval_struct_infoFunction · 0.80
visit_function_defFunction · 0.80

Calls 4

filterFunction · 0.85
strFunction · 0.85
errorMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected