ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleGather.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
20
21#include <loco.h>
22#include <oops/UserExn.h>
23
24namespace luci
25{
26
28{
29 if (!GraphBuilder::validate(args, 2))
30 return false;
31
32 const auto &inputs = args.op.inputs;
33 const auto *options = args.op.builtin_options.AsGatherOptions();
34
35 int32_t axis = options->axis;
36
37 if (axis < 0)
38 axis += inputs.size();
39
40 if (axis < 0)
41 return false;
42
43 // TODO do indices type check
44 // TODO do axis check when shape information is given
45
46 return true;
47}
48
49CircleNode *CircleGatherGraphBuilder::build_node(const circle::OperatorT &op,
50 const std::vector<CircleNode *> &inputs,
51 loco::Graph *graph) const
52{
53 auto *node = graph->nodes()->create<CircleGather>();
54
55 node->params(inputs.at(0));
56 node->indices(inputs.at(1));
57
58 const auto *options = op.builtin_options.AsGatherOptions();
59 node->axis(options->axis);
60
61 return node;
62}
63
64} // namespace luci
A neural network graph.
Definition Graph.h:161
bool validate(const ValidateArgs &args) const final
GATHER in Circle.
loco::Node * params(void) const
bool validate(const ValidateArgs &args, size_t input_cnt) const