Skip to content

Commit

Permalink
fix hier traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
renau committed Jan 7, 2024
1 parent c626350 commit 86ec9b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
4 changes: 4 additions & 0 deletions lgraph/lgedgeiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ void Fwd_edge_iterator::Fwd_iter::fwd_get_from_linear_first(Lgraph *top) {
auto next_node = *global_it;
++global_it;

// fmt::print("1.linear_first {}\n", next_node.debug_name());

if (next_node.is_type_loop_last() || !next_node.has_outputs()) {
if (!visit_sub || !next_node.is_type_sub_present()) {
continue; // Keep it for linear_last_phase
Expand Down Expand Up @@ -186,6 +188,7 @@ void Fwd_edge_iterator::Fwd_iter::fwd_get_from_linear_first(Lgraph *top) {
}
}
}
// fmt::print("linear_first {}\n", next_node.debug_name());

if (is_topo_sorted) {
current_node.update(next_node);
Expand All @@ -196,6 +199,7 @@ void Fwd_edge_iterator::Fwd_iter::fwd_get_from_linear_first(Lgraph *top) {
}

if (current_node.is_invalid()) {
// fmt::print("exit linear_first_phase\n");
linear_first_phase = false;
I(linear_last_phase == false);

Expand Down
6 changes: 3 additions & 3 deletions lgraph/lgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Lgraph::setup_hierarchy_for_traversal() {
I(e.first.nid);

auto *sub_lg2 = ref_library()->open_lgraph(e.second);
if (sub_lg2 && !sub_lg2->get_down_nodes_map().empty()) {
if (sub_lg2) { // && !sub_lg2->get_down_nodes_map().empty()) {
auto child_hidx = htree.add_go_down(parent_hidx, this, e.first.nid);

setup_hierarchy_down(sub_lg2, child_hidx);
Expand Down Expand Up @@ -1720,8 +1720,8 @@ void Lgraph::dump(bool hier) {

absl::flat_hash_map<int, int> color_count;

// for (auto node : forward(hier)) {
for (auto node : fast(hier)) {
for (auto node : forward(hier)) {
// for (auto node : fast(hier)) {
if (node.has_color()) {
++color_count[node.get_color()];
}
Expand Down
10 changes: 0 additions & 10 deletions lgraph/lgraph_base_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ using Lg_type_id = Explicit_type<Lg_id_t, struct Lg_type_id_struct, 0>; // Glo
using Index_id = Explicit_type<Lg_id_t, struct Index_id_struct, 0>;
using Lut_type_id = Explicit_type<Lg_id_t, struct Lut_type_id_struct, 0>;

class Hierarchy_data { // 64bits total
public:
Lg_type_id lgid;
Index_id up_nid;
Hierarchy_data() : lgid(0), up_nid(0) {}
Hierarchy_data(const Lg_type_id& _class_id, const Index_id& _nid) : lgid(_class_id), up_nid(_nid) {}

bool is_invalid() const { return lgid == 0; }
};

using Hierarchy_index = int32_t; // -1 is invalid, 0 is root

struct Lg_type_id_hash {
Expand Down

0 comments on commit 86ec9b9

Please sign in to comment.