ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Module.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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#include "nest/Module.h"
18
19#include <cassert>
20
21namespace nest
22{
23
24void Module::push(const Expr &expr)
25{
26 auto stmt = std::make_shared<stmt::PushNode>(expr);
27 _block.append(stmt);
28}
29
30void Module::ret(const Closure &clo)
31{
32 // Only one RET is allowed for each module
33 assert(_ret == nullptr);
34 _ret = std::make_shared<Ret>(clo.id(), clo.sub());
35}
36
37const Ret &Module::ret(void) const
38{
39 // Caller should NOT invoke this method before setting ret
40 assert(_ret != nullptr);
41 return *_ret;
42}
43
44} // namespace nest
const expr::Subscript & sub(void) const
Definition Closure.h:40
const DomainID & id(void) const
Definition Closure.h:39
void push(const Expr &expr)
Definition Module.cpp:24
const Ret & ret(void) const
Definition Module.cpp:37
Definition Block.h:27
std::shared_ptr< nest::expr::Node > Expr
Definition Expr.h:37
void append(const Stmt &stmt)
Definition Block.h:38