Commit 19a1dd52 authored by Justin Lebar's avatar Justin Lebar Committed by TensorFlower Gardener
Browse files

[XLA] Make pattern_matchers work with gMock.

This lets us unify the HLO pattern matchers and the HLO gmock matchers (in a later patch).

Unifying these two APIs is useful because then we don't have to learn two APIs,
and we don't have to implement features twice.

This change:

 - Adds and tests the DescribeTo and MatchAndExplain APIs (this is the major change)

 - Uses these new gmock matchers in a few tests as a proof of concept.

 - Rewrites the is-constant-scalar API to use a true matcher rather than a std::function predicate matcher.  This is necessary to get a user-friendly DescribeTo message rather than "I don't know what this std::function does."

 - Adds EffectiveScalarConstant helpers along with the old ScalarConstant helpers and then uses these within while_loop_simplifier.

 - Adds some missing simple op matchers: Tuple, Convolution, Pad, etc.

 - Adds a Parameter(n) matcher.

 - Adds Op().Is(), which matches a particular HloInstruction*, which is used in while_loop_simplifier.

 - Updates documentation to reflect new functions (both added here and added in earlier patches).

 - Tightens up the documentation.  It was getting pretty long, and I made it longer.

 - Changes implementation of FooAnyOrder so that it returns an Op rather than an AnyOf.  This lets you do AddAnyOrder(...).IsScalar(), whereas before this was a compile error.

 - Changes the implementation of FooAnyOrder so it uses a custom matcher rather than an AnyOf, in service of better DescribeTo messages.

 - Implements "and" folding, i.e.

     AllOf<AllOf<A, B...>, X, Y, ...> => AllOf<A, B, ..., X, Y, ...>

   in the service of better DescribeTo messages.

PiperOrigin-RevId: 223451504
parent af4417be
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment