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

Method getExecuteOrder

express/Expr.cpp:1350–1399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1348}
1349
1350std::vector<EXPRP> Variable::getExecuteOrder(const std::vector<VARP>& outputs) {
1351 std::vector<EXPRP> sequence;
1352 std::stack<EXPRP> workStack;
1353 for (auto output : outputs) {
1354 if (nullptr == output) {
1355 continue;
1356 }
1357 if (nullptr == output->expr().first) {
1358 continue;
1359 }
1360 auto op = output->expr().first->get();
1361 bool isConst = ((op && op->type() == OpType_Const) || (!op && output->expr().first->inputType() == VARP::CONSTANT));
1362 if (isConst) {
1363 if (!output->expr().first->visited()){
1364 output->expr().first->setVisited(true);
1365 sequence.emplace_back(output->expr().first);
1366 continue;
1367 }
1368 }
1369 workStack.push(output->expr().first);
1370 }
1371 while (!workStack.empty()) {
1372 auto expr = workStack.top();
1373 bool valid = true;
1374 if (expr->visited()) {
1375 workStack.pop();
1376 continue;
1377 }
1378 for (auto input : expr->inputs()) {
1379 if (input == nullptr) {
1380 continue;
1381 }
1382 if (input->expr().first->visited()) {
1383 continue;
1384 }
1385 valid = false;
1386 workStack.push(input->expr().first);
1387 break;
1388 }
1389 if (valid) {
1390 sequence.emplace_back(expr);
1391 expr->setVisited(true);
1392 workStack.pop();
1393 }
1394 }
1395 for (auto expr : sequence) {
1396 expr->setVisited(false);
1397 }
1398 return sequence;
1399}
1400
1401VARP VARP::operator+(VARP var) const {
1402 return _Add(VARP(mContent), var);

Callers

nothing calls this directly

Calls 7

setVisitedMethod · 0.80
getMethod · 0.45
typeMethod · 0.45
visitedMethod · 0.45
pushMethod · 0.45
emptyMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected