ONE - On-device Neural Engine
Loading...
Searching...
No Matches
CircleNodeDecl.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_CIRCLENODEDECL_H__
18#define __LUCI_IR_CIRCLENODEDECL_H__
19
20#include <loco/IR/Dialect.h>
21#include <loco/IR/Node.h>
22#include <loco/IR/NodeMixins.h>
24
25#include "CircleOpcode.h"
27#include "CircleQuantParam.h"
28#include "SparsityParam.h"
29
30#include <memory>
31
32namespace luci
33{
34
35using NodeName = std::string;
36
37struct CircleNode : public loco::Node,
38 public loco::NodeMixin<loco::NodeTrait::DataType>,
39 public loco::NodeMixin<loco::NodeTrait::TensorShape>
40{
41 virtual ~CircleNode() = default;
42
43 const loco::Dialect *dialect(void) const final;
44 virtual CircleOpcode opcode(void) const = 0;
45
46 template <typename T> T accept(CircleNodeVisitorBase<T> *) const;
47 template <typename T> T accept(CircleNodeMutableVisitorBase<T> *);
48
49 NodeName name(void) const { return _name; }
50 void name(const NodeName &name) { _name = name; }
51
52 CircleQuantParam *quantparam(void) const { return _quantparam.get(); }
53 void quantparam(std::unique_ptr<CircleQuantParam> &&quantparam)
54 {
55 _quantparam = std::move(quantparam);
56 }
57
58 SparsityParam *sparsityparam(void) const { return _sparsityparam.get(); }
59 void sparsityparam(std::unique_ptr<SparsityParam> &&sparsityparam)
60 {
61 _sparsityparam = std::move(sparsityparam);
62 }
63
64 ShapeStatus shape_status(void) const { return _shape_status; }
65 void shape_status(ShapeStatus ss) { _shape_status = ss; }
66
67 int32_t op_version(void) const { return _op_version; }
68 void op_version(int32_t op_version) { _op_version = op_version; }
69
70private:
71 NodeName _name;
72 std::unique_ptr<CircleQuantParam> _quantparam;
73 std::unique_ptr<SparsityParam> _sparsityparam;
75 int32_t _op_version = 1;
76};
77
78template <CircleOpcode Code> struct CircleNodeImpl : public CircleNode
79{
80 virtual ~CircleNodeImpl() = default;
81
82 uint32_t opnum(void) const final { return static_cast<uint32_t>(Code); }
83 CircleOpcode opcode(void) const final { return Code; }
84};
85
86} // namespace luci
87
88#endif // __LUCI_IR_CIRCLENODEDECL_H__
Dialect interface.
Definition Dialect.h:37
Logical unit of computation.
Definition Node.h:54
std::string NodeName
ShapeStatus
ShapeStatus is to remember circle node shape status.
CircleQuantParam * quantparam(void) const
void quantparam(std::unique_ptr< CircleQuantParam > &&quantparam)
void shape_status(ShapeStatus ss)
SparsityParam * sparsityparam(void) const
virtual ~CircleNode()=default
int32_t op_version(void) const
NodeName name(void) const
void name(const NodeName &name)
virtual CircleOpcode opcode(void) const =0
void sparsityparam(std::unique_ptr< SparsityParam > &&sparsityparam)
ShapeStatus shape_status(void) const
T accept(CircleNodeVisitorBase< T > *) const
void op_version(int32_t op_version)
const loco::Dialect * dialect(void) const final
Return "Dialect" identifier that this node belongs to.
CircleOpcode opcode(void) const final
uint32_t opnum(void) const final
virtual ~CircleNodeImpl()=default