-
Notifications
You must be signed in to change notification settings - Fork 764
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.42】NO.42 为 Paddle 代码转换工具新增 API 转换规则(第 9 组)-part #6893
Conversation
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的Matcher和单测吧,用实际代码校验一遍
### [paddle.bitwise_left_shift](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/bitwise_left_shift_cn.html#bitwise-left-shift) | ||
|
||
```python | ||
paddle.bitwise_left_shift(x, y, is_arithmetic=True, out=None, name=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.
为啥不对应到 paddle.Tensor.bitwise_left_shift
?
类API尽可能对应类API,除非你确实没有再用其他替代
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.
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.bitwise_left_shift_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/bitwise_left_shift__cn.html#bitwise-left-shift) | ||
|
||
```python | ||
paddle.bitwise_left_shift_(x, y, is_arithmetic=True, out=None, name=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.
同上
### [paddle.bitwise_right_shift](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/bitwise_right_shift_cn.html#bitwise-right-shift) | ||
|
||
```python | ||
paddle.bitwise_right_shift(x, y, is_arithmetic=True, out=None, name=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.
同上
### [paddle.bitwise_right_shift_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/bitwise_right_shift__cn.html#bitwise-right-shift) | ||
|
||
```python | ||
paddle.bitwise_right_shift_(x, y, is_arithmetic=True, out=None, name=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.
同上
### [torch.Tensor.col_indices](https://pytorch.org/docs/stable/generated/torch.Tensor.col_indices.html) | ||
|
||
```python | ||
torch.Tensor.crow_indices() |
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签名对吗?
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.
复制快了,忘改了,抱歉
torch.Tensor.dim_order() | ||
``` | ||
|
||
获取张量在内存中的物理布局,PaddlePaddle 的 Tensor 默认是 contiguous 的, 因此可直接返回一个从0到 Tensor 的维度长度的列表即可。 |
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.
直接删除了,合理吗?
上面写直接删除,这里写的是组合替代实现,但又不给出组合的示例
这个文档很不合格
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.
我改成组合替代吧,这个抱歉,因为写的时候参考了is_continous的文档
### 转写示例 | ||
|
||
```python | ||
# torch 版本可以直接访问属性 |
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.
转写示例写简单点,核心一行就行,不用各种print、准备随机变量这些
### [paddle.Tensor.element_size](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#element-size) | ||
|
||
```python | ||
paddle.Tensor.element_size() |
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.
这两个数值验证了能对上吗
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.
|
||
```python | ||
# torch 版本 | ||
x = torch.rand(3) |
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.
示例简洁,而且看起来有bug
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.
这个我改一下
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------------------------------------------------------- | | ||
| - | sparse_dim | 在新的稀疏张量中包含的稀疏维度的数量,pytorch中无此参数,paddle令其为tensor维度长度即可。 | |
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保持默认,就可以吧
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.
sparse_dim他并没有默认值
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.
没有tensor维度长度这个说法,改成 输入维度
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.
提交reiview前先自查问题
y = a.nbytes | ||
|
||
# Paddle 写法 | ||
y = paddle.numel(a) * a.element_size() |
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.
这个返回的是一个Tensor吧,应该需要返回一个int
### [torch.Tensor.stride](https://pytorch.org/docs/stable/generated/torch.Tensor.stride.html#torch-tensor-stride) | ||
|
||
```python | ||
torch.Tensor.stride(dim) |
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.
这个备注下 dim=None
x.stride(dim) | ||
|
||
# Paddle 版本 | ||
x.get_strides() if dim is None else x.get_strides()[dim] |
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.
直接分行写吧,文档更注重可读性
if dim:
else:
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------------------------------------------------------- | | ||
| - | sparse_dim | 在新的稀疏张量中包含的稀疏维度的数量,pytorch 中无此参数,paddle 令其为 tensor 输入维度长度即可。 | |
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.
tensor输入维度
没有维度长度的说法,维度就是一个标量,标量没有长度。
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.
好的好的,已经都改了的
doc和 PaddlePaddle/PaConvert#490 已经全都跑通了,请review @zhwesky2010 |
y = a.nbytes | ||
|
||
# Paddle 写法 | ||
y = int(paddle.numel(a) * a.element_size()) |
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.
为啥不用 a.size * a.element_size()
,Tensor转来转去效率不更低吗
### [torch.Tensor.stride](https://pytorch.org/docs/stable/generated/torch.Tensor.stride.html#torch-tensor-stride) | ||
|
||
```python | ||
torch.Tensor.stride(dim) |
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.
torch.Tensor.stride(dim=None)
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------------------------------------------------- | | ||
| dim | - | 返回指定维度的步长,默认返回全部步长,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.
返回指定维度的步长,Pytorch为可选值,默认返回全部步长,此时无需转写,当有输入值时,需要转写。
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
No description provided.