ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleIf.h
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
17#ifndef __LUCI_IR_CIRCLE_IF_H__
18#define __LUCI_IR_CIRCLE_IF_H__
19
22
24
25#include <cassert>
26
27namespace luci
28{
29
33class CircleIf final : public VariadicArityNode<CircleNodeImpl<CircleOpcode::IF>>
34{
35public:
36 CircleIf(uint32_t arity, uint32_t out)
37 : VariadicArityNode<CircleNodeImpl<CircleOpcode::IF>>(arity + 1), _output_count(out)
38 {
39 assert(arity > 0);
40 assert(out > 0);
41 }
42
43public:
44 uint32_t input_count(void) const { return arity() - 1; }
45 uint32_t output_count(void) const { return _output_count; }
46
47public:
48 Node *cond(void) const { return at(0)->node(); }
49 void cond(Node *node) { at(0)->node(node); }
50
51 Node *input(uint32_t index) const { return at(index + 1)->node(); }
52 void input(uint32_t index, Node *node) { at(index + 1)->node(node); }
53
54public:
55 int32_t then_branch(void) const { return _then_branch; }
56 void then_branch(int32_t then_branch) { _then_branch = then_branch; }
57
58 int32_t else_branch(void) const { return _else_branch; }
59 void else_branch(int32_t else_branch) { _else_branch = else_branch; }
60
61public:
62 loco::Graph *then_graph(void) const { return _then_graph; }
63 void then_graph(loco::Graph *then_graph) { _then_graph = then_graph; }
64
65 loco::Graph *else_graph(void) const { return _else_graph; }
66 void else_graph(loco::Graph *else_graph) { _else_graph = else_graph; }
67
68private:
69 uint32_t _output_count{0};
70 int32_t _then_branch{-1};
71 int32_t _else_branch{-1};
72
73 loco::Graph *_then_graph{nullptr};
74 loco::Graph *_else_graph{nullptr};
75};
76
77} // namespace luci
78
79#endif // __LUCI_IR_CIRCLE_IF_H__
A neural network graph.
Definition Graph.h:161
Node()=default
Node * node(void) const
Definition Use.h:58
IF in Circle.
Definition CircleIf.h:34
uint32_t output_count(void) const
Definition CircleIf.h:45
Node * input(uint32_t index) const
Definition CircleIf.h:51
void else_branch(int32_t else_branch)
Definition CircleIf.h:59
int32_t else_branch(void) const
Definition CircleIf.h:58
uint32_t input_count(void) const
Definition CircleIf.h:44
loco::Graph * then_graph(void) const
Definition CircleIf.h:62
void else_graph(loco::Graph *else_graph)
Definition CircleIf.h:66
CircleIf(uint32_t arity, uint32_t out)
Definition CircleIf.h:36
void then_branch(int32_t then_branch)
Definition CircleIf.h:56
loco::Graph * else_graph(void) const
Definition CircleIf.h:65
int32_t then_branch(void) const
Definition CircleIf.h:55
void cond(Node *node)
Definition CircleIf.h:49
Node * cond(void) const
Definition CircleIf.h:48
void then_graph(loco::Graph *then_graph)
Definition CircleIf.h:63
void input(uint32_t index, Node *node)
Definition CircleIf.h:52
Nodes with the variadic inputs.
uint32_t arity(void) const final
Return the number of arguments.