MCPcopy Create free account
hub / github.com/OAID/Tengine / CreateNodeFromStatic

Method CreateNodeFromStatic

core/lib/graph.cpp:129–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129bool Graph::CreateNodeFromStatic(Node* node, const StaticGraph* static_graph, const StaticNode* static_node)
130{
131 StaticOp* static_op = static_node->op.get();
132
133 Operator* op = OpManager::CreateOp(static_op->name);
134 if(op == nullptr)
135 {
136 XLOG_ERROR() << "failed to create operator: " << static_op->name << "\n";
137 return false;
138 }
139
140 op->ParamFromStaticOp(static_op);
141 op->SetDynamicShape(static_op->dynamic_shape);
142 node->SetDynamicShape(static_op->dynamic_shape);
143
144 /* copy attrs in static_node */
145 std::vector<std::string> node_attr_name = static_node->attrs.ListAttr();
146
147 for(unsigned int i = 0; i < node_attr_name.size(); i++)
148 {
149 node->SetAttr(node_attr_name[i], static_node->attrs.GetAttr(node_attr_name[i]));
150 }
151
152 /* copy attrs in static_op */
153 std::vector<std::string> attr_name = static_op->attrs.ListAttr();
154
155 for(unsigned int i = 0; i < attr_name.size(); i++)
156 {
157 op->SetAttr(attr_name[i], static_op->attrs[attr_name[i]]);
158 }
159
160 node->SetOp(op);
161
162 /* create output tensors */
163
164 for(unsigned int i = 0; i < static_node->output_tensor_list.size(); i++)
165 {
166 int idx = static_node->output_tensor_list[i];
167 StaticTensor* static_tensor = static_graph->tensor_list[idx].get();
168
169 Tensor* tensor = new Tensor(static_tensor->name);
170
171 tensor->SetDataType(static_tensor->data_type);
172 tensor->SetType(( TensorType )static_tensor->type);
173
174 TShape& shape = tensor->GetShape();
175
176 shape.SetDataLayout(static_graph->graph_layout);
177 shape.SetDim(static_tensor->dims);
178
179 std::vector<QuantParam>* quant_param = tensor->GetQuantParam();
180 quant_param->resize(1);
181
182 // (*quant_param)[0].scale = static_tensor->scale;
183 // (*quant_param)[0].zero_point = static_tensor->zero_point;
184 // (*quant_param)[0].width = static_tensor->width;
185 int scale_num = ( int )static_tensor->scale.size();
186 quant_param->resize(scale_num);

Callers

nothing calls this directly

Calls 15

getMethod · 0.80
SetOpMethod · 0.80
SetDataTypeMethod · 0.80
SetTypeMethod · 0.80
SetDataLayoutMethod · 0.80
SetDimMethod · 0.80
GetQuantParamMethod · 0.80
BindStaticTensorMethod · 0.80
GetNameMethod · 0.80
SetOutputPortMethod · 0.80
GetOutputPortMethod · 0.80
SetNodeIndexMethod · 0.80

Tested by

no test coverage detected