Skip to content

Commit

Permalink
fix api difference doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwesky2010 committed Jun 27, 2023
1 parent aaf1fc8 commit 3866013
Show file tree
Hide file tree
Showing 46 changed files with 156 additions and 361 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [仅paddle参数更多]torch.Tensor.maximum
## [ 仅参数名不同 ] torch.Tensor.maximum

### [torch.Tensor.maximum](https://pytorch.org/docs/stable/generated/torch.Tensor.maximum.html#torch.Tensor.maximum)

Expand All @@ -9,12 +9,11 @@ torch.Tensor.maximum(other)
### [paddle.Tensor.maximum](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#maximum-y-axis-1-name-none)

```python
paddle.Tensor.maximum(y, axis=-1, name=None)
paddle.Tensor.maximum(y)
```

其中 Paddle 相比 Pytorch 支持更多其他参数,具体如下:
两者功能一致且参数用法一致,仅参数名不同,具体如下:

| PyTorch | PaddlePaddle | 备注 |
|----------------------------------|---------------------------------|------------------------------------|
| <font color='red'> other </font> | <font color='red'> y </font> | 输⼊ Tensor ,仅名称不同。 |
| <font color='red'> - </font> | <font color='red'> axis </font> | 指定进行运算的轴,Pytorch无此参数,Paddle保持默认即可。 |
| other | y | 输⼊第二个 Tensor ,仅参数名不同。 |
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [torch 参数更多]torch.Tensor.mean
## [ torch 参数更多 ]torch.Tensor.mean

### [torch.Tensor.mean](https://pytorch.org/docs/stable/generated/torch.Tensor.mean.html#torch.Tensor.mean)

Expand All @@ -17,4 +17,4 @@ paddle.Tensor.mean(axis=None, keepdim=False, name=None)
|-----------------------|------------------------------------|----------------------------------------|
| <font> dim </font> | <font> axis </font> | 指定进行运算的轴,仅参数名不同。 |
| <font> keepdim </font> | <font> keepdim </font> | 是否在输出 Tensor 中保留减小的维度。 |
| <font color='red'> dtpye </font> | <font color='red'> - </font> | 表示输出Tensor的数据类型,一般对训练影响不大,可直接删去 |
| <font color='red'> dtpye </font> | <font color='red'> - </font> | 表示输出 Tensor 的数据类型,一般对训练影响不大,可直接删去 |

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [paddle 参数更多]torch.Tensor.minimum
## [ paddle 参数更多 ]torch.Tensor.minimum

### [torch.Tnsor.,minimum](https://pytorch.org/docs/stable/generated/torch.Tensor.minimum.html)

Expand All @@ -9,12 +9,12 @@ torch.Tensor.maximum(other)
### [paddle.Tensor.minimum](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#minimum-y-axis-1-name-none)

```python
paddle.Tensor.minimum(y, axis=-1, name=None)
paddle.Tensor.minimum(y)
```

其中 Paddle 相比 Pytorch 支持更多其他参数,具体如下:
两者功能一致且参数用法一致,仅参数名不同,具体如下:

| PyTorch | PaddlePaddle | 备注 |
|----------------------------------|---------------------------------|------------------------------------|
| <font color='red'> other </font> | <font color='red'> y </font> | 输⼊ Tensor ,仅名称不同。 |
| <font color='red'> - </font> | <font color='red'> axis </font> | 指定进行运算的轴,Pytorch无此参数,Paddle保持默认即可|
| <font color='red'> - </font> | <font color='red'> axis </font> | 指定进行运算的轴,Pytorch 无此参数,Paddle 保持默认即可|
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [仅参数名完全一致]torch.Tensor.mm
## [ 参数完全一致 ]torch.Tensor.mm

### [torch.Tensor.mm](https://pytorch.org/docs/stable/generated/torch.Tensor.mm.html)

Expand All @@ -9,7 +9,7 @@ torch.Tensor.mm(mat2)
### [paddle.Tensor.mm](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#mm-mat2-name-none)

```python
paddle.Tensor.mm(mat2,name=None)
paddle.Tensor.mm(mat2, name=None)
```

两者功能一致且参数用法一致,具体如下:
Expand All @@ -18,4 +18,4 @@ paddle.Tensor.mm(mat2,name=None)

| PyTorch | PaddlePaddle | 备注 |
|---------------------------------|---------------------------------| ----------------------------------------- |
| <font> mat2 </font> | <font> mat2 </font> | 输⼊ Tensor 。 |
| <font> mat2 </font> | <font> mat2 </font> | 输⼊ Tensor 。 |

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## [参数完全一致]torch.Tensor.moveaxis
## [ 参数完全一致 ]torch.Tensor.moveaxis

### [torch.Tensor.moveaxis](https://pytorch.org/docs/stable/generated/torch.Tensor.moveaxis.html)

```python
torch.Tensor.moveaxis(source, destination)
torch.Tensor.moveaxis(source, destination)
```

### [paddle.Tensor.moveaxis](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/moveaxis_cn.html)

```python
paddle.Tensor.moveaxis(source, destination,name = None)
paddle.Tensor.moveaxis(source, destination,name = None)
```

两者功能一致且参数用法一致,具体如下:

| PyTorch | PaddlePaddle | 备注 |
|------------------------------------|------------------------------------|----------------------------------|
| <font> source </font> | <font> source </font> | 将被移动的轴的位置。 |
| <font> destination </font> | <font> destination </font> | 轴被移动后的目标位置。 |
| <font> destination </font> | <font> destination </font> | 轴被移动后的目标位置。 |
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
## [参数完全一致]torch.Tensor.movedim
## [ 参数完全一致 ]torch.Tensor.movedim

### [torch.Tensor.movedim](https://pytorch.org/docs/stable/generated/torch.Tensor.movedim.html)

```python
torch.Tensor.movedim(source, destination)
torch.Tensor.movedim(source, destination)
```

### [paddle.Tensor.moveaxis](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/moveaxis_cn.html)

```python
paddle.Tensor.moveaxis(source, destination,name = None)
paddle.Tensor.moveaxis(source, destination,name = None)
```

两者功能一致且参数用法一致,具体如下:

| PyTorch | PaddlePaddle | 备注 |
|------------------------------------|------------------------------------|----------------------------------|
| <font> source </font> | <font> source </font> | 将被移动的轴的位置。 |
| <font> destination </font> | <font> destination </font> | 轴被移动后的目标位置。 |
| <font> destination </font> | <font> destination </font> | 轴被移动后的目标位置。 |

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [参数不一致]torch.Tensor.permute
## [ 参数不一致 ]torch.Tensor.permute

### [torch.Tensor.permute](https://pytorch.org/docs/1.13/generated/torch.Tensor.permute.html)

Expand All @@ -12,18 +12,18 @@ torch.Tensor.permute(*dims)
paddle.Tensor.transpose(perm, name=None)
```

Pytorch 的 `dims` paddle 的 `perm` 两者部分参数用法不同,具体如下:
Pytorch 的 `*dims` 相比于 paddle 的 `perm` 额外支持可变参数的用法,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| *dims | perm | torch 支持可变参数或 list/tuple,paddle 仅支持 list/tuple,参数用法不一致,需要进行转写。 |
| *dims | perm | torch 支持可变参数或 list/tuple,paddle 仅支持 list/tuple。对于可变参数的用法,需要进行转写。 |

### 转写示例
#### *dim: Tensor 的维度序列,可变参数用法
#### *dims: 可变参数用法
```python
# pytorch
x = torch.randn(2, 3, 5)
y = x.permute(2,0,1)
y = x.permute(2, 0, 1)

# paddle
x = paddle.randn([2, 3, 5])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [参数不一致]torch.Tensor.repeat
## [ 参数不一致 ]torch.Tensor.repeat

### [torch.Tensor.repeat](https://pytorch.org/docs/1.13/generated/torch.Tensor.repeat.html)

Expand All @@ -12,20 +12,20 @@ torch.Tensor.repeat(*sizes)
paddle.Tensor.tile(repeat_times, name=None)
```

Pytorch 的 `sizes` 参数与 Paddle 的 `repeat_times` 参数用法不同,具体如下:
Pytorch 的 `*sizes` 相比于 Paddle 的 `repeat_times` 额外支持可变参数的用法,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| *sizes | repeat_times | torch 支持可变参数或 list/tuple,paddle 仅支持 list/tuple/Tensor,参数用法不一致,需要进行转写。|
| *sizes | repeat_times | torch 支持可变参数或 list/tuple,paddle 仅支持 list/tuple。对于可变参数的用法,需要进行转写。 |

### 转写示例
#### *sizes: 各个维度重复的次数,可变参数用法
```python
# pytorch
x = torch.randn(2, 3, 5)
y = x.repeat(4,2,1)
y = x.repeat(4, 2, 1)

# paddle
x = paddle.randn([2, 3, 5])
y = x.tile((4,2,1))
y = x.tile((4, 2, 1))
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [参数不一致]torch.Tensor.reshape
## [ 参数不一致 ]torch.Tensor.reshape

### [torch.Tensor.reshape](https://pytorch.org/docs/1.13/generated/torch.Tensor.reshape.html)

Expand All @@ -12,20 +12,20 @@ torch.Tensor.reshape(*shape)
paddle.Tensor.reshape(shape, name=None)
```

Pytorch 的 `*shape` 参数与 Paddle 的 `shape` 参数用法不同,具体如下:
Pytorch 的 `*shape` 相比于 Paddle 的 `shape` 额外支持可变参数的用法,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| *shape | shape | torch *shape 既可以接收 list 也可接收可变参数。需要转写。|
| *shape | shape | torch 支持可变参数或 list/tuple,paddle 仅支持 list/tuple。对于可变参数的用法,需要进行转写。 |

### 转写示例
#### *shape: 新数组的维度序列,可变参数用法
```python
# pytorch
x = torch.randn(2, 3, 5)
y = x.reshape(6,5)
y = x.reshape(6, 5)

# paddle
x = paddle.randn([2, 3, 5])
y = x.tile((6,5))
y = x.reshape((6, 5))
```

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [组合替代实现]torch.Tensor.scatter_add
## [ 组合替代实现 ]torch.Tensor.scatter_add

### [torch.Tensor.scatter_add](https://pytorch.org/docs/1.13/generated/torch.Tensor.scatter_add.html#torch.Tensor.scatter_add)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [仅 paddle 参数更多]torch.Tensor.scatter_add_
## [ 仅 paddle 参数更多 ]torch.Tensor.scatter_add_

### [torch.Tensor.scatter_add_](https://pytorch.org/docs/1.13/generated/torch.Tensor.scatter_add_.html#torch.Tensor.scatter_add_)

Expand All @@ -25,4 +25,4 @@ paddle.Tensor.put_along_axis_(indices,
| dim | axis | 表示在哪一个维度 scatter ,仅参数名不一致。 |
| index | indices | 表示输入的索引张量,仅参数名不一致。 |
| src | values | 表示需要插入的值,仅参数名不一致。 |
| - | reduce | 表示对输出 Tensor 的计算方式, PyTorch 无此参数, Paddle 应设置为 add 。 |
| - | reduce | 表示对输出 Tensor 的计算方式, PyTorch 无此参数, Paddle 应设置为 'add'|
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [参数不一致]torch.Tensor.split
## [ 参数不一致 ]torch.Tensor.split

### [torch.Tensor.split](https://pytorch.org/docs/1.13/generated/torch.Tensor.split.html)

Expand All @@ -17,10 +17,10 @@ Pytorch 的 `split_size_or_sections` 与 Paddle 的 `num_or_sections` 用法不
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| dim | axis | 表示需要分割的维度,仅参数名不同。 |
| split_size_or_sections | num_or_sections | torch 的 split_size_or_sections :int 时表示块的大小, list 时表示块的大小; paddle 的 num_or_sections : int 时表示块的个数, list 时表示块的大小。参数类型为 int 时需要转写|
| split_size_or_sections | num_or_sections | torch:int 时表示块的大小, list 时表示块的大小; paddle: int 时表示块的个数, list 时表示块的大小。对于 int 时用法不同,需要转写|

### 转写示例
#### split_size_or_sections: 参数类型为 int 时表示块的大小
#### split_size_or_sections: int 时表示块的大小,而 paddle 表示块的个数
```python
# pytorch
x = torch.randn(8, 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## [参数不一致]torch.Tensor.transpose
## [ 参数不一致 ]torch.Tensor.transpose

### [torch.Tensor.transpose](https://pytorch.org/docs/1.13/generated/torch.Tensor.transpose.html)

Expand All @@ -23,7 +23,7 @@ Pytorch 的 `dim0, dim1` 与 Paddle 的 `perm` 用法不同,具体如下:
```python
# pytorch
x = torch.randn(2, 3, 5)
y = x.transpose(0,1)
y = x.transpose(0, 1)

# paddle
x = paddle.randn([2, 3, 5])
Expand Down
Loading

0 comments on commit 3866013

Please sign in to comment.