-
Notifications
You must be signed in to change notification settings - Fork 822
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
device类文档更新 #7244
Conversation
Xuxuanang
commented
Apr 8, 2025
- 增强device类的转换规则,增强转换适配灵活性 PaConvert#570
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7244.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
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.
自查一下:
关于单测中必须测 参数以变量形式传入 的要求,不用写在文档里。因为PaConvert是机器转代码,必须要覆盖任何情况,包括参数以变量形式传入的情况。
但文档是手工转代码,只需要给出思路,为方便阅读,不需要这么机械的复制PaConvert。
PaConvert与文档的对齐一致 指的是思路对齐,而不是字符串的对齐。写的时候需要看用户怎么阅读最简便。例如文档需要写device=0、'cuda'
两种用法,但不需要 写0直接传、0通过变量传、0是否指定关键字来传
这三种写法,因为前者是本质不同的用法,后者只是写法的改变,无需冗余赘叙。
docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cuda.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cuda.md
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cuda.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.Stream__upper.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.
有些参数可以不传入device,这种情况下,paddle也是不传入吗
docs/guides/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.Stream__upper.md
Outdated
Show resolved
Hide resolved
|
||
```python | ||
# PyTorch 写法 | ||
torch.cuda.get_device_properties('cuda:0') |
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.
device为空的情况需要转写吗
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 device不能为空
### 参数映射 | ||
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| device | device | 表示希望获取 stream 的设备或者设备 ID。如果为 None,则为当前的设备。默认值为 None。 | | ||
| device | device | 表示希望获取 stream 的设备或者设备 ID。如果为 None,则为当前的设备。默认值为 None,需要转写。 | |
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.
device为空的情况需要转写吗
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.
device为空的情况不需要转写
high_priority = -1 | ||
default_priority = 0 | ||
y = torch.cuda.Stream(priority=default_priority) | ||
y = torch.cuda.Stream(priority=0) |
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.
device为空的情况需要转写吗
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.
device为空的情况不需要转写
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.Size.numel.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.device.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.
device=None 直接写成参数为空的形式吧,一般不会有显式设置为None的情况
docs/guides/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.current_stream.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.current_stream.md
Outdated
Show resolved
Hide resolved
@Xuxuanang CI可能有点不稳定,rerun下就行 |
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.
device=None 这个你是不是没有改完,你再检查下
docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.size.md
Outdated
Show resolved
Hide resolved
...s/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.get_device_properties.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.device.md
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cuda.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.synchronize.md
Outdated
Show resolved
Hide resolved
...s/model_convert/convert_from_pytorch/api_difference/cuda/torch.cuda.get_device_properties.md
Outdated
Show resolved
Hide resolved
docs/guides/model_convert/convert_from_pytorch/api_difference/torch/torch.set_default_device.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