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