From b463b69fb42ff380ee2dc4bc754f5f20de2ee51b Mon Sep 17 00:00:00 2001 From: tianshuo78520a <707759223@qq.com> Date: Sun, 9 May 2021 11:46:02 +0800 Subject: [PATCH 1/4] fix python3 --- tools/check_op_desc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/check_op_desc.py b/tools/check_op_desc.py index 15e410401216c..9e5bd08be698d 100644 --- a/tools/check_op_desc.py +++ b/tools/check_op_desc.py @@ -14,6 +14,7 @@ import json import sys +import operator from paddle.utils import OpLastCheckpointChecker from paddle.fluid.core import OpUpdateType @@ -71,7 +72,8 @@ def diff_vars(origin_vars, new_vars): vars_name_only_in_new = set(new_vars.keys()) - set(origin_vars.keys()) for var_name in common_vars_name: - if cmp(origin_vars.get(var_name), new_vars.get(var_name)) == SAME: + if operator.eq(origin_vars.get(var_name), + new_vars.get(var_name)) == SAME: continue else: error, var_error = True, True @@ -120,7 +122,8 @@ def diff_attr(ori_attrs, new_attrs): attrs_only_in_new = set(new_attrs.keys()) - set(ori_attrs.keys()) for attr_name in common_attrs: - if cmp(ori_attrs.get(attr_name), new_attrs.get(attr_name)) == SAME: + if operator.eq(ori_attrs.get(attr_name), + new_attrs.get(attr_name)) == SAME: continue else: error, attr_error = True, True @@ -184,7 +187,7 @@ def compare_op_desc(origin_op_desc, new_op_desc): new = json.loads(new_op_desc) desc_error_message = {} version_error_message = {} - if cmp(origin_op_desc, new_op_desc) == SAME: + if operator.eq(origin_op_desc, new_op_desc) == SAME: return desc_error_message, version_error_message for op_type in origin: From 7b2ea7c2a56d4d36029b5d8338746a2e4ef582e2 Mon Sep 17 00:00:00 2001 From: tianshuo78520a <707759223@qq.com> Date: Mon, 10 May 2021 17:31:36 +0800 Subject: [PATCH 2/4] fix operator --- tools/check_op_desc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_op_desc.py b/tools/check_op_desc.py index 9e5bd08be698d..bbd1ed720a108 100644 --- a/tools/check_op_desc.py +++ b/tools/check_op_desc.py @@ -18,7 +18,7 @@ from paddle.utils import OpLastCheckpointChecker from paddle.fluid.core import OpUpdateType -SAME = 0 +SAME = 1 INPUTS = "Inputs" OUTPUTS = "Outputs" From dd62e4f64402c78b0757c9ea323828c896c96bc0 Mon Sep 17 00:00:00 2001 From: tianshuo78520a <707759223@qq.com> Date: Mon, 10 May 2021 17:37:11 +0800 Subject: [PATCH 3/4] fix operator --- tools/check_op_desc.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/check_op_desc.py b/tools/check_op_desc.py index bbd1ed720a108..e733cdffaf3a9 100644 --- a/tools/check_op_desc.py +++ b/tools/check_op_desc.py @@ -18,8 +18,6 @@ from paddle.utils import OpLastCheckpointChecker from paddle.fluid.core import OpUpdateType -SAME = 1 - INPUTS = "Inputs" OUTPUTS = "Outputs" ATTRS = "Attrs" @@ -72,8 +70,7 @@ def diff_vars(origin_vars, new_vars): vars_name_only_in_new = set(new_vars.keys()) - set(origin_vars.keys()) for var_name in common_vars_name: - if operator.eq(origin_vars.get(var_name), - new_vars.get(var_name)) == SAME: + if operator.eq(origin_vars.get(var_name), new_vars.get(var_name)): continue else: error, var_error = True, True @@ -122,8 +119,7 @@ def diff_attr(ori_attrs, new_attrs): attrs_only_in_new = set(new_attrs.keys()) - set(ori_attrs.keys()) for attr_name in common_attrs: - if operator.eq(ori_attrs.get(attr_name), - new_attrs.get(attr_name)) == SAME: + if operator.eq(ori_attrs.get(attr_name), new_attrs.get(attr_name)): continue else: error, attr_error = True, True @@ -187,7 +183,7 @@ def compare_op_desc(origin_op_desc, new_op_desc): new = json.loads(new_op_desc) desc_error_message = {} version_error_message = {} - if operator.eq(origin_op_desc, new_op_desc) == SAME: + if operator.eq(origin_op_desc, new_op_desc): return desc_error_message, version_error_message for op_type in origin: From ca4f88668f173f851febeb3ac31e4316f46ddc77 Mon Sep 17 00:00:00 2001 From: tianshuo78520a <707759223@qq.com> Date: Tue, 11 May 2021 14:59:19 +0800 Subject: [PATCH 4/4] fix diff --- tools/check_op_desc.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/check_op_desc.py b/tools/check_op_desc.py index e733cdffaf3a9..78abb6f36c606 100644 --- a/tools/check_op_desc.py +++ b/tools/check_op_desc.py @@ -14,7 +14,6 @@ import json import sys -import operator from paddle.utils import OpLastCheckpointChecker from paddle.fluid.core import OpUpdateType @@ -70,7 +69,7 @@ def diff_vars(origin_vars, new_vars): vars_name_only_in_new = set(new_vars.keys()) - set(origin_vars.keys()) for var_name in common_vars_name: - if operator.eq(origin_vars.get(var_name), new_vars.get(var_name)): + if origin_vars.get(var_name) == new_vars.get(var_name): continue else: error, var_error = True, True @@ -119,7 +118,7 @@ def diff_attr(ori_attrs, new_attrs): attrs_only_in_new = set(new_attrs.keys()) - set(ori_attrs.keys()) for attr_name in common_attrs: - if operator.eq(ori_attrs.get(attr_name), new_attrs.get(attr_name)): + if ori_attrs.get(attr_name) == new_attrs.get(attr_name): continue else: error, attr_error = True, True @@ -183,7 +182,7 @@ def compare_op_desc(origin_op_desc, new_op_desc): new = json.loads(new_op_desc) desc_error_message = {} version_error_message = {} - if operator.eq(origin_op_desc, new_op_desc): + if origin_op_desc == new_op_desc: return desc_error_message, version_error_message for op_type in origin: