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

【Hackathon 7th No.39】为 Paddle 代码转换工具新增 API 转换规则(第 6 组) #6878

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

Asthestarsfalll
Copy link
Contributor

@Asthestarsfalll Asthestarsfalll commented Sep 18, 2024

Copy link

paddle-bot bot commented Sep 18, 2024

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-6878.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html
预览工具的更多说明,请参考:飞桨文档预览工具

Copy link
Collaborator

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

麻烦根据 文档模板规范https://github.com/PaddlePaddle/docs/blob/develop/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_format_cn.md , 一一核对并检查无误。

不符合文档规范,不予合入

@CLAassistant
Copy link

CLAassistant commented Sep 18, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor Author

@Asthestarsfalll Asthestarsfalll left a comment

Choose a reason for hiding this comment

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

已按照文档要求更新,劳烦再审核下

@zhwesky2010
Copy link
Collaborator

@Asthestarsfalll 映射文档有问题,未通过CI不予合入:

1394 mapping documents found in api_difference.
2024-09-18 21:37:29 16 mapping documents found in api_difference_third_party/transformers.
2024-09-18 21:37:29 7 mapping documents found in api_difference_third_party/fairscale.
2024-09-18 21:37:29 4 mapping documents found in api_difference_third_party/flash_attn.
2024-09-18 21:37:29 Traceback (most recent call last):
2024-09-18 21:37:29   File "/FluidDoc/docs/guides/model_convert/convert_from_pytorch/tools/apply_references.py", line 319, in <module>
2024-09-18 21:37:29     metas = discover_all_metas(cfp_basedir)
2024-09-18 21:37:29   File "/FluidDoc/docs/guides/model_convert/convert_from_pytorch/tools/validate_mapping_files.py", line 635, in discover_all_metas
2024-09-18 21:37:29     metas.append(get_meta_from_diff_file(f, s, d, src_argmap_title=sh))
2024-09-18 21:37:29   File "/FluidDoc/docs/guides/model_convert/convert_from_pytorch/tools/validate_mapping_files.py", line 208, in get_meta_from_diff_file
2024-09-18 21:37:29     raise ValueError(
2024-09-18 21:37:29 ValueError: Unexpected mapping type: Paddle ???????????? in /FluidDoc/docs/guides/model_convert/convert_from_pytorch/tools/../api_difference/functional/torch.nn.functional.lp_pool2d.md
2024-09-18 21:37:29 Error: API mapping generate script failed, please check changes in /FluidDoc/docs/guides/model_convert/convert_from_pytorch

| dropout_p | dropout_p | `dropout` 的比例, 默认值为 0.00 即不进行正则化。 |
| is_causal | is_causal | 是否启用因果关系, 默认值为 `False` 即不启用。 |
| scale | - | 在softmax之前应用的缩放因子。默认与 Paddle 行为一致。Paddle 无此参数,暂无转写方式。 |
| - | training | 是否处于训练阶段, 默认值为 `True` 即处于训练阶段。Pytorch 无此参数,Paddle 需要按照是否处于训练阶段设置。 |
Copy link
Collaborator

@zhwesky2010 zhwesky2010 Sep 23, 2024

Choose a reason for hiding this comment

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

这个取决于torch如何设置,不看paddle怎么设置。

如果torch的行为等同于training=True,那就写paddle保持默认即可。如果torch的行为等同于training=False,那可能这两个API无法直接映射,需要看一下有没有更好的组合方式。

### [paddle.nn.Pad3D](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/nn/Pad3D_cn.html#pad3d)

```python
paddle.nn.Pad3D(padding, mode='constant', value=0.0, data_format='NCDHW', name=None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

mode应该是'circular'吧

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ---------------------------------------------------------------------------- |
| padding | padding | 填充大小。 |
| - | mode | `padding` 的四种模式。PyTorch 无此参数,Paddle 应设置为 `constant`。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Paddle应设置为'circular'吧


# Paddle 写法
module = paddle.nn.Softmax(axis=1)
module(-input)
Copy link
Collaborator

Choose a reason for hiding this comment

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

写成 -1 * input 吧,再加个注释强调一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor PaddlePaddle Hackathon 飞桨黑客松活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants