-
Notifications
You must be signed in to change notification settings - Fork 766
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 组)2 -part #6890
Conversation
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.frombuffer.md
Outdated
Show resolved
Hide resolved
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.
写转写示例时:
要求尽可能简单,冗余的变量准备代码都不需要,写关键一行就行。
尽量就是一行对一行、或一行对多行
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.blackman_window.md
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.frombuffer.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.frombuffer.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.frombuffer.md
Outdated
Show resolved
Hide resolved
...des/model_convert/convert_from_pytorch/api_difference/torch/torch.get_num_interop_threads.md
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.get_num_threads.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.set_num_threads.md
Outdated
Show resolved
Hide resolved
torch.get_num_interop_threads() | ||
|
||
# Paddle 写法 | ||
return os.environ['OMP_NUM_THREADS'] |
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
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.
这个用multiprocessing.cpu_count()还是os.environ['OMP_NUM_THREADS']更符合点?
torch.get_num_threads() | ||
|
||
# Paddle 写法 | ||
return multiprocessing.cpu_count() |
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
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.
这个和os.environ['CPU_NUM'] 哪个更合适
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.
已改。
| - | window | 窗函数类型,Pytorch 无此参数,Paddle 需设置为 `hamming`。 | | ||
| window_length | win_length | 输入窗口的长度,仅参数名不同。 | | ||
| periodic | fftbins | 判断是否返回适用于过滤器设计的对称窗口,功能相反,需要转写。 | | ||
| alpha | - | 窗函数中非线性部分的衰减速度,Paddle 无此参数,暂无转写方式。 | |
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.
这个没有转写方式吗?看其他的窗函数std、alpha都能转写
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.
paddle:
def _hamming(M: int, sym: bool = True, dtype: str = 'float64') -> Tensor:
"""Compute a Hamming window.
The Hamming window is a taper formed by using a raised cosine with
non-zero endpoints, optimized to minimize the nearest side lobe.
"""
return _general_hamming(M, 0.54, sym, dtype=dtype)
参数固定了。
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.hann_window.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.hann_window.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.hamming_window.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.blackman_window.md
Outdated
Show resolved
Hide resolved
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.
LGTM
注意事项:
- 后续根据该文档来实现Matcher,注意不要出现文档与Matcher的diff。
- 如果实现Matcher的过程中,发现文档有误,需及时回头更正文档。
Paddle 代码转换工具新增 API 转换规则(第 3 组) part 2