MCPcopy Create free account
hub / github.com/alibaba/MNN / fuseNode

Function fuseNode

codegen/OpFuse.cpp:272–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270 return legal;
271}
272std::vector<Node*> fuseNode(Node* root, std::vector<Node*>& edges, MNNForwardType type) {
273 std::vector<Node*> fuseSet;
274 std::queue<Node*> q;
275 q.push(root);
276 int rasterCount = 0;
277 bool insert = false;
278 while (!q.empty()) {
279 insert = false;
280 auto node = q.front();
281 if(node->cmd->op->type() == OpType_Raster) {
282 // Current only fuse single raster
283 rasterCount++;
284 if(rasterCount < 2) {
285 fuseSet.insert(fuseSet.begin(), node);
286 insert = true;
287 }
288 } else {
289 fuseSet.insert(fuseSet.begin(), node);
290 insert = true;
291 }
292
293 q.pop();
294 if(insert) {
295 for (auto child : node->domainateSucc) {
296 if (isLegal(child->cmd, type) && allPathLegal(child, root, type)) {
297 q.push(child);
298 } else {
299 edges.push_back(child);
300 }
301 }
302 }
303 }
304 return fuseSet;
305}
306
307bool codegen(std::vector<Schedule::OpCacheInfo>& infos, std::vector<std::vector<Node*>>& fuseSets, MNNForwardType type, BackendConfig::PrecisionMode precision) {
308 // generate Kernel

Callers 1

opFuseFunction · 0.85

Calls 10

isLegalFunction · 0.85
allPathLegalFunction · 0.85
pushMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45
typeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
popMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected