I have a testing framework that does negative testing of operations. It specifically builds incorrect operations and makes sure the operations’ verify functions catch these cases. However one side effect from this is that the InFlightDiagnostic from emitOpError/emitOpWarning is printed out to stdout/err. I was wondering if there is an API to toggle this printout off for a bit and then turn it back on again. I know I can suppress all stdout/stderr from my application but I was wondering if there was some builtin method in MLIR just for InFlightDiagnostics. Maybe a verbosity flag that only prints diagnostics that are at that level or higher? Thanks in advance for the help!
You can register a diagnostic handler that intercept these. It’s only the default handler that prints on stderr.
For example in TensorFlow we want to capture these diagnostics, bundle them into an
absl::Status object, and propagate them to the caller. Here is our handler: tensorflow/error_util.h at master · tensorflow/tensorflow · GitHub
Thanks Mehdi! That worked like a charm.