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

Function TEST_F

tensorflow/core/graph/quantize_training_test.cc:76–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74};
75
76TEST_F(QuantizeTrainingTest, SignedInput) {
77 // Test that Quantization ops are created with the correct signed_input value.
78 // Construct the following graph
79 /*
80 m1
81 / \
82 Relu Identity
83 | |
84 a b
85 */
86 Reset();
87 Graph* g = g_.get();
88 Node* a = Constant<float>({1.0, 2.0, 3.0, 4.0}, {2, 2});
89 Node* b = Constant<float>({1.0, 2.0, 3.0, 4.0}, {2, 2});
90 g->AddControlEdge(g->source_node(), a);
91 g->AddControlEdge(g->source_node(), b);
92 Node* relu = test::graph::Relu(g, a);
93 Node* identity = test::graph::Identity(g, b);
94 Node* m1 = test::graph::Matmul(g, relu, identity, false, false);
95 g->AddControlEdge(m1, g->sink_node());
96
97 /*
98 m1
99 / \
100 EMA_Q EMA_Q <- these are subgraphs that estimate moving average.
101 | |
102 Relu Identity
103 | |
104 a b
105 */
106 const int num_bits = 8;
107 TF_ASSERT_OK(DoQuantizeTraining(num_bits, "QuantizeAndDequantizeV2", g));
108
109 EXPECT_EQ(63, g->num_nodes());
110
111 // Quantize_and_dequantize node for identity should have signed_input==true.
112 Node* identity_q_node;
113 TF_ASSERT_OK(
114 FindNode(g, strings::StrCat(identity->name(), "/QuantizeAndDequantizeV2"),
115 &identity_q_node));
116 ASSERT_EQ("true",
117 SummarizeAttrValue(*identity_q_node->attrs().Find("signed_input")));
118 // Quantize_and_dequantize node for relu should have signed_input==false.
119 Node* relu_q_node;
120 TF_ASSERT_OK(
121 FindNode(g, strings::StrCat(relu->name(), "/QuantizeAndDequantizeV2"),
122 &relu_q_node));
123 ASSERT_EQ("false",
124 SummarizeAttrValue(*relu_q_node->attrs().Find("signed_input")));
125}
126
127TEST_F(QuantizeTrainingTest, RangeGivenTrue) {
128 // Test that Quantization ops are created with the correct range_given value.

Callers

nothing calls this directly

Calls 15

DoQuantizeTrainingFunction · 0.85
SummarizeAttrValueFunction · 0.85
ParseProtoUnlimitedFunction · 0.85
ConvertGraphDefToGraphFunction · 0.85
ReluFunction · 0.70
IdentityFunction · 0.70
MatmulFunction · 0.70
Relu6Function · 0.70
NodeBuilderClass · 0.70
nameMethod · 0.65

Tested by

no test coverage detected