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

Function TEST

tensorflow/lite/kernels/detection_postprocess_test.cc:127–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125};
126
127TEST(DetectionPostprocessOpTest, FloatTest) {
128 BaseDetectionPostprocessOpModel m(
129 {TensorType_FLOAT32, {1, 6, 4}}, {TensorType_FLOAT32, {1, 6, 3}},
130 {TensorType_FLOAT32, {6, 4}}, {TensorType_FLOAT32, {}},
131 {TensorType_FLOAT32, {}}, {TensorType_FLOAT32, {}},
132 {TensorType_FLOAT32, {}});
133
134 // six boxes in center-size encoding
135 m.SetInput1<float>({
136 0.0, 0.0, 0.0, 0.0, // box #1
137 0.0, 1.0, 0.0, 0.0, // box #2
138 0.0, -1.0, 0.0, 0.0, // box #3
139 0.0, 0.0, 0.0, 0.0, // box #4
140 0.0, 1.0, 0.0, 0.0, // box #5
141 0.0, 0.0, 0.0, 0.0 // box #6
142 });
143 // class scores - two classes with background
144 m.SetInput2<float>({0., .9, .8, 0., .75, .72, 0., .6, .5, 0., .93, .95, 0.,
145 .5, .4, 0., .3, .2});
146 // six anchors in center-size encoding
147 m.SetInput3<float>({
148 0.5, 0.5, 1.0, 1.0, // anchor #1
149 0.5, 0.5, 1.0, 1.0, // anchor #2
150 0.5, 0.5, 1.0, 1.0, // anchor #3
151 0.5, 10.5, 1.0, 1.0, // anchor #4
152 0.5, 10.5, 1.0, 1.0, // anchor #5
153 0.5, 100.5, 1.0, 1.0 // anchor #6
154 });
155 // Same boxes in box-corner encoding:
156 // { 0.0, 0.0, 1.0, 1.0,
157 // 0.0, 0.1, 1.0, 1.1,
158 // 0.0, -0.1, 1.0, 0.9,
159 // 0.0, 10.0, 1.0, 11.0,
160 // 0.0, 10.1, 1.0, 11.1,
161 // 0.0, 100.0, 1.0, 101.0}
162 m.Invoke();
163 // detection_boxes
164 // in center-size
165 std::vector<int> output_shape1 = m.GetOutputShape1();
166 EXPECT_THAT(output_shape1, ElementsAre(1, 3, 4));
167 EXPECT_THAT(
168 m.GetOutput1<float>(),
169 ElementsAreArray(ArrayFloatNear(
170 {0.0, 10.0, 1.0, 11.0, 0.0, 0.0, 1.0, 1.0, 0.0, 100.0, 1.0, 101.0},
171 1e-1)));
172 // detection_classes
173 std::vector<int> output_shape2 = m.GetOutputShape2();
174 EXPECT_THAT(output_shape2, ElementsAre(1, 3));
175 EXPECT_THAT(m.GetOutput2<float>(),
176 ElementsAreArray(ArrayFloatNear({1, 0, 0}, 1e-1)));
177 // detection_scores
178 std::vector<int> output_shape3 = m.GetOutputShape3();
179 EXPECT_THAT(output_shape3, ElementsAre(1, 3));
180 EXPECT_THAT(m.GetOutput3<float>(),
181 ElementsAreArray(ArrayFloatNear({0.95, 0.9, 0.3}, 1e-1)));
182 // num_detections
183 std::vector<int> output_shape4 = m.GetOutputShape4();
184 EXPECT_THAT(output_shape4, ElementsAre(1));

Callers

nothing calls this directly

Calls 9

ArrayFloatNearFunction · 0.70
InvokeMethod · 0.45
GetOutputShape1Method · 0.45
GetOutputShape2Method · 0.45
GetOutputShape3Method · 0.45
GetOutputShape4Method · 0.45
input1Method · 0.45
input2Method · 0.45
input3Method · 0.45

Tested by

no test coverage detected