| 37 | class ReplayTest : public ClientLibraryTestBase {}; |
| 38 | |
| 39 | TEST_F(ReplayTest, TwoPlusTwoReplay) { |
| 40 | // Make 2+2 computation. |
| 41 | XlaBuilder builder(TestName()); |
| 42 | auto two = ConstantR0<int32>(&builder, 2); |
| 43 | Add(two, two); |
| 44 | XlaComputation computation = builder.Build().ConsumeValueOrDie(); |
| 45 | |
| 46 | // Serialize it out. |
| 47 | std::unique_ptr<HloSnapshot> module = |
| 48 | computation.Snapshot().ConsumeValueOrDie(); |
| 49 | |
| 50 | // Replay it. |
| 51 | XlaComputation replayed = client_->LoadSnapshot(*module).ConsumeValueOrDie(); |
| 52 | |
| 53 | // Check signature is the same. |
| 54 | std::unique_ptr<ProgramShape> original_shape = |
| 55 | client_->GetComputationShape(computation).ConsumeValueOrDie(); |
| 56 | std::unique_ptr<ProgramShape> replayed_shape = |
| 57 | client_->GetComputationShape(replayed).ConsumeValueOrDie(); |
| 58 | ASSERT_TRUE(protobuf_util::ProtobufEquals(original_shape->ToProto(), |
| 59 | replayed_shape->ToProto())); |
| 60 | |
| 61 | // Run it. |
| 62 | Literal literal = |
| 63 | client_ |
| 64 | ->ExecuteAndTransfer(replayed, /*arguments=*/{}, &execution_options_) |
| 65 | .ConsumeValueOrDie(); |
| 66 | |
| 67 | // Expect 4. |
| 68 | LiteralTestUtil::ExpectR0Equal<int32>(4, literal); |
| 69 | } |
| 70 | |
| 71 | XLA_TEST_F(ReplayTest, XPlusYReplayWithParameters) { |
| 72 | // Make computation. |
nothing calls this directly
no test coverage detected