[XLA] Make NoteError and NoteErrorOrReturn public, rename them to ReportError...
[XLA] Make NoteError and NoteErrorOrReturn public, rename them to ReportError and ReportErrorOrReturn. Change NoteError to return an XlaOp. The goal of this change is to remove an asymmetry between ops defined internally to XLA (inside XlaBuilder) and ops defined inside client libraries built around XLA: * Ops defined inside XlaBuilder unconditionally return an XlaOp, and report failures via the builder that are returned on the next XlaBuilder::Build() call. * Library functions defined outside XlaBuilder cannot report errors via the builder, so they typically must have a StatusOr<XlaOp> signature. This leads to very verbose code (e.g., look at the use of TF_ASSIGN_OR_RETURN in tensorflow/compiler/tf2xla/lib/triangular_solve.cc) and prevents such functions from being chained in the way that native XLA ops are. Instead, we can publicize the builder-based method for reporting failures and allow user-defined library functions to look and feel more like "native" XLA ops, without needing two different mechanisms for error reporting. Fix a few of the arithmetic examples to show how this leads to more readable code. PiperOrigin-RevId: 202031363
Loading
Please sign in to comment