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

Function TEST_P

tensorflow/compiler/xla/service/hlo_dataflow_analysis_test.cc:101–142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99};
100
101TEST_P(HloDataflowAnalysisTest, BinaryOperation) {
102 // Test the dataflow for a simple binary operation (Add).
103 auto builder = HloComputation::Builder(TestName());
104 auto constant1 = builder.AddInstruction(
105 HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(1.0)));
106 auto constant2 = builder.AddInstruction(
107 HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(2.0)));
108 auto add = builder.AddInstruction(HloInstruction::CreateBinary(
109 scalar_shape_, HloOpcode::kAdd, constant1, constant2));
110 module_->AddEntryComputation(builder.Build());
111 SCOPED_TRACE(module_->ToString());
112
113 bool ssa_form = GetParam();
114 const HloDataflowAnalysis& analysis = RunAnalysis(ssa_form);
115
116 // Each instruction should define a single value.
117 EXPECT_EQ(analysis.values().size(), 3);
118 EXPECT_TRUE(analysis.ValueIsDefinedAt(constant1));
119 EXPECT_TRUE(analysis.ValueIsDefinedAt(constant2));
120 EXPECT_TRUE(analysis.ValueIsDefinedAt(add));
121
122 // Verify the positions of the values. These positions are all trivial because
123 // there are no instructions which forward values.
124 EXPECT_THAT(analysis.GetValueDefinedAt(constant1).positions(),
125 UnorderedElementsAre(HloPosition{constant1, {}}));
126 EXPECT_THAT(analysis.GetValueDefinedAt(constant2).positions(),
127 UnorderedElementsAre(HloPosition{constant2, {}}));
128 EXPECT_THAT(analysis.GetValueDefinedAt(add).positions(),
129 UnorderedElementsAre(HloPosition{add, {}}));
130
131 // Verify the uses of the values.
132 EXPECT_THAT(analysis.GetValueDefinedAt(constant1).uses(),
133 UnorderedElementsAre(HloUse{add, 0, {}}));
134 EXPECT_THAT(analysis.GetValueDefinedAt(constant2).uses(),
135 UnorderedElementsAre(HloUse{add, 1, {}}));
136 EXPECT_TRUE(analysis.GetValueDefinedAt(add).uses().empty());
137
138 // Verify liveout values from the module.
139 EXPECT_FALSE(analysis.GetValueDefinedAt(constant1).live_out_of_module());
140 EXPECT_FALSE(analysis.GetValueDefinedAt(constant2).live_out_of_module());
141 EXPECT_TRUE(analysis.GetValueDefinedAt(add).live_out_of_module());
142}
143
144TEST_P(HloDataflowAnalysisTest, TupleAndGtes) {
145 // Verify the dataflow through a Tuple and GetTupleElement instructions.

Callers

nothing calls this directly

Calls 15

TestNameFunction · 0.85
GetParamFunction · 0.85
MakeShapeFunction · 0.85
CreateTokenFunction · 0.85
AddEntryComputationMethod · 0.80
ValueIsDefinedAtMethod · 0.80
usesMethod · 0.80
live_out_of_moduleMethod · 0.80
is_phiMethod · 0.80
set_sequenceMethod · 0.80
entry_computationMethod · 0.80

Tested by

no test coverage detected