ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleSplitV.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.AsSplitVOptions();
33
34 if (inputs.size() != 3)
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 *CircleSplitVGraphBuilder::build_node(const BuildNodeArgs &bna) const
62{
63 auto node = bna.context->graph()->nodes()->create<CircleSplitV>();
64
65 node->input(bna.input_nodes[0]);
66 node->size_splits(bna.input_nodes[1]);
67 node->split_dim(bna.input_nodes[2]);
68
69 const auto *options = bna.op.builtin_options.AsSplitVOptions();
70 node->num_split(options->num_splits);
71
72 assert(int32_t(bna.op.outputs.size()) == options->num_splits);
73
74 return node;
75}
76
77CircleNode *CircleSplitVGraphBuilder::build_out(const BuildOutArgs &boa) const
78{
79 auto *nodeout = boa.node->graph()->nodes()->create<CircleSplitVOut>();
80
81 nodeout->input(boa.node);
82 nodeout->index(boa.index);
83
84 return nodeout;
85}
86
87} // 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_V in Circle.
loco::Node * input(void) const