ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleNonMaxSuppressionV5.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
18
21
22#include <loco.h>
23#include <oops/UserExn.h>
24
25namespace luci
26{
27
29{
30 const auto &inputs = args.op.inputs;
31 const auto &outputs = args.op.outputs;
32
33 if (inputs.size() != 6)
34 return false;
35 if (outputs.size() != 3)
36 return false;
37
38 const auto tensors = args.reader.tensors();
39 const auto boxes_tensor = tensors.at(inputs[0]);
40 assert(boxes_tensor != nullptr);
41 const auto boxes_tensor_shape = wrap(boxes_tensor->shape());
42 if (boxes_tensor_shape.size() != 2)
43 return false;
44 if (boxes_tensor_shape.at(1) != 4)
45 return false;
46 assert(tensors.at(inputs[1]) != nullptr);
47 if (boxes_tensor_shape.at(0) != wrap(tensors.at(inputs[1])->shape()).at(0))
48 return false;
49
50 assert(tensors.at(inputs[2]) != nullptr);
51 if (tensors.at(inputs[2])->type() != circle::TensorType_INT32)
52 return false;
53 assert(tensors.at(inputs[3]) != nullptr);
54 if (tensors.at(inputs[3])->type() != circle::TensorType_FLOAT32)
55 return false;
56 assert(tensors.at(inputs[4]) != nullptr);
57 if (tensors.at(inputs[4])->type() != circle::TensorType_FLOAT32)
58 return false;
59 assert(tensors.at(inputs[5]) != nullptr);
60 if (tensors.at(inputs[5])->type() != circle::TensorType_FLOAT32)
61 return false;
62
63 return true;
64}
65
73CircleNode *CircleNonMaxSuppressionV5GraphBuilder::build_node(const BuildNodeArgs &bna) const
74{
75 auto node = bna.context->graph()->nodes()->create<CircleNonMaxSuppressionV5>();
76
77 node->boxes(bna.input_nodes[0]);
78 node->scores(bna.input_nodes[1]);
79 node->max_output_size(bna.input_nodes[2]);
80 node->iou_threshold(bna.input_nodes[3]);
81 node->score_threshold(bna.input_nodes[4]);
82 node->soft_nms_sigma(bna.input_nodes[5]);
83
84 return node;
85}
86
87CircleNode *CircleNonMaxSuppressionV5GraphBuilder::build_out(const BuildOutArgs &boa) const
88{
89 auto *nodeout = boa.node->graph()->nodes()->create<CircleNonMaxSuppressionV5Out>();
90
91 nodeout->input(boa.node);
92 nodeout->index(boa.index);
93
94 return nodeout;
95}
96
97} // namespace luci
NodeContext * nodes(void)
Definition Graph.h:218
Graph * graph(void)
Definition Node.h:70
Derived * create(Args &&...args)
Definition NodePool.h:37
bool validate(const ValidateArgs &args) const final
NON_MAX_SUPPRESSION_V5 in Circle.
VectorWrapper< T > wrap(const flatbuffers::Vector< T > *vec)