MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST_F

Function TEST_F

tensorflow/compiler/xla/service/call_inliner_test.cc:45–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43using CallInlinerTest = HloTestBase;
44
45TEST_F(CallInlinerTest, ControlDependenciesAreCarriedToCaller) {
46 // "inner" computation just has a control dependency from the "zero" value to
47 // the "one" value.
48 HloComputation::Builder inner(TestName() + ".inner");
49 HloInstruction* zero = inner.AddInstruction(
50 HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(24.0f)));
51 HloInstruction* one = inner.AddInstruction(
52 HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(42.0f)));
53 TF_ASSERT_OK(zero->AddControlDependencyTo(one));
54 auto module = CreateNewVerifiedModule();
55 HloComputation* inner_computation =
56 module->AddEmbeddedComputation(inner.Build());
57
58 // "outer" computation just calls the "inner" computation.
59 HloComputation::Builder outer(TestName() + ".outer");
60 Shape r0f32 = ShapeUtil::MakeShape(F32, {});
61 outer.AddInstruction(
62 HloInstruction::CreateCall(r0f32, {}, inner_computation));
63
64 auto computation = module->AddEntryComputation(outer.Build());
65
66 CallInliner call_inliner;
67 TF_ASSERT_OK_AND_ASSIGN(bool mutated, call_inliner.Run(module.get()));
68 ASSERT_TRUE(mutated);
69 EXPECT_THAT(computation->root_instruction(), op::Constant());
70 EXPECT_EQ(computation->root_instruction()->literal().GetFirstElement<float>(),
71 42);
72 ASSERT_EQ(1, computation->root_instruction()->control_predecessors().size());
73 auto prior = computation->root_instruction()->control_predecessors()[0];
74 EXPECT_THAT(prior, op::Constant());
75 EXPECT_EQ(prior->literal().GetFirstElement<float>(), 24);
76}
77
78// Tests for referential transparency (a function that calls a function that
79// returns false should be identical to just returning false).

Callers

nothing calls this directly

Calls 15

TestNameFunction · 0.85
MakeShapeFunction · 0.85
InlineClass · 0.85
CreateTokenFunction · 0.85
AddEntryComputationMethod · 0.80
root_instructionMethod · 0.80
while_conditionMethod · 0.80
entry_computationMethod · 0.80
instructionsMethod · 0.80
ConstantFunction · 0.50

Tested by

no test coverage detected