From 52028bc8aab6f4c3545f700d58ce7b890cb22d82 Mon Sep 17 00:00:00 2001
From: Li-fAngyU <972117977@qq.com>
Date: Tue, 26 Sep 2023 11:26:10 +0800
Subject: [PATCH 1/7] Hackthon5 No 42. paddle/docs first commit.
---
.../convert_from_pytorch/pytorch_api_mapping_cn.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md
index 70df36f9755..15f9daac58c 100644
--- a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md
+++ b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md
@@ -917,7 +917,9 @@
| 300 | [torch.ShortTensor](https://pytorch.org/docs/stable/tensors.html) |[paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor)| 仅 paddle 参数更多 , [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.ShortTensor.md)|
| 301 | [torch.Tensor.copysign](https://pytorch.org/docs/1.13/generated/torch.Tensor.copysign.html?highlight=torch+tensor+copysign#torch.Tensor.copysign) | | 功能缺失 |
| 302 | [torch.Tensor.dequantize](https://pytorch.org/docs/1.13/generated/torch.Tensor.dequantize.html?highlight=torch+tensor+dequantize#torch.Tensor.dequantize) | | 功能缺失 |
-
+| 303 | [torch.Tensor.is_pinned](https://pytorch.org/docs/stable/generated/torch.Tensor.is_pinned.html?highlight=is_pinned#torch.Tensor.is_pinned) | | 功能缺失 |
+| 304 | [torch.Tensor.sum_to_size](https://pytorch.org/docs/stable/generated/torch.Tensor.sum_to_size.html?highlight=sum_to_size#torch.Tensor.sum_to_size) | | 功能缺失 |
+| 305 | [torch.Tensor.resize_](https://pytorch.org/docs/stable/generated/torch.Tensor.resize_.html?highlight=resize#torch.Tensor.resize_) | | 功能缺失 |
***持续更新...***
## torch.nn.init.XX API 映射列表
From e46bf1ff12de9365ddd4d0004b914c246f43bdf9 Mon Sep 17 00:00:00 2001
From: Li-fAngyU <972117977@qq.com>
Date: Tue, 26 Sep 2023 11:27:36 +0800
Subject: [PATCH 2/7] first commit.
---
.../Tensor/torch.Tensor.as_strided.md | 25 +++++++++++
.../Tensor/torch.Tensor.cummax.md | 22 +++++++++
.../Tensor/torch.Tensor.cummin.md | 22 +++++++++
.../api_difference/Tensor/torch.Tensor.i0.md | 15 +++++++
.../Tensor/torch.Tensor.index_put.md | 22 +++++++++
.../Tensor/torch.Tensor.sum_to_size.md | 0
.../Tensor/torch.Tensor.unfold.md | 28 ++++++++++++
.../Tensor/torch.Tensor.view.md | 21 +++++++++
.../Tensor/torch.Tensor.view_as.md | 21 +++++++++
.../api_difference/ops/torch.as_strided.md | 28 ++++++++++++
.../api_difference/ops/torch.clamp_max.md | 38 ++++++++++++++++
.../api_difference/ops/torch.cummax.md | 40 +++++++++++++++++
.../api_difference/ops/torch.nanquantile.md | 45 +++++++++++++++++++
13 files changed, 327 insertions(+)
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.i0.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.sum_to_size.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.clamp_max.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cummax.md
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md
new file mode 100644
index 00000000000..c92d68cc642
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md
@@ -0,0 +1,25 @@
+## [ 仅参数名不一致 ]torch.Tensor.as_strided
+### [torch.Tensor.as_strided](https://pytorch.org/docs/stable/generated/torch.Tensor.as_strided.html?highlight=as_strided#torch.Tensor.as_strided)
+
+```python
+torch.Tensor.as_strided(size,
+ stride,
+ storage_offset=None)
+```
+
+### [paddle.Tensor.as_strided](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#as-strided-x-shape-stride-offset-0-name-none)
+
+```python
+paddle.Tensor.as_strided(shape,
+ stride,
+ offset=0,
+ name=None)
+```
+
+两者功能一致,仅参数名不一致,具体如下:
+### 参数映射
+| PyTorch | PaddlePaddle | 备注 |
+| ------------- | ------------ | ------------------------------------------------------ |
+| size | shape | 表示输出 Tensor 的维度。 |
+| stride | stride | 表示输出 Tensor 的 stride。 |
+| storage_offset | offset | 表示偏移量 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md
new file mode 100644
index 00000000000..3400fac2abe
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md
@@ -0,0 +1,22 @@
+## [ 仅参数名不一致 ]torch.Tensor.cummax
+
+### [torch.Tensor.cummax](https://pytorch.org/docs/stable/generated/torch.Tensor.cummax.html?highlight=cummax#torch.Tensor.cummax)
+
+```python
+torch.Tensor.cummax(dim, dtype=None)
+```
+
+### [paddle.Tensor.cummax](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/cummax_cn.html)
+
+```python
+paddle.Tensor.cummax(axis=None, dtype=None, name=None)
+```
+
+两者功能一致且参数用法一致,仅参数名不一致,具体如下:
+
+### 参数映射
+
+| PyTorch | PaddlePaddle | 备注 |
+| ------- | ------------ | ------------------------------ |
+| dim | axis | 需要累加的维度,仅参数名不一致。 |
+| dtype | dtype | 输出 Tensor 的数据类型。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md
new file mode 100644
index 00000000000..7c9a630f966
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md
@@ -0,0 +1,22 @@
+## [ 仅参数名不一致 ]torch.Tensor.cummin
+
+### [torch.Tensor.cummin](https://pytorch.org/docs/stable/generated/torch.Tensor.cummin.html?highlight=cummin#torch.Tensor.cummin)
+
+```python
+torch.Tensor.cummin(dim, dtype=None)
+```
+
+### [paddle.Tensor.cummin](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/cummin_cn.html#cummin)
+
+```python
+paddle.Tensor.cummin(axis=None, dtype=None, name=None)
+```
+
+两者功能一致且参数用法一致,仅参数名不一致,具体如下:
+
+### 参数映射
+
+| PyTorch | PaddlePaddle | 备注 |
+| ------- | ------------ | ------------------------------ |
+| dim | axis | 需要累加的维度,仅参数名不一致。 |
+| dtype | dtype | 输出 Tensor 的数据类型。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.i0.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.i0.md
new file mode 100644
index 00000000000..0f9b8498da4
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.i0.md
@@ -0,0 +1,15 @@
+## [ 无参数 ]torch.Tensor.i0
+
+### [torch.Tensor.i0](https://pytorch.org/docs/stable/generated/torch.Tensor.i0.html?highlight=i0#torch.Tensor.i0)
+
+```python
+torch.Tensor.i0()
+```
+
+### [paddle.Tensor.i0](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#i0-x-name-none)
+
+```python
+paddle.Tensor.i0(name=None)
+```
+
+两者功能一致,无参数。
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md
new file mode 100644
index 00000000000..83438f16a2d
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md
@@ -0,0 +1,22 @@
+## [ 仅参数名不一致 ]torch.Tensor.index_put
+### [torch.Tensor.index_put](https://pytorch.org/docs/stable/generated/torch.Tensor.index_put.html?highlight=index_put#torch.Tensor.index_put)
+
+```python
+torch.Tensor.index_put(indices, values, accumulate=False)
+```
+
+### [paddle.Tensor.index_put](https://pytorch.org/docs/stable/generated/torch.Tensor.index_put.html?highlight=index_put#torch.Tensor.index_put)
+
+```python
+paddle.Tensor.index_put(indices, value, accumulate=False, name=None)
+```
+
+两者功能一致且参数用法一致,仅参数名不一致,具体如下:
+
+### 参数映射
+
+| PyTorch | PaddlePaddle | 备注 |
+| ------------- | ------------ | ------------------------------------------------------ |
+| indices | indices | 包含用来索引的 tensors 的元组。数据类型为 int32,int64,bool。 |
+| values | value | 用来给 x 赋值的 Tensor,仅参数名不一致。 |
+| accumulate | accumulate | 指定是否将 value 加到 x 的参数。 默认值为 False。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.sum_to_size.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.sum_to_size.md
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md
new file mode 100644
index 00000000000..ff94e4bf041
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md
@@ -0,0 +1,28 @@
+## [ 参数名不一致 ]torch.Tensor.unfold
+
+### [torch.Tensor.unfold](https://pytorch.org/docs/stable/generated/torch.Tensor.unfold.html?highlight=unfold#torch.Tensor.unfold)
+
+```python
+torch.Tensor.unfold(dimension,
+ size,
+ step)
+```
+
+### [paddle.Tensor.unfold](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#unfold-x-axis-size-step-name-none)
+
+```python
+paddle.Tensor.unfold(axis,
+ size,
+ step,
+ name=None)
+```
+
+Paddle 相比 PyTorch 支持更多其他参数,具体如下:
+
+### 参数映射
+
+| PyTorch | PaddlePaddle | 备注 |
+| ------- | :----------: | :----------------------------------------------------------: |
+| dimension | axis | 表示需要提取的维度,仅参数名不一致。 |
+| size | size | 表示需要提取的窗口长度。 |
+| step | step | 表示每次提取跳跃的步长。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
new file mode 100644
index 00000000000..b41e59b8461
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
@@ -0,0 +1,21 @@
+## [ 参数不一致 ]torch.Tensor.view
+
+### [torch.Tensor.view](https://pytorch.org/docs/stable/generated/torch.Tensor.view.html?highlight=view#torch.Tensor.view)
+
+```python
+torch.Tensor.view(*shape)
+```
+
+### [paddle.Tensor.view](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#view-x-shape-or-dtype-name-none)
+
+```python
+paddle.Tensor.view(shape_or_dtype, name=None)
+```
+
+两者功能一致, 但 pytorch 的 `*shape` 和 paddle 的 `shape_or_dtype` 参数用法不一致,具体如下:
+
+### 参数映射
+
+| PyTorch | PaddlePaddle | 备注 |
+| ------- | ------------ | ------------------------------ |
+| *shape | shape_or_dtype | 指定的维度。 Pytorch 参数 shape 既可以是可变参数,也可以是 list/tuple/torch.Size/dtype 的形式, Paddle 参数 shape_or_dtype 为 list/tuple/dtype 的形式。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md
new file mode 100644
index 00000000000..747acda2548
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md
@@ -0,0 +1,21 @@
+## [ 参数完全一致 ]torch.Tensor.view_as
+
+### [torch.Tensor.view](https://pytorch.org/docs/stable/generated/torch.Tensor.view_as.html?highlight=view_as#torch.Tensor.view_as)
+
+```python
+torch.Tensor.view_as(other)
+```
+
+### [paddle.Tensor.view](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#view-as-x-other-name-none)
+
+```python
+paddle.Tensor.view_as(other, name=None)
+```
+
+功能一致,参数完全一致,具体如下:
+
+### 参数映射
+
+| PyTorch | PaddlePaddle | 备注 |
+| ------- | ------------ | ------------------------------ |
+| other | other | 与返回 Tensor shape 相同的 Tensor |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
new file mode 100644
index 00000000000..ce7e904b4c4
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
@@ -0,0 +1,28 @@
+## [ 仅参数名不一致 ]torch.as_strided
+### [torch.as_strided](https://pytorch.org/docs/stable/generated/torch.as_strided.html?highlight=as_strided#torch.as_strided)
+
+```python
+torch.as_strided(input,
+ size,
+ stride,
+ storage_offset=None)
+```
+
+### [paddle.as_strided](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/as_strided_cn.html#as-strided)
+
+```python
+paddle.as_strided(x,
+ shape,
+ stride,
+ offset=0,
+ name=None)
+```
+
+两者功能一致,仅参数名不一致,具体如下:
+### 参数映射
+| PyTorch | PaddlePaddle | 备注 |
+| ------------- | ------------ | ------------------------------------------------------ |
+| input | x | 表示输入的 Tensor 。 |
+| size | shape | 表示输出 Tensor 的维度。 |
+| stride | stride | 表示输出 Tensor 的 stride。 |
+| storage_offset | offset | 表示偏移量 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.clamp_max.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.clamp_max.md
new file mode 100644
index 00000000000..ed8f940dc1b
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.clamp_max.md
@@ -0,0 +1,38 @@
+## [ torch 参数更多 ]torch.clamp_max
+### [torch.clamp_max]()
+
+```python
+torch.clamp_max(input,
+ max=None,
+ *,
+ out=None)
+```
+
+### [paddle.clip](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/clip_cn.html#clip)
+
+```python
+paddle.clip(x,
+ min=None,
+ max=None,
+ name=None)
+```
+
+Pytorch 相比 Paddle 支持更多其他参数,具体如下:
+### 参数映射
+| PyTorch | PaddlePaddle | 备注 |
+| ------------- | ------------ | ------------------------------------------------------ |
+| input | x | 表示输入的 Tensor ,仅参数名不一致。 |
+| - | min | 表示裁剪的最小值。Pytorch 无此参数, Paddle 保持默认即可。 |
+| max | max | 表示裁剪的最大值。 |
+| out | - | 表示输出的 Tensor , Paddle 无此参数,需要转写。 |
+
+
+### 转写示例
+#### out:指定输出
+```python
+# Pytorch 写法
+torch.clamp_max(input, max=0.5, out=y)
+
+# Paddle 写法
+paddle.assign(paddle.clip(input, max=0.5), y)
+```
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cummax.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cummax.md
new file mode 100644
index 00000000000..b51e2070b44
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cummax.md
@@ -0,0 +1,40 @@
+## [ torch 参数更多 ]torch.cummax
+
+### [torch.cummax](https://pytorch.org/docs/stable/generated/torch.cummax.html?highlight=cummax#torch.cummax)
+
+```python
+torch.cummax(input,
+ dim,
+ *,
+ out=None)
+```
+
+### [paddle.cummax](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/cummax_cn.html#cummax)
+
+```python
+paddle.cummax(x,
+ axis=None,
+ dtype='int64',
+ name=None)
+```
+
+两者功能一致,torch 参数更多,具体如下:
+
+### 参数映射
+| PyTorch | PaddlePaddle | 备注 |
+| ------------- | ------------ | ------------------------------------------------------ |
+| input | x | 表示输入的 Tensor,仅参数名不一致。 |
+| dim | axis | 用于指定 index 获取输入的维度,仅参数名不一致。 |
+| - | dtype | 指定输出索引的数据格式,PyTorch 无此参数,Paddle 保持默认即可。 |
+| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 |
+
+### 转写示例
+#### out:指定输出
+
+```python
+# Pytorch 写法
+torch.cummax(x,1, out=(values, indices))
+
+# Paddle 写法
+paddle.assign(paddle.cummax(x,1), (values, indices))
+```
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md
new file mode 100644
index 00000000000..1e8d3e82e2c
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md
@@ -0,0 +1,45 @@
+## [ torch 参数更多 ]torch.nanquantile
+
+### [torch.nanquantile](https://pytorch.org/docs/stable/generated/torch.nanquantile.html?highlight=nanquantile#torch.nanquantile)
+
+```python
+torch.nanquantile(input,
+ q,
+ dim=None,
+ keepdim=False,
+ *,
+ interpolation='linear',
+ out=None)
+```
+
+### [paddle.nanquantile]()
+
+```python
+paddle.nanquantile(x,
+ q,
+ axis=None,
+ keepdim=False,
+ name=None)
+```
+
+Pytorch 相比 Paddle 支持更多其他参数,具体如下:
+### 参数映射
+| PyTorch | PaddlePaddle | 备注 |
+| ------------- | ------------ | ------------------------------------------------------ |
+| input | x | 表示输入的 Tensor,仅参数名不一致。 |
+| q | q | 待计算的分位数。 |
+| dim | axis| 指定对 x 进行计算的轴,仅参数名不一致。 |
+|keepdim|keepdim| 是否在输出 Tensor 中保留减小的维度。|
+|interpolation| - | 当所需分位数位于两个数据点之间时使用的插值方法,Paddle 无此参数,需要转写,Paddle 暂无转写方式。|
+| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 |
+
+
+### 转写示例
+#### out:指定输出
+```python
+# Pytorch 写法
+torch.nanquantile(torch.tensor([float('nan'), 1., 2., 3.]), 0.6, interpolation='linear', out=y)
+
+# Paddle 写法
+paddle.assign(paddle.nanquantile(paddle.to_tensor([float('nan'), 1., 2., 3.]), 0.6), y)
+```
From 1b437f14cec0ccfcc65894e29c6dda7ec716e39c Mon Sep 17 00:00:00 2001
From: Li-fAngyU <972117977@qq.com>
Date: Tue, 26 Sep 2023 18:12:10 +0800
Subject: [PATCH 3/7] remove empty file
---
.../api_difference/Tensor/torch.Tensor.sum_to_size.md | 0
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.sum_to_size.md
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.sum_to_size.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.sum_to_size.md
deleted file mode 100644
index e69de29bb2d..00000000000
From f61679a412bbdb323faf3fa9eee16bdc7e1d0faa Mon Sep 17 00:00:00 2001
From: Li-fAngyU <972117977@qq.com>
Date: Tue, 26 Sep 2023 23:14:14 +0800
Subject: [PATCH 4/7] fix torch.Tensor.cummin.md torch.Tensor.cummax.md.
---
.../api_difference/Tensor/torch.Tensor.cummax.md | 10 +++++-----
.../api_difference/Tensor/torch.Tensor.cummin.md | 10 +++++-----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md
index 3400fac2abe..cc6d2596d4e 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummax.md
@@ -1,22 +1,22 @@
-## [ 仅参数名不一致 ]torch.Tensor.cummax
+## [ 仅 paddle 参数更多 ]torch.Tensor.cummax
### [torch.Tensor.cummax](https://pytorch.org/docs/stable/generated/torch.Tensor.cummax.html?highlight=cummax#torch.Tensor.cummax)
```python
-torch.Tensor.cummax(dim, dtype=None)
+torch.Tensor.cummax(dim)
```
-### [paddle.Tensor.cummax](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/cummax_cn.html)
+### [paddle.Tensor.cummax](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#cummax-x-axis-none-dtype-int64-name-none)
```python
paddle.Tensor.cummax(axis=None, dtype=None, name=None)
```
-两者功能一致且参数用法一致,仅参数名不一致,具体如下:
+两者功能一致,其中 Paddle 相比 PyTorch 支持更多其他参数,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------ |
| dim | axis | 需要累加的维度,仅参数名不一致。 |
-| dtype | dtype | 输出 Tensor 的数据类型。 |
+| - | dtype | 输出 Tensor 的数据类型。PyTorch 无此参数, Paddle 保持默认即可。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md
index 7c9a630f966..c60aa4e25bb 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.cummin.md
@@ -1,22 +1,22 @@
-## [ 仅参数名不一致 ]torch.Tensor.cummin
+## [ 仅 paddle 参数更多 ]torch.Tensor.cummin
### [torch.Tensor.cummin](https://pytorch.org/docs/stable/generated/torch.Tensor.cummin.html?highlight=cummin#torch.Tensor.cummin)
```python
-torch.Tensor.cummin(dim, dtype=None)
+torch.Tensor.cummin(dim)
```
-### [paddle.Tensor.cummin](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/cummin_cn.html#cummin)
+### [paddle.Tensor.cummin](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#cummin-x-axis-none-dtype-int64-name-none)
```python
paddle.Tensor.cummin(axis=None, dtype=None, name=None)
```
-两者功能一致且参数用法一致,仅参数名不一致,具体如下:
+两者功能一致,其中 Paddle 相比 PyTorch 支持更多其他参数,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------ |
| dim | axis | 需要累加的维度,仅参数名不一致。 |
-| dtype | dtype | 输出 Tensor 的数据类型。 |
+| - | dtype | 输出 Tensor 的数据类型。PyTorch 无此参数, Paddle 保持默认即可。 |
From aab37c23a5e1b106e434472603e8aba7dc40253b Mon Sep 17 00:00:00 2001
From: Li-fAngyU <972117977@qq.com>
Date: Wed, 11 Oct 2023 21:47:03 +0800
Subject: [PATCH 5/7] update
---
.../Tensor/torch.Tensor.index_put.md | 6 +++---
.../api_difference/Tensor/torch.Tensor.unfold.md | 4 ++--
.../api_difference/Tensor/torch.Tensor.view.md | 15 ++++++++++++++-
.../api_difference/Tensor/torch.Tensor.view_as.md | 6 +++---
.../api_difference/ops/torch.as_strided.md | 4 ++--
.../pytorch_api_mapping_format_cn.md | 2 +-
6 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md
index 83438f16a2d..aabf6986f9c 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.index_put.md
@@ -17,6 +17,6 @@ paddle.Tensor.index_put(indices, value, accumulate=False, name=None)
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
-| indices | indices | 包含用来索引的 tensors 的元组。数据类型为 int32,int64,bool。 |
-| values | value | 用来给 x 赋值的 Tensor,仅参数名不一致。 |
-| accumulate | accumulate | 指定是否将 value 加到 x 的参数。 默认值为 False。 |
+| indices | indices | 包含用来索引的 tensors 的元组。数据类型为 int32,int64,bool。 |
+| values | value | 用来给 x 赋值的 Tensor,仅参数名不一致。 |
+| accumulate | accumulate | 指定是否将 value 加到 x 的参数。 默认值为 False。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md
index ff94e4bf041..fdd4ab2ae7b 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.unfold.md
@@ -1,4 +1,4 @@
-## [ 参数名不一致 ]torch.Tensor.unfold
+## [ 仅参数名不一致 ]torch.Tensor.unfold
### [torch.Tensor.unfold](https://pytorch.org/docs/stable/generated/torch.Tensor.unfold.html?highlight=unfold#torch.Tensor.unfold)
@@ -17,7 +17,7 @@ paddle.Tensor.unfold(axis,
name=None)
```
-Paddle 相比 PyTorch 支持更多其他参数,具体如下:
+两者功能一致且参数用法一致,仅参数名不一致,具体如下:
### 参数映射
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
index b41e59b8461..d5dbc1b9377 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
@@ -4,6 +4,7 @@
```python
torch.Tensor.view(*shape)
+torch.Tensor.view(dtype)
```
### [paddle.Tensor.view](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#view-x-shape-or-dtype-name-none)
@@ -18,4 +19,16 @@ paddle.Tensor.view(shape_or_dtype, name=None)
| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------ |
-| *shape | shape_or_dtype | 指定的维度。 Pytorch 参数 shape 既可以是可变参数,也可以是 list/tuple/torch.Size/dtype 的形式, Paddle 参数 shape_or_dtype 为 list/tuple/dtype 的形式。 |
+| *shape | shape_or_dtype | 指定的维度。 Pytorch 参数 shape 既可以是可变参数,也可以是 list/tuple/torch.Size/dtype 的形式, Paddle 参数 shape_or_dtype 为 list/tuple/dtype 的形式。需要进行转写。 |
+
+### 转写示例
+
+```python
+# Pytorch 写法
+x = torch.randn(4, 4)
+x.view(2, 2, 4)
+
+# Paddle 写法
+x = paddle.randn(4, 4)
+x.view([2, 2, 4])
+```
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md
index 747acda2548..fd26f41c301 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view_as.md
@@ -1,18 +1,18 @@
## [ 参数完全一致 ]torch.Tensor.view_as
-### [torch.Tensor.view](https://pytorch.org/docs/stable/generated/torch.Tensor.view_as.html?highlight=view_as#torch.Tensor.view_as)
+### [torch.Tensor.view_as](https://pytorch.org/docs/stable/generated/torch.Tensor.view_as.html?highlight=view_as#torch.Tensor.view_as)
```python
torch.Tensor.view_as(other)
```
-### [paddle.Tensor.view](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#view-as-x-other-name-none)
+### [paddle.Tensor.view_as](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/Tensor_cn.html#view-as-x-other-name-none)
```python
paddle.Tensor.view_as(other, name=None)
```
-功能一致,参数完全一致,具体如下:
+两者功能一致,参数完全一致,具体如下:
### 参数映射
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
index ce7e904b4c4..d54346d3fec 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
@@ -18,11 +18,11 @@ paddle.as_strided(x,
name=None)
```
-两者功能一致,仅参数名不一致,具体如下:
+两者功能一致且参数用法一致,仅参数名不一致,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input | x | 表示输入的 Tensor 。 |
-| size | shape | 表示输出 Tensor 的维度。 |
+| size | shape | 表示输出 Tensor 的维度, 仅参数名不一致。 |
| stride | stride | 表示输出 Tensor 的 stride。 |
| storage_offset | offset | 表示偏移量 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/pytorch_api_mapping_format_cn.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/pytorch_api_mapping_format_cn.md
index 52d383dc5b8..f72794c13be 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/pytorch_api_mapping_format_cn.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/pytorch_api_mapping_format_cn.md
@@ -51,7 +51,7 @@ Paddle API 签名
* 如果 `无参数`,则没有参数映射这一栏。
-* 如果 `参数完全一致`,无需转写示例,需要在备注栏里对该参数加一句 `仅参数名不一致`。
+* 如果 `参数完全一致`,无需转写示例。
* 如果 `仅参数名不一致`,无需转写示例,需要在备注栏里对该参数加一句 `仅参数名不一致`。
From 938fad1327c20ba87fc6ed59f21b8c90cc015cb6 Mon Sep 17 00:00:00 2001
From: Li-fAngyU <972117977@qq.com>
Date: Tue, 17 Oct 2023 18:33:48 +0800
Subject: [PATCH 6/7] fix torch.as_strided and torch.Tensor.as_strided
---
.../api_difference/Tensor/torch.Tensor.as_strided.md | 6 +++---
.../api_difference/ops/torch.as_strided.md | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md
index c92d68cc642..4a1af406473 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.as_strided.md
@@ -16,10 +16,10 @@ paddle.Tensor.as_strided(shape,
name=None)
```
-两者功能一致,仅参数名不一致,具体如下:
+两者功能一致且参数用法一致,仅参数名不一致,具体如下:
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
-| size | shape | 表示输出 Tensor 的维度。 |
+| size | shape | 表示输出 Tensor 的维度, 仅参数名不一致。 |
| stride | stride | 表示输出 Tensor 的 stride。 |
-| storage_offset | offset | 表示偏移量 |
+| storage_offset | offset | 表示偏移量, 仅参数名不一致。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
index d54346d3fec..f23ddd6ddbf 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
@@ -25,4 +25,4 @@ paddle.as_strided(x,
| input | x | 表示输入的 Tensor 。 |
| size | shape | 表示输出 Tensor 的维度, 仅参数名不一致。 |
| stride | stride | 表示输出 Tensor 的 stride。 |
-| storage_offset | offset | 表示偏移量 |
+| storage_offset | offset | 表示偏移量, 仅参数名不一致。 |
From a2c64ee526ddd8cc94e08cd87121d3d16b082cb1 Mon Sep 17 00:00:00 2001
From: Li-fAngyU <972117977@qq.com>
Date: Wed, 18 Oct 2023 10:41:22 +0800
Subject: [PATCH 7/7] update
---
.../Tensor/torch.Tensor.view.md | 2 +-
.../api_difference/ops/torch.as_strided.md | 2 +-
.../api_difference/ops/torch.is_pinned.md | 19 +++++++++++++++++++
.../api_difference/ops/torch.nanquantile.md | 4 ++--
.../pytorch_api_mapping_cn.md | 5 ++---
5 files changed, 25 insertions(+), 7 deletions(-)
create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.is_pinned.md
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
index d5dbc1b9377..6f976460516 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.Tensor.view.md
@@ -19,7 +19,7 @@ paddle.Tensor.view(shape_or_dtype, name=None)
| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | ------------------------------ |
-| *shape | shape_or_dtype | 指定的维度。 Pytorch 参数 shape 既可以是可变参数,也可以是 list/tuple/torch.Size/dtype 的形式, Paddle 参数 shape_or_dtype 为 list/tuple/dtype 的形式。需要进行转写。 |
+| *shape | shape_or_dtype | 指定的维度。 Pytorch 参数 shape 既可以是可变参数,也可以是 list/tuple/torch.Size/dtype 的形式, Paddle 参数 shape_or_dtype 为 list/tuple/dtype 的形式。对于可变参数的用法,需要进行转写。 |
### 转写示例
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
index f23ddd6ddbf..4a12e07122d 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.as_strided.md
@@ -22,7 +22,7 @@ paddle.as_strided(x,
### 参数映射
| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
-| input | x | 表示输入的 Tensor 。 |
+| input | x | 表示输入的 Tensor, 仅参数名不一致。 |
| size | shape | 表示输出 Tensor 的维度, 仅参数名不一致。 |
| stride | stride | 表示输出 Tensor 的 stride。 |
| storage_offset | offset | 表示偏移量, 仅参数名不一致。 |
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.is_pinned.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.is_pinned.md
new file mode 100644
index 00000000000..fcbb9a6481a
--- /dev/null
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.is_pinned.md
@@ -0,0 +1,19 @@
+## [ 组合替代实现 ]torch.Tensor.is_pinned
+
+### [torch.Tensor.is_pinned](https://pytorch.org/docs/stable/generated/torch.Tensor.is_pinned.html?highlight=is_pinned#torch.Tensor.is_pinned)
+
+```python
+torch.Tensor.is_pinned()
+```
+
+返回张量是否在固定内存上; Paddle 无此 API,需要组合实现。
+
+### 转写示例
+
+```python
+# Pytorch 写法
+y = a.is_pinned(b)
+
+# Paddle 写法
+y = 'pinned' in str(a.place)
+```
diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md
index 1e8d3e82e2c..0c4c84d04fa 100644
--- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md
+++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.nanquantile.md
@@ -30,7 +30,7 @@ Pytorch 相比 Paddle 支持更多其他参数,具体如下:
| q | q | 待计算的分位数。 |
| dim | axis| 指定对 x 进行计算的轴,仅参数名不一致。 |
|keepdim|keepdim| 是否在输出 Tensor 中保留减小的维度。|
-|interpolation| - | 当所需分位数位于两个数据点之间时使用的插值方法,Paddle 无此参数,需要转写,Paddle 暂无转写方式。|
+|interpolation| - | 当所需分位数位于两个数据点之间时使用的插值方法,Paddle 无此参数,Paddle 暂无转写方式。|
| out | - | 表示输出的 Tensor,Paddle 无此参数,需要转写。 |
@@ -38,7 +38,7 @@ Pytorch 相比 Paddle 支持更多其他参数,具体如下:
#### out:指定输出
```python
# Pytorch 写法
-torch.nanquantile(torch.tensor([float('nan'), 1., 2., 3.]), 0.6, interpolation='linear', out=y)
+torch.nanquantile(torch.tensor([float('nan'), 1., 2., 3.]), 0.6, out=y)
# Paddle 写法
paddle.assign(paddle.nanquantile(paddle.to_tensor([float('nan'), 1., 2., 3.]), 0.6), y)
diff --git a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md
index 15f9daac58c..9afaba1d3f4 100644
--- a/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md
+++ b/docs/guides/model_convert/convert_from_pytorch/pytorch_api_mapping_cn.md
@@ -917,9 +917,8 @@
| 300 | [torch.ShortTensor](https://pytorch.org/docs/stable/tensors.html) |[paddle.to_tensor](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/to_tensor_cn.html#to-tensor)| 仅 paddle 参数更多 , [差异对比](https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/Tensor/torch.ShortTensor.md)|
| 301 | [torch.Tensor.copysign](https://pytorch.org/docs/1.13/generated/torch.Tensor.copysign.html?highlight=torch+tensor+copysign#torch.Tensor.copysign) | | 功能缺失 |
| 302 | [torch.Tensor.dequantize](https://pytorch.org/docs/1.13/generated/torch.Tensor.dequantize.html?highlight=torch+tensor+dequantize#torch.Tensor.dequantize) | | 功能缺失 |
-| 303 | [torch.Tensor.is_pinned](https://pytorch.org/docs/stable/generated/torch.Tensor.is_pinned.html?highlight=is_pinned#torch.Tensor.is_pinned) | | 功能缺失 |
-| 304 | [torch.Tensor.sum_to_size](https://pytorch.org/docs/stable/generated/torch.Tensor.sum_to_size.html?highlight=sum_to_size#torch.Tensor.sum_to_size) | | 功能缺失 |
-| 305 | [torch.Tensor.resize_](https://pytorch.org/docs/stable/generated/torch.Tensor.resize_.html?highlight=resize#torch.Tensor.resize_) | | 功能缺失 |
+| 303 | [torch.Tensor.sum_to_size](https://pytorch.org/docs/stable/generated/torch.Tensor.sum_to_size.html?highlight=sum_to_size#torch.Tensor.sum_to_size) | | 功能缺失 |
+| 304 | [torch.Tensor.resize_](https://pytorch.org/docs/stable/generated/torch.Tensor.resize_.html?highlight=resize#torch.Tensor.resize_) | | 功能缺失 |
***持续更新...***
## torch.nn.init.XX API 映射列表