tvm
Public Member Functions | List of all members
tvm::relay::ErrorReporter Class Reference

An abstraction around how errors are stored and reported. Designed to be opaque to users, so we can support a robust and simpler error reporting mode, as well as a more complex mode. More...

#include <error.h>

Collaboration diagram for tvm::relay::ErrorReporter:

Public Member Functions

 ErrorReporter ()
 default constructor. More...
 
void Report (const CompileError &err)
 Report a CompileError. More...
 
void ReportAt (const GlobalVar &global, const ObjectRef &node, std::stringstream &err)
 Report an error against a program, using the full program error reporting strategy. More...
 
void ReportAt (const GlobalVar &global, const ObjectRef &node, const CompileError &err)
 Report an error against a program, using the full program error reporting strategy. More...
 
void RenderErrors (const IRModule &module, bool use_color=true)
 Render all reported errors and exit the program. More...
 
bool AnyErrors ()
 

Detailed Description

An abstraction around how errors are stored and reported. Designed to be opaque to users, so we can support a robust and simpler error reporting mode, as well as a more complex mode.

The first mode is the most accurate: we report a Relay error at a specific Span, and then render the error message directly against a textual representation of the program, highlighting the exact lines in which it occurs. This mode is not implemented in this PR and will not work.

The second mode is a general-purpose mode, which attempts to annotate the program's textual format with errors.

The final mode represents the old mode, if we report an error that has no span or expression, we will default to throwing an exception with a textual representation of the error and no indication of where it occurred in the original program.

The latter mode is not ideal, and the goal of the new error reporting machinery is to avoid ever reporting errors in this style.

Constructor & Destructor Documentation

◆ ErrorReporter()

tvm::relay::ErrorReporter::ErrorReporter ( )
inline

default constructor.

Member Function Documentation

◆ AnyErrors()

bool tvm::relay::ErrorReporter::AnyErrors ( )
inline

◆ RenderErrors()

void tvm::relay::ErrorReporter::RenderErrors ( const IRModule module,
bool  use_color = true 
)

Render all reported errors and exit the program.

This function should be used after executing a pass to render reported errors.

It will build an error message from the set of errors, depending on the error reporting strategy.

Parameters
moduleThe module to report errors on.
use_colorControls whether to colorize the output.

◆ Report()

void tvm::relay::ErrorReporter::Report ( const CompileError err)
inline

Report a CompileError.

This API is useful for reporting spanned errors.

Parameters
errThe error to report.

◆ ReportAt() [1/2]

void tvm::relay::ErrorReporter::ReportAt ( const GlobalVar global,
const ObjectRef node,
const CompileError err 
)

Report an error against a program, using the full program error reporting strategy.

This error reporting method requires the global function in which to report an error, the expression to report the error on, and the error object.

Parameters
globalThe global function in which the expression is contained.
nodeThe expression or type to report the error at.
errThe error to report.

◆ ReportAt() [2/2]

void tvm::relay::ErrorReporter::ReportAt ( const GlobalVar global,
const ObjectRef node,
std::stringstream &  err 
)
inline

Report an error against a program, using the full program error reporting strategy.

This error reporting method requires the global function in which to report an error, the expression to report the error on, and the error object.

Parameters
globalThe global function in which the expression is contained.
nodeThe expression or type to report the error at.
errThe error message to report.

The documentation for this class was generated from the following file: