-
Notifications
You must be signed in to change notification settings - Fork 50
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
转换规则 No. 10 #170
base: master
Are you sure you want to change the base?
转换规则 No. 10 #170
Conversation
Thanks for your contribution! |
单测未通过,也需要修复 |
@zhwesky2010 AssertionError: API (torch.stft): shape mismatch, torch shape is (1, 9, 9), paddle shape is (1, 16, 9) |
@zhwesky2010 2023-07-20 12:42:10 File "/workspace/a4bba61b-0eea-44b9-8d1b-5a4732f9836f/PaConvert/paconvert/../paconvert/transformer/basic_transformer.py", line 550, in visit_FunctionDef
2023-07-20 12:42:10 super(BasicTransformer, self).generic_visit(node)
2023-07-20 12:42:10 File "/root/anaconda3/lib/python3.10/ast.py", line 494, in generic_visit
2023-07-20 12:42:10 value = self.visit(value)
2023-07-20 12:42:10 File "/workspace/a4bba61b-0eea-44b9-8d1b-5a4732f9836f/PaConvert/paconvert/../paconvert/base.py", line 82, in visit
2023-07-20 12:42:10 node = super(BaseTransformer, self).visit(node)
2023-07-20 12:42:10 File "/root/anaconda3/lib/python3.10/ast.py", line 418, in visit
2023-07-20 12:42:10 return visitor(node)
2023-07-20 12:42:10 File "/root/anaconda3/lib/python3.10/ast.py", line 503, in generic_visit
2023-07-20 12:42:10 new_node = self.visit(old_value)
2023-07-20 12:42:10 File "/workspace/a4bba61b-0eea-44b9-8d1b-5a4732f9836f/PaConvert/paconvert/../paconvert/base.py", line 82, in visit
2023-07-20 12:42:10 node = super(BaseTransformer, self).visit(node)
2023-07-20 12:42:10 File "/root/anaconda3/lib/python3.10/ast.py", line 418, in visit
2023-07-20 12:42:10 return visitor(node)
2023-07-20 12:42:10 File "/workspace/a4bba61b-0eea-44b9-8d1b-5a4732f9836f/PaConvert/paconvert/../paconvert/transformer/basic_transformer.py", line 314, in visit_Call
2023-07-20 12:42:10 node_list = matcher.get_paddle_nodes(node.args, node.keywords)
2023-07-20 12:42:10 File "/workspace/a4bba61b-0eea-44b9-8d1b-5a4732f9836f/PaConvert/paconvert/../paconvert/base.py", line 397, in get_paddle_nodes
2023-07-20 12:42:10 new_code = self.generate_code(new_kwargs)
2023-07-20 12:42:10 File "/workspace/a4bba61b-0eea-44b9-8d1b-5a4732f9836f/PaConvert/paconvert/../paconvert/api_matcher.py", line 3170, in generate_code
2023-07-20 12:42:10 kwargs["onesided"],
2023-07-20 12:42:10 KeyError: 'onesided' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个API能否用GenericMatcher实现,而且你的实现和文档的转写思路也不太一样,看看转写文档 https://github.com/PaddlePaddle/docs/pull/6007/files#diff-bdd744e44f42895f618539ba1fe51a96e211dd9558d0a2967a453fdb89eec160
你可以看下GenericMatcher的功能,其搭配的 kwargs_change、paddle_default_kwargs、unsupport_args 这些字段的功能
obj.run(pytorch_code, ["result"]) | ||
|
||
|
||
def test_case_4(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已加。CI已过,请有空审核
paconvert/api_mapping.json
Outdated
], | ||
"kwargs_change": { | ||
"input": "x", | ||
"return_complex": "onesided" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return_complex 时,可使用as_real、as_complex进行转换处理 |
收到,我尽快处理,抱歉 |
按照文档的说法,不知道我理解的对不对: 在paddle中: 也就是说,onesided为false时,输入的是复数,可是pytorch2.0的输入必须为实信号,所以paddle的onesided值只能是True吧。 |
但你这个和映射文档中的参数映射对不上吧,麻烦检查下文档是不是有问题 https://github.com/PaddlePaddle/docs/blob/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.stft.md |
收到,我把文档改下。 |
No.10 的文档改了: |
paconvert/api_mapping.json
Outdated
], | ||
"kwargs_change": { | ||
"input": "x", | ||
"return_complex": "onesided" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里把 return_complex
这个参数赋值给 onesided
这个参数,我觉得是不对的,这不是两个完全不同的参数吗?
如果认为 return_complex
已经废弃,且恒为True无其他影响,那就应该设置 "return_complex": ""
,表示直接去掉该参数。
目前这个写法 "return_complex": "onesided"
是出于什么考虑对应两个不同的参数呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
收到,已改
[-1.6092, 0.5419, -0.2993, 0.3195]]) | ||
n_fft = 4 | ||
win_length = 4 | ||
result = torch.stft(x, n_fft=n_fft, center=False, win_length=win_length, normalized=True, return_complex=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加一下测试case:return_complex=False
[ 0.4907, -1.3948, -1.0691, -0.3132], | ||
[-1.6092, 0.5419, -0.2993, 0.3195]]) | ||
n_fft = 4 | ||
result = torch.stft(x, n_fft=n_fft, center=False, return_complex=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这四种情况需要都测到:
- 全部指定关键字
- 全部不指定关键字
- 改变关键字顺序
- 默认参数全部省略
PR Docs
PR APIs