| 251 | return x; |
| 252 | } |
| 253 | bool allPathLegal(Node* s, Node* t, MNNForwardType type) { |
| 254 | bool legal = true; |
| 255 | std::queue<Node*> q; |
| 256 | q.push(s); |
| 257 | while (!q.empty()) { |
| 258 | auto node = q.front(); |
| 259 | q.pop(); |
| 260 | legal &= isLegal(node->cmd, type); |
| 261 | if(!legal) { |
| 262 | return false; |
| 263 | } |
| 264 | for (auto succ : node->succ) { |
| 265 | if (succ != t) { |
| 266 | q.push(succ); |
| 267 | } |
| 268 | } |
| 269 | } |
| 270 | return legal; |
| 271 | } |
| 272 | std::vector<Node*> fuseNode(Node* root, std::vector<Node*>& edges, MNNForwardType type) { |
| 273 | std::vector<Node*> fuseSet; |
| 274 | std::queue<Node*> q; |