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

Method error

python/tvm/script/parser/core/diagnostics.py:278–305  ·  view source on GitHub ↗

Emit a diagnostic error by raising with source location context. Parameters ---------- node : doc.AST The node with diagnostic error. message : str The diagnostic message.

(self, node: doc.AST, message: str)

Source from the content-addressed store, hash-verified

276 self.source = source
277
278 def error(self, node: doc.AST, message: str) -> None:
279 """Emit a diagnostic error by raising with source location context.
280
281 Parameters
282 ----------
283 node : doc.AST
284 The node with diagnostic error.
285
286 message : str
287 The diagnostic message.
288 """
289 lineno = getattr(node, "lineno", 1)
290 col_offset = getattr(node, "col_offset", self.source.start_column)
291 end_lineno = getattr(node, "end_lineno", lineno)
292 end_col_offset = getattr(node, "end_col_offset", col_offset)
293 lineno += self.source.start_line - 1
294 end_lineno += self.source.start_line - 1
295 col_offset += self.source.start_column + 1
296 end_col_offset += self.source.start_column + 1
297
298 source_lines = self.source.full_source.splitlines(keepends=True)
299 snippet = _format_source_snippet(
300 source_lines, lineno, col_offset, end_lineno, end_col_offset
301 )
302
303 location = f"{self.source.source_name}:{lineno}:{col_offset}"
304 formatted = f"error: {message}\n --> {location}\n{snippet}"
305 raise DiagnosticError(formatted)

Callers 9

LUT_generationFunction · 0.80
report_errorMethod · 0.80
resolve_bundlesFunction · 0.80
s3.pyFile · 0.80
tryCreateBufferFunction · 0.80
responseTostoretypeMethod · 0.80
initDBMethod · 0.80
normalizeCacheTypeFunction · 0.80
initWebGPUMethod · 0.80

Calls 2

DiagnosticErrorClass · 0.90
_format_source_snippetFunction · 0.85

Tested by

no test coverage detected