ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Util.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 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 NNCC_UTIL_H
18#define NNCC_UTIL_H
19
20#include "mir/ops/AddOp.h"
21#include "mir/ops/AvgPool2DOp.h"
22#include "mir/ops/ConcatOp.h"
23#include "mir/ops/ConstantOp.h"
24#include "mir/ops/Conv2DOp.h"
25#include "mir/ops/MaxPool2DOp.h"
26#include "mir/ops/MulOp.h"
27#include "mir/ops/OutputOp.h"
28#include "mir/ops/ReluOp.h"
29#include "mir/ops/TanhOp.h"
30#include "mir/ops/TransposeOp.h"
31#include "mir/Visitor.h"
32
33namespace nnc
34{
35
37{
38public:
39 explicit DumpVisitor(std::ostream &s) : _s(s) {}
40
41 void visit(mir::ops::InputOp &op) override { _s << "i_" << std::to_string(op.getId()) << "."; };
42
43 void visit(mir::ops::TanhOp &op) override { _s << "th_" << std::to_string(op.getId()) << "."; }
44
45 void visit(mir::ops::MulOp &op) override { _s << "s_" << std::to_string(op.getId()) << "."; }
46
47 void visit(mir::ops::AddOp &op) override { _s << "b_" << std::to_string(op.getId()) << "."; }
48
49 void visit(mir::ops::ReluOp &op) override { _s << "r_" << std::to_string(op.getId()) << "."; }
50
51 void visit(mir::ops::AvgPool2DOp &op) override
52 {
53 _s << "p_" << std::to_string(op.getId()) << ".";
54 }
55
56 void visit(mir::ops::MaxPool2DOp &op) override
57 {
58 _s << "p_" << std::to_string(op.getId()) << ".";
59 }
60
61 void visit(mir::ops::TransposeOp &op) override
62 {
63 _s << "t_" << std::to_string(op.getId()) << ".";
64 }
65
66 void visit(mir::ops::Conv2DOp &op) override
67 {
68 _s << "conv_" << std::to_string(op.getId()) << ".";
69 }
70
71 void visit(mir::ops::ConstantOp &op) override
72 {
73 _s << "const_" << std::to_string(op.getId()) << ".";
74 }
75
76 std::ostream &_s;
77};
78
79} // namespace nnc
80#endif // NNCC_UTIL_H
std::size_t getId() const
Definition Operation.h:125
Base visitor with empty fallback function.
Definition Visitor.h:51
Tensor transpose operation.
Definition TransposeOp.h:34
void visit(mir::ops::MaxPool2DOp &op) override
Definition Util.h:56
void visit(mir::ops::ReluOp &op) override
Definition Util.h:49
void visit(mir::ops::AvgPool2DOp &op) override
Definition Util.h:51
void visit(mir::ops::AddOp &op) override
Definition Util.h:47
void visit(mir::ops::MulOp &op) override
Definition Util.h:45
void visit(mir::ops::TransposeOp &op) override
Definition Util.h:61
void visit(mir::ops::TanhOp &op) override
Definition Util.h:43
void visit(mir::ops::InputOp &op) override
Definition Util.h:41
void visit(mir::ops::Conv2DOp &op) override
Definition Util.h:66
DumpVisitor(std::ostream &s)
Definition Util.h:39
std::ostream & _s
Definition Util.h:76
void visit(mir::ops::ConstantOp &op) override
Definition Util.h:71