Skip to content

Commit 9a6e239

Browse files
authored
fix mac graph detector sort (#14356)
1 parent c27554a commit 9a6e239

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

paddle/fluid/framework/ir/graph_pattern_detector.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,16 @@ GraphPatternDetector::DetectPatterns() {
261261
return result;
262262
}
263263

264-
bool GraphItemCMP(const std::pair<PDNode *, Node *> &a,
264+
struct GraphItemLessThan {
265+
bool operator()(const std::pair<PDNode *, Node *> &a,
265266
const std::pair<PDNode *, Node *> &b) {
266-
if (a.first != b.first) {
267-
return a.first < b.first;
268-
} else {
269-
return a.second < b.second;
267+
if (a.first != b.first) {
268+
return a.first < b.first;
269+
} else {
270+
return a.second < b.second;
271+
}
270272
}
271-
}
273+
};
272274

273275
// TODO(Superjomn) enhance the function as it marks unique unique as duplicates
274276
// see https://github.com/PaddlePaddle/Paddle/issues/13550
@@ -282,7 +284,7 @@ void GraphPatternDetector::UniquePatterns(
282284
for (auto &g : *subgraphs) {
283285
// Sort the items in the sub-graph, and transform to a string key.
284286
std::vector<std::pair<PDNode *, Node *>> sorted_keys(g.begin(), g.end());
285-
std::sort(sorted_keys.begin(), sorted_keys.end(), GraphItemCMP);
287+
std::sort(sorted_keys.begin(), sorted_keys.end(), GraphItemLessThan());
286288
std::stringstream ss;
287289
for (auto &item : sorted_keys) {
288290
ss << item.first << ":" << item.second;

0 commit comments

Comments
 (0)