| 223 | } |
| 224 | |
| 225 | bool FindDicePattern(const utils::MutableGraphView& graph_view, int node_index, |
| 226 | DicePattern* matched) { |
| 227 | DicePattern pattern; |
| 228 | std::vector<int> outs; |
| 229 | auto* node_view = graph_view.GetNode(node_index); |
| 230 | if (node_view->NumControllingFanins() > 0 || |
| 231 | node_view->NumControlledFanouts() > 0) |
| 232 | return false; |
| 233 | |
| 234 | pattern.sub_1_id = node_index; |
| 235 | // Match sub_1, get input index and mul_1 index |
| 236 | if (!IsNodeViewMatchSub_1(graph_view, node_index, &pattern)) return false; |
| 237 | // Match mul, get constant input index and sigmoid index |
| 238 | if (!IsNodeViewMatchMul_1(graph_view, pattern.mul_1_id, &pattern)) |
| 239 | return false; |
| 240 | // Match sigmoid, get sub_2 & mul_4 index |
| 241 | if (!IsNodeViewMatchSigmoid(graph_view, pattern.sigmoid_id, &pattern)) |
| 242 | return false; |
| 243 | // Match sub_2, get constant input index |
| 244 | if (!IsNodeViewMatchSub_2(graph_view, pattern.sub_2_id, &pattern)) |
| 245 | return false; |
| 246 | // Match mul_2, get mul_3 index and check input index |
| 247 | if (!IsNodeViewMatchMul_2(graph_view, pattern.mul_2_id, &pattern)) |
| 248 | return false; |
| 249 | // Match mul_3, get add index and input index |
| 250 | if (!IsNodeViewMatchMul_3(graph_view, pattern.mul_3_id, &pattern)) |
| 251 | return false; |
| 252 | // Match mul_4, check add and input index |
| 253 | if (!IsNodeViewMatchMul_4(graph_view, pattern.mul_4_id, &pattern)) |
| 254 | return false; |
| 255 | |
| 256 | *matched = pattern; |
| 257 | return true; |
| 258 | } |
| 259 | |
| 260 | string get_node_by_tensor(string tensor_name) { |
| 261 | auto position = tensor_name.find(":"); |
no test coverage detected