dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
NodeOpType.cpp
1
6#include "dlinear/parser/onnx/NodeOpType.h"
7
8#include <map>
9#include <string>
10
11#include "dlinear/util/exception.h"
12
13namespace dlinear::onnx {
14
15const std::map<std::string, NodeOpType> string_to_node_op_type{
16 {"Abs", NodeOpType::Abs},
17 {"Add", NodeOpType::Add},
18 {"AveragePool", NodeOpType::AveragePool},
19 {"BatchNormalization", NodeOpType::BatchNormalization},
20 {"Concat", NodeOpType::Concat},
21 {"Constant", NodeOpType::Constant},
22 {"Conv", NodeOpType::Conv},
23 {"Dropout", NodeOpType::Dropout},
24 {"Flatten", NodeOpType::Flatten},
25 {"Gather", NodeOpType::Gather},
26 {"Gemm", NodeOpType::Gemm},
27 {"GlobalAveragePool", NodeOpType::GlobalAveragePool},
28 {"Identity", NodeOpType::Identity},
29 {"LeakyRelu", NodeOpType::LeakyRelu},
30 {"LRN", NodeOpType::LRN},
31 {"MatMul", NodeOpType::MatMul},
32 {"MaxPool", NodeOpType::MaxPool},
33 {"Mul", NodeOpType::Mul},
34 {"Relu", NodeOpType::Relu},
35 {"Reshape", NodeOpType::Reshape},
36 {"Slice", NodeOpType::Slice},
37 {"Sigmoid", NodeOpType::Sigmoid},
38 {"Sign", NodeOpType::Sign},
39 {"Softmax", NodeOpType::Softmax},
40 {"Squeeze", NodeOpType::Squeeze},
41 {"Sub", NodeOpType::Sub},
42 {"Transpose", NodeOpType::Transpose},
43 {"Unsqueeze", NodeOpType::Unsqueeze},
44};
45
46std::ostream& operator<<(std::ostream& os, const NodeOpType& op_type) {
47 switch (op_type) {
48 case NodeOpType::Abs:
49 return os << "Abs";
50 case NodeOpType::Add:
51 return os << "Add";
53 return os << "AveragePool";
55 return os << "BatchNormalization";
57 return os << "Concat";
59 return os << "Constant";
61 return os << "Conv";
63 return os << "Dropout";
65 return os << "Flatten";
67 return os << "Gather";
69 return os << "Gemm";
71 return os << "GlobalAveragePool";
73 return os << "Identity";
75 return os << "LeakyRelu";
76 case NodeOpType::LRN:
77 return os << "LRN";
79 return os << "MatMul";
81 return os << "MaxPool";
82 case NodeOpType::Mul:
83 return os << "Mul";
85 return os << "Relu";
87 return os << "Reshape";
89 return os << "Slice";
91 return os << "Sign";
93 return os << "Sigmoid";
95 return os << "Softmax";
97 return os << "Squeeze";
98 case NodeOpType::Sub:
99 return os << "Sub";
101 return os << "Transpose";
103 return os << "Unsqueeze";
104 default:
105 DLINEAR_UNREACHABLE();
106 }
107}
108
109NodeOpType parseNodeOpType(const std::string& op_type) { return string_to_node_op_type.at(op_type); }
110
111} // namespace dlinear::onnx
Namespace for the ONNX parser of the dlinear library.
Definition Driver.cpp:20
NodeOpType
Type of node operation.
Definition NodeOpType.h:15
@ Abs
Absolute value.
@ MatMul
Matrix multiplication.
@ Mul
Multiplication.
@ Gemm
General matrix multiplication.
@ GlobalAveragePool
Global average pooling.
@ Concat
Concatenation.
@ BatchNormalization
Batch normalization.
@ AveragePool
Average pooling.
@ LRN
Local response normalization.
NodeOpType parseNodeOpType(const std::string &op_type)
Parse a string to a node operation type.