Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpCompat] Remove redundant mappings #55448

Merged
merged 3 commits into from
Jul 28, 2023

Conversation

Asthestarsfalll
Copy link
Contributor

@Asthestarsfalll Asthestarsfalll commented Jul 14, 2023

PR types

Others

PR changes

Others

Description

去除paddle/phi/api/yaml/op_compat.yaml中类似冗余的映射逻辑

脚本代码:

import yaml

path = './Paddle/paddle/phi/api/yaml/op_compat.yaml'


with open(path, 'r') as file:
    yaml_data = file.read()

data = yaml.load(yaml_data, Loader=yaml.FullLoader)
targets = ['inputs', 'outputs']

def check_duplicated(params):
    for k, v in params.items():
        if k != v:
            return True
    return False

def check_op(op):
    temp = [op[t] for t in targets if t in op]
    return len(temp) == len(list(op.keys())) - 1

for op in data:
    flag = True
    for tar in targets:
        if tar in op:
           flag = flag and check_duplicated(op[tar]) 

    if not flag and check_op(op):
        print(op)

@paddle-bot
Copy link

paddle-bot bot commented Jul 14, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Jul 14, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jul 15, 2023
@kangguangli
Copy link
Contributor

kangguangli commented Jul 16, 2023

hello, 同学你的进展很快,但是这一步依赖 #55334 中的第二步,可以把第二步一起完成,参考#55201 中对paddle/fluid/ir_adaptor/translator/op_compat_info.h的修改即可。

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented Jul 22, 2023

Sorry to inform you that 3e1369a's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@kangguangli
Copy link
Contributor

@Asthestarsfalll hello,重新看了下这里的脚本,有个问题

def check_op(op):
    temp = [op[t] for t in targets if t in op]
    return len(temp) == len(list(op.keys())) - 1

这个检查是为了确认是否全部参数都是冗余的吗?如果是的话,应该没有必要。只有一对参数或某几个映射冗余,也应该一起删除

@Asthestarsfalll
Copy link
Contributor Author

Asthestarsfalll commented Jul 27, 2023

@Asthestarsfalll hello,重新看了下这里的脚本,有个问题

def check_op(op):
    temp = [op[t] for t in targets if t in op]
    return len(temp) == len(list(op.keys())) - 1

这个检查是为了确认是否全部参数都是冗余的吗?如果是的话,应该没有必要。只有一对参数或某几个映射冗余,也应该一起删除

这里是判断是不是只有inputs或outputs,如果有其他信息比如extra等就跳过,现在去除了
更新了一下,现在考虑到了只有某些参数映射冗余的情况

Copy link
Contributor

@kangguangli kangguangli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@kangguangli kangguangli requested a review from zyfncg July 28, 2023 02:42
@kangguangli kangguangli merged commit 0b04b93 into PaddlePaddle:develop Jul 28, 2023
wz1qqx pushed a commit to wz1qqx/Paddle that referenced this pull request Jul 31, 2023
* [OpCompat] Remove redundant mappings

* update op_compat.yaml
@Asthestarsfalll Asthestarsfalll deleted the remove_redundant branch August 19, 2023 06:38
jinjidejinmuyan pushed a commit to jinjidejinmuyan/Paddle that referenced this pull request Aug 30, 2023
* [OpCompat] Remove redundant mappings

* update op_compat.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants