-
Notifications
You must be signed in to change notification settings - Fork 53
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
【Hackathon 7th No.36】为 Paddle 代码转换工具新增 API 转换规则(第 3 组)-part #479
base: master
Are you sure you want to change the base?
Changes from all commits
28ed535
cdc060b
131dac1
fdd7ae6
9eeb83d
73e0929
9ea271b
9e9cab5
7e1675a
ce46bff
70cfd55
206980a
7c8b49e
6a892d0
f155669
7c8108f
563a1be
4aee5c1
f40a61e
ecd7677
6b22746
5aca4f5
4d9440d
fb27f13
854bd4c
6c0d004
2b56f1a
3761ca9
51f6f81
c66d5ed
6eef583
476edb3
9c2aa00
67972d8
466d826
3c5e0e4
38d7bc8
3ce42da
a34f023
814e9fd
d2d0a82
fc5b930
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14571,6 +14571,195 @@ | |
"input": "x" | ||
} | ||
}, | ||
"torch.signal.windows.blackman": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64", | ||
"window": "'blackman'" | ||
} | ||
}, | ||
"torch.signal.windows.cosine": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64", | ||
"window": "'cosine'" | ||
} | ||
}, | ||
"torch.signal.windows.exponential": { | ||
"Matcher": "SignalWindowsWatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"center", | ||
"tau", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"unsupport_args": [ | ||
"center" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64" | ||
} | ||
}, | ||
"torch.signal.windows.gaussian": { | ||
"Matcher": "SignalWindowsWatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"std", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64" | ||
} | ||
}, | ||
"torch.signal.windows.general_cosine": { | ||
"Matcher": "SignalWindowsWatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"a", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"a": "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 文档的转写方式看起来不是直接删除?是否有没对应上的diff? 没对应上的注意回头修正文档 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 文档中a需要转写,a传入的是list, paddle组合成了 tuple(str, list)。a作为非可选参数,没有默认值。paddle中没有a这个参数,所以在general_cosine中,a默认为空。从pytorch拿值给a pytorch: torch.signal.windows.general_cosine(10, a=[0.46, 0.23, 0.31]) paddle: paddle.audio.functional.get_window(('general_cosine', [0.46, 0.23, 0.31]), 10) |
||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64" | ||
} | ||
}, | ||
"torch.signal.windows.general_hamming": { | ||
"Matcher": "SignalWindowsWatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"alpha", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64" | ||
} | ||
}, | ||
"torch.signal.windows.hamming": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64", | ||
"window": "'hamming'" | ||
} | ||
}, | ||
"torch.signal.windows.hann": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.audio.functional.get_window", | ||
"min_input_args": 1, | ||
"args_list": [ | ||
"M", | ||
"*", | ||
"sym", | ||
"dtype", | ||
"layout", | ||
"device", | ||
"requires_grad" | ||
], | ||
"kwargs_change": { | ||
"M": "win_length", | ||
"sym": "fftbins", | ||
"dtype": "dtype" | ||
}, | ||
"paddle_default_kwargs": { | ||
"dtype": "paddle.float64", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. paddle中默认float64。已开pr改文档。 def get_window(
window: _WindowLiteral | tuple[_WindowLiteral, float],
win_length: int,
fftbins: bool = True,
dtype: str = 'float64',
) -> Tensor:
def _gaussian(
M: int, std: float, sym: bool = True, dtype: str = 'float64'
) -> Tensor:
def _exponential(
M: int, center=None, tau=1.0, sym: bool = True, dtype: str = 'float64'
) -> Tensor: |
||
"window": "'hann'" | ||
} | ||
}, | ||
"torch.signbit": { | ||
"Matcher": "GenericMatcher", | ||
"paddle_api": "paddle.signbit", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import textwrap | ||
|
||
from apibase import APIBase | ||
|
||
obj = APIBase("torch.signal.windows.blackman") | ||
|
||
|
||
def test_case_1(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.blackman(5) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False, check_dtype=False) | ||
|
||
|
||
def test_case_2(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.blackman(5, dtype=torch.float64) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_3(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.blackman(5, dtype=torch.float64, requires_grad=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_4(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.blackman(5, dtype=torch.float64, layout=torch.strided, requires_grad=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_5(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.blackman(5, dtype=torch.float64, layout=torch.strided, device=torch.device('cpu'), requires_grad=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_6(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.blackman(5, sym=False, dtype=torch.float64) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import textwrap | ||
|
||
from apibase import APIBase | ||
|
||
obj = APIBase("torch.signal.windows.cosine") | ||
|
||
|
||
def test_case_1(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.cosine(10) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False, check_dtype=False) | ||
|
||
|
||
def test_case_2(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.cosine(10, dtype=torch.float64) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_3(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.cosine(10, dtype=torch.float64, requires_grad=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_4(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.cosine(10, dtype=torch.float64, layout=torch.strided, requires_grad=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_5(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.cosine(10, dtype=torch.float64, layout=torch.strided, device=torch.device('cpu'), requires_grad=True) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) | ||
|
||
|
||
def test_case_7(): | ||
pytorch_code = textwrap.dedent( | ||
""" | ||
import torch | ||
result = torch.signal.windows.cosine(10, sym=False, dtype=torch.float64) | ||
""" | ||
) | ||
obj.run(pytorch_code, ["result"], check_value=False) |
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.
这个是能转写吗?是否和文档有没对应上的diff?
https://github.com/PaddlePaddle/docs/pull/6879/files#diff-c25f5bf0bbbdaa584d455f882add0f1663e1bbef009b752bd32d19564d9474be
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改文档。