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

Function TEST_F

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

Test that A + 0 is simplified to A

Source from the content-addressed store, hash-verified

56
57// Test that A + 0 is simplified to A
58TEST_F(AlgebraicSimplifierTest, AddZero) {
59 auto m = CreateNewVerifiedModule();
60 Shape r0f32 = ShapeUtil::MakeShape(F32, {});
61 HloComputation::Builder builder(TestName());
62 HloInstruction* param0 = builder.AddInstruction(
63 HloInstruction::CreateParameter(0, r0f32, "param0"));
64 HloInstruction* zero = builder.AddInstruction(
65 HloInstruction::CreateConstant(LiteralUtil::CreateR0<float>(0.0f)));
66 builder.AddInstruction(
67 HloInstruction::CreateBinary(r0f32, HloOpcode::kAdd, param0, zero));
68
69 auto computation = m->AddEntryComputation(builder.Build());
70 HloInstruction* root = computation->root_instruction();
71 EXPECT_EQ(root->opcode(), HloOpcode::kAdd);
72 AlgebraicSimplifier simplifier(default_options_);
73 ASSERT_TRUE(simplifier.Run(m.get()).ValueOrDie());
74 root = computation->root_instruction();
75 EXPECT_EQ(root, param0);
76}
77
78TEST_F(AlgebraicSimplifierTest, FactorIntegerAddition) {
79 const char* kModuleStr = R"(

Callers

nothing calls this directly

Calls 15

MakeShapeFunction · 0.85
TestNameFunction · 0.85
GmockMatchFunction · 0.85
AlgebraicSimplifierClass · 0.85
ConstantScalarFunction · 0.85
BroadcastFunction · 0.85
ShiftRightLogicalFunction · 0.85
NegateFunction · 0.85
DynamicSliceFunction · 0.85
PowerClass · 0.85
ReduceWindowFunction · 0.85
CreateReshapeFunction · 0.85

Tested by

no test coverage detected