Skip to content

device类文档更新 #7244

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

Merged
merged 16 commits into from
Apr 27, 2025
Merged

device类文档更新 #7244

merged 16 commits into from
Apr 27, 2025

Conversation

Xuxuanang
Copy link
Contributor

Copy link

paddle-bot bot commented Apr 8, 2025

感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7244.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.

自查一下:

关于单测中必须测 参数以变量形式传入 的要求,不用写在文档里。因为PaConvert是机器转代码,必须要覆盖任何情况,包括参数以变量形式传入的情况。
但文档是手工转代码,只需要给出思路,为方便阅读,不需要这么机械的复制PaConvert。

PaConvert与文档的对齐一致 指的是思路对齐而不是字符串的对齐。写的时候需要看用户怎么阅读最简便。例如文档需要写device=0、'cuda'两种用法,但不需要 写0直接传、0通过变量传、0是否指定关键字来传 这三种写法,因为前者是本质不同的用法,后者只是写法的改变,无需冗余赘叙。

@Xuxuanang
Copy link
Contributor Author

自查一下:

关于单测中必须测 参数以变量形式传入 的要求,不用写在文档里。因为PaConvert是机器转代码,必须要覆盖任何情况,包括参数以变量形式传入的情况。 但文档是手工转代码,只需要给出思路,为方便阅读,不需要这么机械的复制PaConvert。

PaConvert与文档的对齐一致 指的是思路对齐而不是字符串的对齐。写的时候需要看用户怎么阅读最简便。例如文档需要写device=0、'cuda'两种用法,但不需要 写0直接传、0通过变量传、0是否指定关键字来传 这三种写法,因为前者是本质不同的用法,后者只是写法的改变,无需冗余赘叙。

已经将冗余叙述全部修改

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.

有些参数可以不传入device,这种情况下,paddle也是不传入吗


```python
# PyTorch 写法
torch.cuda.get_device_properties('cuda:0')
Copy link
Collaborator

Choose a reason for hiding this comment

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

device为空的情况需要转写吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个api device不能为空

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| device | device | 表示希望获取 stream 的设备或者设备 ID。如果为 None,则为当前的设备。默认值为 None。 |
| device | device | 表示希望获取 stream 的设备或者设备 ID。如果为 None,则为当前的设备。默认值为 None,需要转写。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

device为空的情况需要转写吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

device为空的情况不需要转写

high_priority = -1
default_priority = 0
y = torch.cuda.Stream(priority=default_priority)
y = torch.cuda.Stream(priority=0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

device为空的情况需要转写吗

Copy link
Contributor Author

Choose a reason for hiding this comment

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

device为空的情况不需要转写

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.

device=None 直接写成参数为空的形式吧,一般不会有显式设置为None的情况

@zhwesky2010
Copy link
Collaborator

@Xuxuanang CI可能有点不稳定,rerun下就行

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.

device=None 这个你是不是没有改完,你再检查下

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.

LGTM

@zhwesky2010 zhwesky2010 merged commit cb783bb into PaddlePaddle:develop Apr 27, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants