未验证 提交 9a6e2392 编写于 作者: Y Yan Chunwei 提交者: GitHub

fix mac graph detector sort (#14356)

上级 c27554ac
...@@ -261,14 +261,16 @@ GraphPatternDetector::DetectPatterns() { ...@@ -261,14 +261,16 @@ GraphPatternDetector::DetectPatterns() {
return result; return result;
} }
bool GraphItemCMP(const std::pair<PDNode *, Node *> &a, struct GraphItemLessThan {
bool operator()(const std::pair<PDNode *, Node *> &a,
const std::pair<PDNode *, Node *> &b) { const std::pair<PDNode *, Node *> &b) {
if (a.first != b.first) { if (a.first != b.first) {
return a.first < b.first; return a.first < b.first;
} else { } else {
return a.second < b.second; return a.second < b.second;
}
} }
} };
// TODO(Superjomn) enhance the function as it marks unique unique as duplicates // TODO(Superjomn) enhance the function as it marks unique unique as duplicates
// see https://github.com/PaddlePaddle/Paddle/issues/13550 // see https://github.com/PaddlePaddle/Paddle/issues/13550
...@@ -282,7 +284,7 @@ void GraphPatternDetector::UniquePatterns( ...@@ -282,7 +284,7 @@ void GraphPatternDetector::UniquePatterns(
for (auto &g : *subgraphs) { for (auto &g : *subgraphs) {
// Sort the items in the sub-graph, and transform to a string key. // Sort the items in the sub-graph, and transform to a string key.
std::vector<std::pair<PDNode *, Node *>> sorted_keys(g.begin(), g.end()); std::vector<std::pair<PDNode *, Node *>> sorted_keys(g.begin(), g.end());
std::sort(sorted_keys.begin(), sorted_keys.end(), GraphItemCMP); std::sort(sorted_keys.begin(), sorted_keys.end(), GraphItemLessThan());
std::stringstream ss; std::stringstream ss;
for (auto &item : sorted_keys) { for (auto &item : sorted_keys) {
ss << item.first << ":" << item.second; ss << item.first << ":" << item.second;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册