Commit 84a7f40c authored by Peter Hawkins's avatar Peter Hawkins Committed by TensorFlower Gardener
Browse files

[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
parent 2912db37
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment