ONE - On-device Neural Engine
Loading...
Searching...
No Matches
COpCall.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 __LOCOEX_COPCALL_H__
18#define __LOCOEX_COPCALL_H__
19
20#include "VariadicArityNode.h"
21#include "locoex/COpAttrTypes.h"
22#include "locoex/COpNode.h"
23
24#include <loco/IR/NodeMixins.h>
25
26#include <map>
27#include <memory>
28
29namespace locoex
30{
31
35class COpCall final : public VariadicArityNode<COpNode>,
36 public loco::NodeMixin<loco::NodeTrait::TensorShape>,
37 public loco::NodeMixin<loco::NodeTrait::DataType>
38{
39public:
41
42public:
43 void op(const std::string &op) { _op.assign(op); }
44 const std::string &op() { return _op; }
45
46 void name(const std::string &name) { _name.assign(name); }
47 const std::string &name() { return _name; }
48
49 void input(uint32_t nth, loco::Node *node) { at(nth)->node(node); }
50 loco::Node *input(uint32_t nth) const { return at(nth)->node(); }
51
53 void attr(const std::string &attr_name, std::unique_ptr<COpAttrData> &&attr_data);
54
56 template <COpAttrType AT>
57 const typename AttrTypeTrait<AT>::Type *attr(const std::string &attr_name) const;
58
60 std::vector<std::string> attr_names() const;
61
62private:
63 std::string _op;
64 std::string _name;
65
66 std::map<std::string, std::unique_ptr<COpAttrData>> _attrs;
67};
68
69} // namespace locoex
70
71#endif // __LOCOEX_COPCALL_H__
Logical unit of computation.
Definition Node.h:54
Node * node(void) const
Definition Use.h:58
Class to calls custom operation.
Definition COpCall.h:38
const std::string & name()
Definition COpCall.h:47
loco::Node * input(uint32_t nth) const
Definition COpCall.h:50
std::vector< std::string > attr_names() const
get all the names of attr
Definition COpCall.cpp:46
void op(const std::string &op)
Definition COpCall.h:43
void name(const std::string &name)
Definition COpCall.h:46
COpCall(unsigned arity)
Definition COpCall.h:40
void input(uint32_t nth, loco::Node *node)
Definition COpCall.h:49
const std::string & op()
Definition COpCall.h:44
void attr(const std::string &attr_name, std::unique_ptr< COpAttrData > &&attr_data)
Store [attr_name, attr_data].
Definition COpCall.cpp:38
Nodes with the variadic inputs.
uint32_t arity(void) const final
Return the number of arguments.
loco::Use * at(uint32_t n) const