ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleSplit.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 const auto *options = args.op.builtin_options.AsSplitOptions();
33
34 if (inputs.size() != 2)
35 return false;
36
37 if (static_cast<int32_t>(outputs.size()) != options->num_splits)
38 return false;
39
40 // TODO check types
41
42 return true;
43}
44
61CircleNode *CircleSplitGraphBuilder::build_node(const BuildNodeArgs &bna) const
62{
63 auto node = bna.context->graph()->nodes()->create<CircleSplit>();
64
65 node->split_dim(bna.input_nodes[0]);
66 node->input(bna.input_nodes[1]);
67
68 const auto *options = bna.op.builtin_options.AsSplitOptions();
69 node->num_split(options->num_splits);
70
71 return node;
72}
73
74CircleNode *CircleSplitGraphBuilder::build_out(const BuildOutArgs &boa) const
75{
76 auto *nodeout = boa.node->graph()->nodes()->create<CircleSplitOut>();
77
78 nodeout->input(boa.node);
79 nodeout->index(boa.index);
80
81 return nodeout;
82}
83
84} // 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
SPLIT in Circle.
Definition CircleSplit.h:32
loco::Node * split_dim(void) const
Definition CircleSplit.h:34