diff --git a/lib/utils/include/utils/containers.h b/lib/utils/include/utils/containers.h index ae274f473a..eacb522ee5 100644 --- a/lib/utils/include/utils/containers.h +++ b/lib/utils/include/utils/containers.h @@ -172,7 +172,8 @@ std::unordered_map filter_keys(std::unordered_map const &m, return result; } -template std::unordered_map filter_keys(bidict const & m, F const & f) { +template +std::unordered_map filter_keys(bidict const &m, F const &f) { std::unordered_map result; for (auto const &kv : m) { if (f(kv.first)) { @@ -182,8 +183,8 @@ template std::unordered_map filter_ke return result; } - -template std::unordered_map filter_values(bidict const & m, F const & f) { +template +std::unordered_map filter_values(bidict const &m, F const &f) { std::unordered_map result; for (auto const &kv : m) { if (f(kv.second)) { @@ -193,7 +194,6 @@ template std::unordered_map filter_va return result; } - template filter_values(std::unordered_map const &m, return result; } - - - template std::vector keys(C const &c) { std::vector result; diff --git a/lib/utils/include/utils/graph/query_set.h b/lib/utils/include/utils/graph/query_set.h index d16099a080..4bea69a289 100644 --- a/lib/utils/include/utils/graph/query_set.h +++ b/lib/utils/include/utils/graph/query_set.h @@ -1,10 +1,10 @@ #ifndef _FLEXFLOW_UTILS_INCLUDE_UTILS_GRAPH_QUERY_SET_H #define _FLEXFLOW_UTILS_INCLUDE_UTILS_GRAPH_QUERY_SET_H +#include "utils/bidict.h" #include "utils/containers.h" #include "utils/exception.h" #include "utils/optional.h" -#include "utils/bidict.h" #include namespace FlexFlow { @@ -12,12 +12,12 @@ namespace FlexFlow { template struct query_set { query_set() = delete; - query_set(T const & query) : query({query}) { - std::cout<<"1"< const &query) : query(query) {} - query_set(optional> const & query): query(query) {} + query_set(optional> const &query) : query(query) {} friend bool operator==(query_set const &lhs, query_set const &rhs) { return lhs.value == rhs.value; @@ -71,37 +71,36 @@ template std::unordered_map query_keys(query_set const &q, C const &m) { - std::cout<<"3"< q_set = allowed_values(q); - auto filter_lambda = [&q_set](const K& key) { + auto filter_lambda = [&q_set](K const &key) { return q_set.find(key) != q_set.end(); }; return filter_keys(m, filter_lambda); -}//TODO +} // TODO -template -std::unordered_map query_keys(query_set const &q, bidict const &m) { +template +std::unordered_map query_keys(query_set const &q, + bidict const &m) { std::unordered_set q_set = allowed_values(q); - auto filter_lambda = [&q_set](const V& value) { + auto filter_lambda = [&q_set](V const &value) { return q_set.find(value) != q_set.end(); }; - return filter_values(m, filter_lambda); + return filter_values(m, filter_lambda); } - template std::unordered_map query_values(query_set const &q, C const &m) { - std::cout<<"4"< q_set = allowed_values(q); - auto filter_lambda = [&q_set](const V& value) { + auto filter_lambda = [&q_set](V const &value) { return q_set.find(value) != q_set.end(); }; diff --git a/lib/utils/src/graph/adjacency_multidigraph.cc b/lib/utils/src/graph/adjacency_multidigraph.cc index 0b8ee7f4f1..adf5ded069 100644 --- a/lib/utils/src/graph/adjacency_multidigraph.cc +++ b/lib/utils/src/graph/adjacency_multidigraph.cc @@ -42,11 +42,13 @@ void AdjacencyMultiDiGraph::remove_edge(MultiDiEdge const &e) { std::unordered_set AdjacencyMultiDiGraph::query_edges(MultiDiEdgeQuery const &q) const { std::unordered_set result; - for (auto const &src_kv : query_keys(q.srcs, this->adjacency)) { //query_keys(q.srcs, this->adjacency) return map>>> + for (auto const &src_kv : query_keys(q.srcs, this->adjacency)) { for (auto const &dst_kv : query_keys(q.dsts, src_kv.second)) { for (auto const &srcIdx_kv : query_keys(q.srcIdxs, dst_kv.second)) { for (auto const &dstIdx : apply_query(q.dstIdxs, srcIdx_kv.second)) { - std::cout<<"add edge "< ViewOpenMultiDiGraphAsMultiDiGraph::query_edges( // } // return result; - std::cout<<"5"< JoinedNodeView::query_nodes(NodeQuery const &query) const { - return unique(values(query_keys(query.nodes, this->mapping)));//query_keys(query.nodes, this->mapping)->std::unordered_map + return unique(values(query_keys(query.nodes, this->mapping))); } std::pair, std::unordered_set>