| 707 | } |
| 708 | |
| 709 | void heuristic_tree(TokenStream &in, MLGOHeuristics &h, bool &valid) |
| 710 | { |
| 711 | CHECK(expect_text(in, "<heuristic", valid), valid); |
| 712 | const auto tree_id = CHECK(uint_val(in, valid), valid); |
| 713 | CHECK(expect_text(in, ">", valid), valid); |
| 714 | HeuristicTree *t = nullptr; |
| 715 | std::tie(valid, t) = CHECK(h.get_heuristic_tree(tree_id), valid); |
| 716 | const HeuristicType t_heuristic_type = std::get<0>(t->index()); |
| 717 | while (!accept_text(in, "</heuristic>")) |
| 718 | { |
| 719 | LOG_TOKEN_POS(in, pos); |
| 720 | if (accept_text(in, "b")) |
| 721 | { |
| 722 | // Branch node |
| 723 | const auto id = CHECK(uint_val(in, valid), valid); |
| 724 | const auto cond = CHECK(condition(in, valid), valid); |
| 725 | const auto t_id = CHECK(uint_val(in, valid), valid); |
| 726 | const auto f_id = CHECK(uint_val(in, valid), valid); |
| 727 | valid = CHECK(t->add_branch(id, cond, t_id, f_id), valid); |
| 728 | } |
| 729 | else if (accept_text(in, "l")) |
| 730 | { |
| 731 | // Leaf node |
| 732 | const auto id = CHECK(uint_val(in, valid), valid); |
| 733 | // NOTE: Heuristic type within each tree appears to be redundant (same information can be obtained from the |
| 734 | // heuristic table). For now it remains as a step for validation. |
| 735 | LOG_TOKEN_POS(in, pos); |
| 736 | CHECK(expect_heuristic_type(in, t_heuristic_type, valid), valid); |
| 737 | switch (t_heuristic_type) |
| 738 | { |
| 739 | case HeuristicType::GEMM_Type: |
| 740 | { |
| 741 | const auto g_type = CHECK(gemm_type(in, valid), valid); |
| 742 | valid = CHECK(t->add_leaf(id, g_type), valid); |
| 743 | break; |
| 744 | } |
| 745 | case HeuristicType::GEMM_Config_Native: |
| 746 | { |
| 747 | const auto g_c = CHECK(gemm_config_native(in, valid), valid); |
| 748 | valid = CHECK(t->add_leaf(id, g_c), valid); |
| 749 | break; |
| 750 | } |
| 751 | case HeuristicType::GEMM_Config_Reshaped_Only_RHS: |
| 752 | { |
| 753 | const auto g_c = CHECK(gemm_config_reshaped_only_rhs(in, valid), valid); |
| 754 | valid = CHECK(t->add_leaf(id, g_c), valid); |
| 755 | break; |
| 756 | } |
| 757 | case HeuristicType::GEMM_Config_Reshaped: |
| 758 | { |
| 759 | const auto g_c = CHECK(gemm_config_reshaped(in, valid), valid); |
| 760 | valid = CHECK(t->add_leaf(id, g_c), valid); |
| 761 | break; |
| 762 | } |
| 763 | default: |
| 764 | { |
| 765 | FAIL_WITH_MSG(valid, pos, "Unexpected heuristic type"); |
| 766 | } |
no test coverage detected