-
Notifications
You must be signed in to change notification settings - Fork 23
/
node.h
97 lines (71 loc) · 2.25 KB
/
node.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pragma once
#include <iosfwd>
#include <string>
#include <vector>
#include <compiler/onnx.h>
#include <compiler/gen_node_base.h>
namespace chainer_compiler {
class Value;
class Node : public NodeBase {
public:
Node(const OpsetList& opset,
const onnx::NodeProto& xnode,
const std::vector<Value*>& inputs,
const std::vector<Value*>& outputs,
const std::string& name = "");
Node(const std::string& name,
OpType op_type,
const std::vector<Value*>& inputs,
const std::vector<Value*>& outputs,
const std::string& domain,
const OpsetList& opsets);
~Node();
Node(const Node&) = delete;
Node& operator=(const Node&) = delete;
void ToONNX(onnx::NodeProto* xnode, const OpsetList& opsets, bool validate = true) const;
std::string DebugString() const;
void Validate() const;
Value* input(int index) const;
const std::vector<Value*>& inputs() const {
return inputs_;
}
void AddInput(Value* value);
Value* output(int index) const;
const std::vector<Value*>& outputs() const {
return outputs_;
}
void AddOutput(Value* value, size_t index = static_cast<size_t>(-1));
const std::string& name() const {
return name_;
}
const std::string& domain() const {
return domain_;
}
const std::string& doc_string() const {
return doc_string_;
}
bool detached() const {
return detached_;
}
void Detach();
// Returns the number of input values whose type is not `kNull`.
int GetNumActualInputs() const;
void ReplaceInput(Value* f, Value* t);
void ReplaceOutput(Value* f, Value* t);
std::vector<Graph*> GetSubGraphs() const;
bool IsGradNode() const;
bool IsZeroCost() const;
std::string ToString() const;
OpsetList OpsetImports() const;
int OpVersion() const;
bool ValidateWithSchema(const OpsetList& opsets = {}, std::string* message = nullptr) const;
private:
std::vector<Value*> inputs_;
std::vector<Value*> outputs_;
std::string name_;
std::string domain_;
std::string doc_string_;
bool detached_ = false;
};
std::ostream& operator<<(std::ostream& os, Node::OpType op_type);
} // namespace chainer_compiler