ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleTopKV2.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() != 2)
34 return false;
35 if (outputs.size() != 2)
36 return false;
37
38 const auto tensors = args.reader.tensors();
39 const auto tensor = tensors.at(inputs.at(1));
40 assert(tensor != nullptr);
41 if (tensor->type() != circle::TensorType_INT32)
42 return false;
43
44 return true;
45}
46
63CircleNode *CircleTopKV2GraphBuilder::build_node(const BuildNodeArgs &bna) const
64{
65 auto node = bna.context->graph()->nodes()->create<CircleTopKV2>();
66
67 node->input(bna.input_nodes[0]);
68 node->k(bna.input_nodes[1]);
69
70 return node;
71}
72
73CircleNode *CircleTopKV2GraphBuilder::build_out(const BuildOutArgs &boa) const
74{
75 auto *nodeout = boa.node->graph()->nodes()->create<CircleTopKV2Out>();
76
77 nodeout->input(boa.node);
78 nodeout->index(boa.index);
79
80 return nodeout;
81}
82
83} // 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
TOPK_V2 in Circle.
loco::Node * input(void) const