2 * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "GenModelTest.h"
21 TEST_F(GenModelTest, OneOp_DetectionPostProcess_SingleBox)
25 int boxes = cgen.addTensor({{1, 1, 4}, circle::TensorType::TensorType_FLOAT32});
26 int scores = cgen.addTensor({{1, 1, 2}, circle::TensorType::TensorType_FLOAT32});
27 int anchors = cgen.addTensor({{1, 1, 4}, circle::TensorType::TensorType_FLOAT32});
29 int box_coors = cgen.addTensor({{1, 1, 4}, circle::TensorType::TensorType_FLOAT32});
30 int box_classes = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
31 int box_scores = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
32 int num_selected = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
34 cgen.addOperatorDetectionPostProcess(
35 {{boxes, scores, anchors}, {box_coors, box_classes, box_scores, num_selected}}, 1, 10, 10, 5, 5,
37 cgen.setInputsAndOutputs({boxes, scores, anchors},
38 {box_coors, box_classes, box_scores, num_selected});
40 _context = std::make_unique<GenModelTestContext>(cgen.finish());
41 _context->addTestCase(uniformTCD<float>({{0, 0, 0, 0}, {0, 0.9}, {0, 0, 1, 1}},
42 {{-0.5, -0.5, 0.5, 0.5}, {0}, {0.9}, {1}}));
43 _context->setBackends({"cpu"});
48 TEST_F(GenModelTest, neg_OneOp_DetectionPostProcess_SinglBox_MultiClasses)
52 int boxes = cgen.addTensor({{1, 1, 4}, circle::TensorType::TensorType_FLOAT32});
53 int scores = cgen.addTensor({{1, 1, 3}, circle::TensorType::TensorType_FLOAT32});
54 int anchors = cgen.addTensor({{1, 1, 4}, circle::TensorType::TensorType_FLOAT32});
56 int box_coors = cgen.addTensor({{1, 1, 4}, circle::TensorType::TensorType_FLOAT32});
57 int box_classes = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
58 int box_scores = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
59 int num_selected = cgen.addTensor({{1}, circle::TensorType::TensorType_FLOAT32});
61 cgen.addOperatorDetectionPostProcess(
62 {{boxes, scores, anchors}, {box_coors, box_classes, box_scores, num_selected}}, 2, 10, 10, 5, 5,
64 cgen.setInputsAndOutputs({boxes, scores, anchors},
65 {box_coors, box_classes, box_scores, num_selected});
67 _context = std::make_unique<GenModelTestContext>(cgen.finish());
68 _context->addTestCase(uniformTCD<float>({{0, 0, 0, 0}, {0, 0.7, 0.9}, {0, 0, 1, 1}},
69 {{-0.5, -0.5, 0.5, 0.5}, {1}, {0.9}, {1}}));
70 _context->setBackends({"cpu"});
71 _context->expectFailModelLoad();