From 4bb8da376e3e4156f45fbf8b1567bc3c5b7b64be Mon Sep 17 00:00:00 2001 From: megemini Date: Thu, 16 Nov 2023 15:11:29 +0800 Subject: [PATCH 1/9] [Add] atleast_Nd cn doc --- docs/api/paddle/Overview_cn.rst | 3 +++ docs/api/paddle/atleast_1d_cn.rst | 24 ++++++++++++++++++++++++ docs/api/paddle/atleast_2d_cn.rst | 24 ++++++++++++++++++++++++ docs/api/paddle/atleast_3d_cn.rst | 24 ++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 docs/api/paddle/atleast_1d_cn.rst create mode 100644 docs/api/paddle/atleast_2d_cn.rst create mode 100644 docs/api/paddle/atleast_3d_cn.rst diff --git a/docs/api/paddle/Overview_cn.rst b/docs/api/paddle/Overview_cn.rst index afa6ef263e6..b857f45e94b 100755 --- a/docs/api/paddle/Overview_cn.rst +++ b/docs/api/paddle/Overview_cn.rst @@ -356,6 +356,9 @@ tensor 元素操作相关(如:转置,reshape 等) " :ref:`paddle.gather ` ", "根据索引 index 获取输入 x 的指定 aixs 维度的条目,并将它们拼接在一起" " :ref:`paddle.gather_nd ` ", "paddle.gather 的高维推广" " :ref:`paddle.reshape ` ", "在保持输入 x 数据不变的情况下,改变 x 的形状" + " :ref:`paddle.atleast_1d ` ", "将输入转换为张量并返回至少为 ‵‵1`` 维的视图" + " :ref:`paddle.atleast_2d ` ", "将输入转换为张量并返回至少为 ‵‵2`` 维的视图" + " :ref:`paddle.atleast_3d ` ", "将输入转换为张量并返回至少为 ‵‵3`` 维的视图" " :ref:`paddle.roll ` ", "沿着指定维度 axis 对输入 x 进行循环滚动,当元素移动到最后位置时,会从第一个位置重新插入" " :ref:`paddle.scatter ` ", "通过基于 updates 来更新选定索引 index 上的输入来获得输出" " :ref:`paddle.scatter_nd ` ", "根据 index ,将 updates 添加到一个新的张量中,从而得到输出的 Tensor" diff --git a/docs/api/paddle/atleast_1d_cn.rst b/docs/api/paddle/atleast_1d_cn.rst new file mode 100644 index 00000000000..d12a0833dbd --- /dev/null +++ b/docs/api/paddle/atleast_1d_cn.rst @@ -0,0 +1,24 @@ +.. _cn_api_paddle_atleast_1d: + +atleast_1d +------------------------------- + +.. py:function:: paddle.atleast_1d(*inputs, name=None) + +将输入转换为张量并返回至少为 ‵‵1`` 维的视图。标量输入会被转换,``1`` 维或更高维的输入则会被保留。 + +参数 +:::::::::::: + + - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为:``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 + - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 + +返回 +:::::::::::: +一个 Tensor,当只有一个输入的时候。 +多个 Tensor,当有多个输入的时候。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.atleast_1d diff --git a/docs/api/paddle/atleast_2d_cn.rst b/docs/api/paddle/atleast_2d_cn.rst new file mode 100644 index 00000000000..2e943aa1b99 --- /dev/null +++ b/docs/api/paddle/atleast_2d_cn.rst @@ -0,0 +1,24 @@ +.. _cn_api_paddle_atleast_2d: + +atleast_2d +------------------------------- + +.. py:function:: paddle.atleast_2d(*inputs, name=None) + +将输入转换为张量并返回至少为 ‵‵2`` 维的视图。``2`` 维或更高维的输入会被保留。 + +参数 +:::::::::::: + + - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为:``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 + - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 + +返回 +:::::::::::: +一个 Tensor,当只有一个输入的时候。 +多个 Tensor,当有多个输入的时候。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.atleast_2d diff --git a/docs/api/paddle/atleast_3d_cn.rst b/docs/api/paddle/atleast_3d_cn.rst new file mode 100644 index 00000000000..8df2ca84fd6 --- /dev/null +++ b/docs/api/paddle/atleast_3d_cn.rst @@ -0,0 +1,24 @@ +.. _cn_api_paddle_atleast_3d: + +atleast_3d +------------------------------- + +.. py:function:: paddle.atleast_3d(*inputs, name=None) + +将输入转换为张量并返回至少为 ‵‵3`` 维的视图。``3`` 维或更高维的输入会被保留。 + +参数 +:::::::::::: + + - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为:``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 + - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 + +返回 +:::::::::::: +一个 Tensor,当只有一个输入的时候。 +多个 Tensor,当有多个输入的时候。 + +代码示例 +:::::::::::: + +COPY-FROM: paddle.atleast_3d From dff577b16713e997253699c88c0698a991ae503d Mon Sep 17 00:00:00 2001 From: megemini Date: Fri, 17 Nov 2023 13:15:37 +0800 Subject: [PATCH 2/9] [Update] return of list --- docs/api/paddle/atleast_1d_cn.rst | 2 +- docs/api/paddle/atleast_2d_cn.rst | 2 +- docs/api/paddle/atleast_3d_cn.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api/paddle/atleast_1d_cn.rst b/docs/api/paddle/atleast_1d_cn.rst index d12a0833dbd..3295160844c 100644 --- a/docs/api/paddle/atleast_1d_cn.rst +++ b/docs/api/paddle/atleast_1d_cn.rst @@ -16,7 +16,7 @@ atleast_1d 返回 :::::::::::: 一个 Tensor,当只有一个输入的时候。 -多个 Tensor,当有多个输入的时候。 +多个 Tensor 组成的 list,当有多个输入的时候。 代码示例 :::::::::::: diff --git a/docs/api/paddle/atleast_2d_cn.rst b/docs/api/paddle/atleast_2d_cn.rst index 2e943aa1b99..989cbdffd05 100644 --- a/docs/api/paddle/atleast_2d_cn.rst +++ b/docs/api/paddle/atleast_2d_cn.rst @@ -16,7 +16,7 @@ atleast_2d 返回 :::::::::::: 一个 Tensor,当只有一个输入的时候。 -多个 Tensor,当有多个输入的时候。 +多个 Tensor 组成的 list,当有多个输入的时候。 代码示例 :::::::::::: diff --git a/docs/api/paddle/atleast_3d_cn.rst b/docs/api/paddle/atleast_3d_cn.rst index 8df2ca84fd6..4c051f1a233 100644 --- a/docs/api/paddle/atleast_3d_cn.rst +++ b/docs/api/paddle/atleast_3d_cn.rst @@ -16,7 +16,7 @@ atleast_3d 返回 :::::::::::: 一个 Tensor,当只有一个输入的时候。 -多个 Tensor,当有多个输入的时候。 +多个 Tensor 组成的 list,当有多个输入的时候。 代码示例 :::::::::::: From 9509523cd84870d1ff8fe24e804cfacc7948eb4a Mon Sep 17 00:00:00 2001 From: megemini Date: Fri, 17 Nov 2023 18:48:29 +0800 Subject: [PATCH 3/9] [Add] torch paddle mapping --- docs/api/paddle/Overview_cn.rst | 6 +-- docs/api/paddle/Tensor_cn.rst | 24 ++++++++++ docs/api/paddle/atleast_1d_cn.rst | 7 ++- docs/api/paddle/atleast_2d_cn.rst | 7 ++- docs/api/paddle/atleast_3d_cn.rst | 7 ++- .../api_difference/ops/torch.atleast_1d.md | 44 +++++++++++++++++++ .../api_difference/ops/torch.atleast_2d.md | 44 +++++++++++++++++++ .../api_difference/ops/torch.atleast_3d.md | 44 +++++++++++++++++++ .../pytorch_api_mapping_cn.md | 7 +++ 9 files changed, 175 insertions(+), 15 deletions(-) create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md create mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md diff --git a/docs/api/paddle/Overview_cn.rst b/docs/api/paddle/Overview_cn.rst index b857f45e94b..3a4e3b0239a 100755 --- a/docs/api/paddle/Overview_cn.rst +++ b/docs/api/paddle/Overview_cn.rst @@ -356,9 +356,9 @@ tensor 元素操作相关(如:转置,reshape 等) " :ref:`paddle.gather ` ", "根据索引 index 获取输入 x 的指定 aixs 维度的条目,并将它们拼接在一起" " :ref:`paddle.gather_nd ` ", "paddle.gather 的高维推广" " :ref:`paddle.reshape ` ", "在保持输入 x 数据不变的情况下,改变 x 的形状" - " :ref:`paddle.atleast_1d ` ", "将输入转换为张量并返回至少为 ‵‵1`` 维的视图" - " :ref:`paddle.atleast_2d ` ", "将输入转换为张量并返回至少为 ‵‵2`` 维的视图" - " :ref:`paddle.atleast_3d ` ", "将输入转换为张量并返回至少为 ‵‵3`` 维的视图" + " :ref:`paddle.atleast_1d ` ", "将输入转换为张量并返回至少为 ``1`` 维的视图" + " :ref:`paddle.atleast_2d ` ", "将输入转换为张量并返回至少为 ``2`` 维的视图" + " :ref:`paddle.atleast_3d ` ", "将输入转换为张量并返回至少为 ``3`` 维的视图" " :ref:`paddle.roll ` ", "沿着指定维度 axis 对输入 x 进行循环滚动,当元素移动到最后位置时,会从第一个位置重新插入" " :ref:`paddle.scatter ` ", "通过基于 updates 来更新选定索引 index 上的输入来获得输出" " :ref:`paddle.scatter_nd ` ", "根据 index ,将 updates 添加到一个新的张量中,从而得到输出的 Tensor" diff --git a/docs/api/paddle/Tensor_cn.rst b/docs/api/paddle/Tensor_cn.rst index a417316187b..d798a96b9c8 100755 --- a/docs/api/paddle/Tensor_cn.rst +++ b/docs/api/paddle/Tensor_cn.rst @@ -3081,3 +3081,27 @@ masked_fill_(x, mask, value, name=None) ::::::::: Inplace 版本的 :ref:`cn_api_paddle_masked_fill` API,对输入 `x` 采用 Inplace 策略。 + +atleast_1d(name=None) +::::::::: +将输入转换为张量并返回至少为 ``1`` 维的视图。 ``1`` 维或更高维的输入会被保留。 + +返回至少为 ``1`` 维视图的 Tensor 。 + +请参考 :ref:`cn_api_paddle_atleast_1d` + +atleast_2d(name=None) +::::::::: +将输入转换为张量并返回至少为 ``2`` 维的视图。 ``2`` 维或更高维的输入会被保留。 + +返回至少为 ``2`` 维视图的 Tensor 。 + +请参考 :ref:`cn_api_paddle_atleast_2d` + +atleast_3d(name=None) +::::::::: +将输入转换为张量并返回至少为 ``3`` 维的视图。 ``3`` 维或更高维的输入会被保留。 + +返回至少为 ``3`` 维视图的 Tensor 。 + +请参考 :ref:`cn_api_paddle_atleast_3d` diff --git a/docs/api/paddle/atleast_1d_cn.rst b/docs/api/paddle/atleast_1d_cn.rst index 3295160844c..74de52a0f7d 100644 --- a/docs/api/paddle/atleast_1d_cn.rst +++ b/docs/api/paddle/atleast_1d_cn.rst @@ -5,18 +5,17 @@ atleast_1d .. py:function:: paddle.atleast_1d(*inputs, name=None) -将输入转换为张量并返回至少为 ‵‵1`` 维的视图。标量输入会被转换,``1`` 维或更高维的输入则会被保留。 +将输入转换为张量并返回至少为 ``1`` 维的视图。标量输入会被转换, ``1`` 维或更高维的输入则会被保留。 参数 :::::::::::: - - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为:``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 + - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为: ``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 :::::::::::: -一个 Tensor,当只有一个输入的时候。 -多个 Tensor 组成的 list,当有多个输入的时候。 +Tensor 或者由 Tensor 组成的 list。当只有一个输入的时候返回一个 Tensor,当有多个输入的时候返回由 Tensor 组成的 list。 代码示例 :::::::::::: diff --git a/docs/api/paddle/atleast_2d_cn.rst b/docs/api/paddle/atleast_2d_cn.rst index 989cbdffd05..56554a57a94 100644 --- a/docs/api/paddle/atleast_2d_cn.rst +++ b/docs/api/paddle/atleast_2d_cn.rst @@ -5,18 +5,17 @@ atleast_2d .. py:function:: paddle.atleast_2d(*inputs, name=None) -将输入转换为张量并返回至少为 ‵‵2`` 维的视图。``2`` 维或更高维的输入会被保留。 +将输入转换为张量并返回至少为 ``2`` 维的视图。 ``2`` 维或更高维的输入会被保留。 参数 :::::::::::: - - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为:``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 + - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为: ``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 :::::::::::: -一个 Tensor,当只有一个输入的时候。 -多个 Tensor 组成的 list,当有多个输入的时候。 +Tensor 或者由 Tensor 组成的 list。当只有一个输入的时候返回一个 Tensor,当有多个输入的时候返回由 Tensor 组成的 list。 代码示例 :::::::::::: diff --git a/docs/api/paddle/atleast_3d_cn.rst b/docs/api/paddle/atleast_3d_cn.rst index 4c051f1a233..db6fd8116fd 100644 --- a/docs/api/paddle/atleast_3d_cn.rst +++ b/docs/api/paddle/atleast_3d_cn.rst @@ -5,18 +5,17 @@ atleast_3d .. py:function:: paddle.atleast_3d(*inputs, name=None) -将输入转换为张量并返回至少为 ‵‵3`` 维的视图。``3`` 维或更高维的输入会被保留。 +将输入转换为张量并返回至少为 ``3`` 维的视图。 ``3`` 维或更高维的输入会被保留。 参数 :::::::::::: - - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为:``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 + - **inputs** (Tensor|list(Tensor)) - 一个或多个 Tensor,数据类型为: ``float16``, ``float32``, ``float64``, ``int16``, ``int32``, ``int64``, ``int8``, ``uint8``, ``complex64``, ``complex128``, ``bfloat16`` 或 ``bool``。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 返回 :::::::::::: -一个 Tensor,当只有一个输入的时候。 -多个 Tensor 组成的 list,当有多个输入的时候。 +Tensor 或者由 Tensor 组成的 list。当只有一个输入的时候返回一个 Tensor,当有多个输入的时候返回由 Tensor 组成的 list。 代码示例 :::::::::::: diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md new file mode 100644 index 00000000000..77b0215a80b --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md @@ -0,0 +1,44 @@ +## [ 参数不一致 ]torch.atleast_1d + +### [torch.atleast_1d](https://pytorch.org/docs/stable/generated/torch.atleast_1d.html#torch-atleast-1d) + +```python +torch.atleast_1d(*tensors) +``` + +### [paddle.atleast_1d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_1d_cn.html#atleast_1d) + +```python +paddle.atleast_1d(*inputs, name=None) +``` + +PyTorch 与 Paddle 参数形式上一致,具体如下: + +### 参数映射 +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ------------------------------------------------------ | +| tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | + +PyTorch 与 Paddle 功能一致,但,对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 + +### 转写示例 + +#### 多个 Tensor +```python +# Pytorch 写法 +x = torch.tensor(0.3) +y = torch.tensor(0.4) +# 可以写为多个输入的方式 +torch.atleast_1d(x, y) +# 或者组合为一个 tuple,这两种方式是等价的 +torch.atleast_1d((x, y)) + +# Paddle 写法 +x = paddle.to_tensor(0.3) +y = paddle.to_tensor(0.4) +# 这里只能分别传入 +paddle.atleast_1d(x, y) +# 下面这种方式会将 (x, y) 经过 broadcast 后作为单个输入 +paddle.atleast_1d((x, y)) + +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md new file mode 100644 index 00000000000..170419a8cb4 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md @@ -0,0 +1,44 @@ +## [ 参数不一致 ]torch.atleast_2d + +### [torch.atleast_2d](https://pytorch.org/docs/stable/generated/torch.atleast_2d.html#torch-atleast-2d) + +```python +torch.atleast_2d(*tensors) +``` + +### [paddle.atleast_2d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_2d_cn.html#atleast_2d) + +```python +paddle.atleast_2d(*inputs, name=None) +``` + +PyTorch 与 Paddle 参数形式上一致,具体如下: + +### 参数映射 +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ------------------------------------------------------ | +| tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | + +PyTorch 与 Paddle 功能一致,但,对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 + +### 转写示例 + +#### 多个 Tensor +```python +# Pytorch 写法 +x = torch.tensor(0.3) +y = torch.tensor(0.4) +# 可以写为多个输入的方式 +torch.atleast_2d(x, y) +# 或者组合为一个 tuple,这两种方式是等价的 +torch.atleast_2d((x, y)) + +# Paddle 写法 +x = paddle.to_tensor(0.3) +y = paddle.to_tensor(0.4) +# 这里只能分别传入 +paddle.atleast_2d(x, y) +# 下面这种方式会将 (x, y) 经过 broadcast 后作为单个输入 +paddle.atleast_2d((x, y)) + +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md new file mode 100644 index 00000000000..2b88b5185b0 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md @@ -0,0 +1,44 @@ +## [ 参数不一致 ]torch.atleast_3d + +### [torch.atleast_3d](https://pytorch.org/docs/stable/generated/torch.atleast_3d.html#torch-atleast-3d) + +```python +torch.atleast_3d(*tensors) +``` + +### [paddle.atleast_3d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_3d_cn.html#atleast_3d) + +```python +paddle.atleast_3d(*inputs, name=None) +``` + +PyTorch 与 Paddle 参数形式上一致,具体如下: + +### 参数映射 +| PyTorch | PaddlePaddle | 备注 | +| ------------- | ------------ | ------------------------------------------------------ | +| tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | + +PyTorch 与 Paddle 功能一致,但,对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 + +### 转写示例 + +#### 多个 Tensor +```python +# Pytorch 写法 +x = torch.tensor(0.3) +y = torch.tensor(0.4) +# 可以写为多个输入的方式 +torch.atleast_3d(x, y) +# 或者组合为一个 tuple,这两种方式是等价的 +torch.atleast_3d((x, y)) + +# Paddle 写法 +x = paddle.to_tensor(0.3) +y = paddle.to_tensor(0.4) +# 这里只能分别传入 +paddle.atleast_3d(x, y) +# 下面这种方式会将 (x, y) 经过 broadcast 后作为单个输入 +paddle.atleast_3d((x, 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 b14f3a3eeef..c26d72c1cd3 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 @@ -368,6 +368,9 @@ | REFERENCE-MAPPING-ITEM(`torch.is_grad_enabled`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.is_grad_enabled.md) | | REFERENCE-MAPPING-ITEM(`torch.manual_seed`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/others/torch.manual_seed.md) | | [torch.can_cast](https://pytorch.org/docs/stable/generated/torch.can_cast.html#torch-can-cast) | 功能缺失 | +| REFERENCE-MAPPING-ITEM(`torch.atleast_1d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md) | +| REFERENCE-MAPPING-ITEM(`torch.atleast_2d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md) | +| REFERENCE-MAPPING-ITEM(`torch.atleast_3d`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md) | ***持续更新...*** @@ -926,6 +929,9 @@ | 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_) | | 功能缺失 | | 305 | [torch.Tensor.masked_fill_](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_fill_.html?highlight=resize#torch.Tensor.masked_fill_) | [paddle.Tensor.masked_fill_](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#id25) | 功能完全一致 | +| 306 | | [paddle.Tensor.atleast_1d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_1d_cn.html#atleast_1d) | PyTorch 功能缺失 | +| 307 | | [paddle.Tensor.atleast_2d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_2d_cn.html#atleast_2d) | PyTorch 功能缺失 | +| 308 | | [paddle.Tensor.atleast_3d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_3d_cn.html#atleast_3d) | PyTorch 功能缺失 | | 序号 | PyTorch API | PaddlePaddle API | 备注 | @@ -1234,6 +1240,7 @@ | NOT-IMPLEMENTED-ITEM(`torch.Tensor.dequantize`, https://pytorch.org/docs/1.13/generated/torch.Tensor.dequantize.html?highlight=torch+tensor+dequantize#torch.Tensor.dequantize) | | NOT-IMPLEMENTED-ITEM(`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) | | NOT-IMPLEMENTED-ITEM(`torch.Tensor.resize_`, https://pytorch.org/docs/stable/generated/torch.Tensor.resize_.html?highlight=resize#torch.Tensor.resize_) | + ***持续更新...*** ## torch.nn.init.XX API 映射列表 From 47e76f2675908cffe2efedee86b91548c1e6f221 Mon Sep 17 00:00:00 2001 From: megemini Date: Sat, 18 Nov 2023 14:10:06 +0800 Subject: [PATCH 4/9] [Update] desc --- .../convert_from_pytorch/api_difference/ops/torch.atleast_1d.md | 2 +- .../convert_from_pytorch/api_difference/ops/torch.atleast_2d.md | 2 +- .../convert_from_pytorch/api_difference/ops/torch.atleast_3d.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md index 77b0215a80b..ef027ca7164 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md @@ -19,7 +19,7 @@ PyTorch 与 Paddle 参数形式上一致,具体如下: | ------------- | ------------ | ------------------------------------------------------ | | tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | -PyTorch 与 Paddle 功能一致,但,对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 +PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md index 170419a8cb4..9275d1cb18e 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md @@ -19,7 +19,7 @@ PyTorch 与 Paddle 参数形式上一致,具体如下: | ------------- | ------------ | ------------------------------------------------------ | | tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | -PyTorch 与 Paddle 功能一致,但,对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 +PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md index 2b88b5185b0..d26e3a49ea1 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md @@ -19,7 +19,7 @@ PyTorch 与 Paddle 参数形式上一致,具体如下: | ------------- | ------------ | ------------------------------------------------------ | | tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | -PyTorch 与 Paddle 功能一致,但,对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 +PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 From bb172f95deaba7d6b22dcc9ed17897f97bb9eef8 Mon Sep 17 00:00:00 2001 From: megemini Date: Tue, 21 Nov 2023 12:50:11 +0800 Subject: [PATCH 5/9] [Change] params desc --- .../api_difference/ops/torch.atleast_1d.md | 4 ++-- .../api_difference/ops/torch.atleast_2d.md | 4 ++-- .../api_difference/ops/torch.atleast_3d.md | 4 ++-- .../convert_from_pytorch/pytorch_api_mapping_cn.md | 3 --- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md index ef027ca7164..61d6c25ca48 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md @@ -12,12 +12,12 @@ torch.atleast_1d(*tensors) paddle.atleast_1d(*inputs, name=None) ``` -PyTorch 与 Paddle 参数形式上一致,具体如下: +PyTorch 与 Paddle 参数不一致,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | -| tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | +| tensors | inputs | 输入的 Tensor ,参数不一致。 | PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md index 9275d1cb18e..4a2856dc5bc 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md @@ -12,12 +12,12 @@ torch.atleast_2d(*tensors) paddle.atleast_2d(*inputs, name=None) ``` -PyTorch 与 Paddle 参数形式上一致,具体如下: +PyTorch 与 Paddle 参数不一致,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | -| tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | +| tensors | inputs | 输入的 Tensor ,参数不一致。 | PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md index d26e3a49ea1..b288b99f447 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md @@ -12,12 +12,12 @@ torch.atleast_3d(*tensors) paddle.atleast_3d(*inputs, name=None) ``` -PyTorch 与 Paddle 参数形式上一致,具体如下: +PyTorch 与 Paddle 参数不一致,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | -| tensors | inputs | 输入的 Tensor ,仅参数名不一致。 | +| tensors | inputs | 输入的 Tensor ,参数不一致。 | PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 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 c26d72c1cd3..65b346eca3f 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 @@ -929,9 +929,6 @@ | 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_) | | 功能缺失 | | 305 | [torch.Tensor.masked_fill_](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_fill_.html?highlight=resize#torch.Tensor.masked_fill_) | [paddle.Tensor.masked_fill_](https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#id25) | 功能完全一致 | -| 306 | | [paddle.Tensor.atleast_1d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_1d_cn.html#atleast_1d) | PyTorch 功能缺失 | -| 307 | | [paddle.Tensor.atleast_2d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_2d_cn.html#atleast_2d) | PyTorch 功能缺失 | -| 308 | | [paddle.Tensor.atleast_3d](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/atleast_3d_cn.html#atleast_3d) | PyTorch 功能缺失 | | 序号 | PyTorch API | PaddlePaddle API | 备注 | From 5826df2342377a807f891a9757e86e5bd2bd93a8 Mon Sep 17 00:00:00 2001 From: megemini Date: Wed, 22 Nov 2023 12:37:03 +0800 Subject: [PATCH 6/9] [Change] atleast_xd with same shape tuple inputs --- .../convert_from_pytorch/api_difference/ops/torch.atleast_1d.md | 2 +- .../convert_from_pytorch/api_difference/ops/torch.atleast_2d.md | 2 +- .../convert_from_pytorch/api_difference/ops/torch.atleast_3d.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md index 61d6c25ca48..e4c5939258e 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md @@ -38,7 +38,7 @@ x = paddle.to_tensor(0.3) y = paddle.to_tensor(0.4) # 这里只能分别传入 paddle.atleast_1d(x, y) -# 下面这种方式会将 (x, y) 经过 broadcast 后作为单个输入 +# 下面这种方式需要 x, y 具有一样的 shape paddle.atleast_1d((x, y)) ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md index 4a2856dc5bc..e5cb46630de 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md @@ -38,7 +38,7 @@ x = paddle.to_tensor(0.3) y = paddle.to_tensor(0.4) # 这里只能分别传入 paddle.atleast_2d(x, y) -# 下面这种方式会将 (x, y) 经过 broadcast 后作为单个输入 +# 下面这种方式需要 x, y 具有一样的 shape paddle.atleast_2d((x, y)) ``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md index b288b99f447..12a2a32f391 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md @@ -38,7 +38,7 @@ x = paddle.to_tensor(0.3) y = paddle.to_tensor(0.4) # 这里只能分别传入 paddle.atleast_3d(x, y) -# 下面这种方式会将 (x, y) 经过 broadcast 后作为单个输入 +# 下面这种方式需要 x, y 具有一样的 shape paddle.atleast_3d((x, y)) ``` From 38cd1080387416692b1a4a67bf48d5b856ed3c8f Mon Sep 17 00:00:00 2001 From: megemini Date: Fri, 24 Nov 2023 13:31:01 +0800 Subject: [PATCH 7/9] [Change] atleast for tuple input --- .../api_difference/ops/torch.atleast_1d.md | 30 +++++++++++-------- .../api_difference/ops/torch.atleast_2d.md | 30 +++++++++++-------- .../api_difference/ops/torch.atleast_3d.md | 30 +++++++++++-------- 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md index e4c5939258e..ef43e13d7ef 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md @@ -19,26 +19,32 @@ PyTorch 与 Paddle 参数不一致,具体如下: | ------------- | ------------ | ------------------------------------------------------ | | tensors | inputs | 输入的 Tensor ,参数不一致。 | -PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 +PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 -#### 多个 Tensor +如果有多个 Tensor,如 x 和 y: + ```python # Pytorch 写法 -x = torch.tensor(0.3) -y = torch.tensor(0.4) -# 可以写为多个输入的方式 torch.atleast_1d(x, y) -# 或者组合为一个 tuple,这两种方式是等价的 -torch.atleast_1d((x, y)) # Paddle 写法 -x = paddle.to_tensor(0.3) -y = paddle.to_tensor(0.4) -# 这里只能分别传入 paddle.atleast_1d(x, y) -# 下面这种方式需要 x, y 具有一样的 shape -paddle.atleast_1d((x, y)) +``` + +两者功能一致,同为输出两个至少 1 维的 Tensor。 + +如果 x 和 y 组成 (x, y) 作为输入(注意,此时的输入只有一个,是由 x 和 y 组成的 tuple): + +```python +# Pytorch 写法 +torch.atleast_1d((x, y)) +# Paddle 写法 +paddle.atleast_1d((x, y)) ``` + +PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 + +此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md index e5cb46630de..db614556dc0 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md @@ -19,26 +19,32 @@ PyTorch 与 Paddle 参数不一致,具体如下: | ------------- | ------------ | ------------------------------------------------------ | | tensors | inputs | 输入的 Tensor ,参数不一致。 | -PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 +PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 -#### 多个 Tensor +如果有多个 Tensor,如 x 和 y: + ```python # Pytorch 写法 -x = torch.tensor(0.3) -y = torch.tensor(0.4) -# 可以写为多个输入的方式 torch.atleast_2d(x, y) -# 或者组合为一个 tuple,这两种方式是等价的 -torch.atleast_2d((x, y)) # Paddle 写法 -x = paddle.to_tensor(0.3) -y = paddle.to_tensor(0.4) -# 这里只能分别传入 paddle.atleast_2d(x, y) -# 下面这种方式需要 x, y 具有一样的 shape -paddle.atleast_2d((x, y)) +``` + +两者功能一致,同为输出两个至少 2 维的 Tensor。 + +如果 x 和 y 组成 (x, y) 作为输入(注意,此时的输入只有一个,是由 x 和 y 组成的 tuple): + +```python +# Pytorch 写法 +torch.atleast_2d((x, y)) +# Paddle 写法 +paddle.atleast_2d((x, y)) ``` + +PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 + +此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md index 12a2a32f391..ad766a5f79b 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md @@ -19,26 +19,32 @@ PyTorch 与 Paddle 参数不一致,具体如下: | ------------- | ------------ | ------------------------------------------------------ | | tensors | inputs | 输入的 Tensor ,参数不一致。 | -PyTorch 与 Paddle 功能一致,但对于多个 Tensor 输入的处理方式略有不同,具体请看转写示例。 +PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 -#### 多个 Tensor +如果有多个 Tensor,如 x 和 y: + ```python # Pytorch 写法 -x = torch.tensor(0.3) -y = torch.tensor(0.4) -# 可以写为多个输入的方式 torch.atleast_3d(x, y) -# 或者组合为一个 tuple,这两种方式是等价的 -torch.atleast_3d((x, y)) # Paddle 写法 -x = paddle.to_tensor(0.3) -y = paddle.to_tensor(0.4) -# 这里只能分别传入 paddle.atleast_3d(x, y) -# 下面这种方式需要 x, y 具有一样的 shape -paddle.atleast_3d((x, y)) +``` + +两者功能一致,同为输出两个至少 3 维的 Tensor。 + +如果 x 和 y 组成 (x, y) 作为输入(注意,此时的输入只有一个,是由 x 和 y 组成的 tuple): + +```python +# Pytorch 写法 +torch.atleast_3d((x, y)) +# Paddle 写法 +paddle.atleast_3d((x, y)) ``` + +PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 + +此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 From 48c671e5cd909253da0eb7360b1081ad03e0a735 Mon Sep 17 00:00:00 2001 From: megemini Date: Fri, 24 Nov 2023 13:39:36 +0800 Subject: [PATCH 8/9] [Update] convert pytorch --- .../api_difference/ops/torch.atleast_1d.md | 10 ++++++++++ .../api_difference/ops/torch.atleast_2d.md | 10 ++++++++++ .../api_difference/ops/torch.atleast_3d.md | 10 ++++++++++ 3 files changed, 30 insertions(+) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md index ef43e13d7ef..170e0c35c27 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md @@ -48,3 +48,13 @@ paddle.atleast_1d((x, y)) PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 + +此时正确的转写方式为: + +```python +# Pytorch 写法 +torch.atleast_1d((x, y)) + +# Paddle 写法 +paddle.atleast_1d(x, y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md index db614556dc0..5ec7681c328 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md @@ -48,3 +48,13 @@ paddle.atleast_2d((x, y)) PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 + +此时正确的转写方式为: + +```python +# Pytorch 写法 +torch.atleast_2d((x, y)) + +# Paddle 写法 +paddle.atleast_2d(x, y) +``` diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md index ad766a5f79b..f0842acf590 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md @@ -48,3 +48,13 @@ paddle.atleast_3d((x, y)) PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 + +此时正确的转写方式为: + +```python +# Pytorch 写法 +torch.atleast_3d((x, y)) + +# Paddle 写法 +paddle.atleast_3d(x, y) +``` From a05cbe9097a3670c53092923f3f3ee25210d0c89 Mon Sep 17 00:00:00 2001 From: megemini Date: Wed, 29 Nov 2023 14:37:19 +0800 Subject: [PATCH 9/9] [Change] torch.atleast_xd.md --- .../api_difference/ops/torch.atleast_1d.md | 30 ++----------------- .../api_difference/ops/torch.atleast_2d.md | 30 ++----------------- .../api_difference/ops/torch.atleast_3d.md | 30 ++----------------- 3 files changed, 6 insertions(+), 84 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md index 170e0c35c27..7c22eeeebe4 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md @@ -17,39 +17,13 @@ PyTorch 与 Paddle 参数不一致,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | -| tensors | inputs | 输入的 Tensor ,参数不一致。 | +| tensors | inputs | 输入的 Tensor,仅当 torch 输入为 tuple(Tensor)时,两者处理方式不一致,需要转写。其他情形下均一致。 | PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 -如果有多个 Tensor,如 x 和 y: - -```python -# Pytorch 写法 -torch.atleast_1d(x, y) - -# Paddle 写法 -paddle.atleast_1d(x, y) -``` - -两者功能一致,同为输出两个至少 1 维的 Tensor。 - -如果 x 和 y 组成 (x, y) 作为输入(注意,此时的输入只有一个,是由 x 和 y 组成的 tuple): - -```python -# Pytorch 写法 -torch.atleast_1d((x, y)) - -# Paddle 写法 -paddle.atleast_1d((x, y)) -``` - -PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 - -此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 - -此时正确的转写方式为: +#### tensors: 输入为 tuple(Tensor)时 ```python # Pytorch 写法 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md index 5ec7681c328..b2ade703402 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md @@ -17,39 +17,13 @@ PyTorch 与 Paddle 参数不一致,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | -| tensors | inputs | 输入的 Tensor ,参数不一致。 | +| tensors | inputs | 输入的 Tensor,仅当 torch 输入为 tuple(Tensor)时,两者处理方式不一致,需要转写。其他情形下均一致。 | PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 -如果有多个 Tensor,如 x 和 y: - -```python -# Pytorch 写法 -torch.atleast_2d(x, y) - -# Paddle 写法 -paddle.atleast_2d(x, y) -``` - -两者功能一致,同为输出两个至少 2 维的 Tensor。 - -如果 x 和 y 组成 (x, y) 作为输入(注意,此时的输入只有一个,是由 x 和 y 组成的 tuple): - -```python -# Pytorch 写法 -torch.atleast_2d((x, y)) - -# Paddle 写法 -paddle.atleast_2d((x, y)) -``` - -PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 - -此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 - -此时正确的转写方式为: +#### tensors: 输入为 tuple(Tensor)时 ```python # Pytorch 写法 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md index f0842acf590..c2dbbe0a5f8 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md @@ -17,39 +17,13 @@ PyTorch 与 Paddle 参数不一致,具体如下: ### 参数映射 | PyTorch | PaddlePaddle | 备注 | | ------------- | ------------ | ------------------------------------------------------ | -| tensors | inputs | 输入的 Tensor ,参数不一致。 | +| tensors | inputs | 输入的 Tensor,仅当 torch 输入为 tuple(Tensor)时,两者处理方式不一致,需要转写。其他情形下均一致。 | PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 ### 转写示例 -如果有多个 Tensor,如 x 和 y: - -```python -# Pytorch 写法 -torch.atleast_3d(x, y) - -# Paddle 写法 -paddle.atleast_3d(x, y) -``` - -两者功能一致,同为输出两个至少 3 维的 Tensor。 - -如果 x 和 y 组成 (x, y) 作为输入(注意,此时的输入只有一个,是由 x 和 y 组成的 tuple): - -```python -# Pytorch 写法 -torch.atleast_3d((x, y)) - -# Paddle 写法 -paddle.atleast_3d((x, y)) -``` - -PyTorch 仍然输出两个 Tensor,而 Paddle 会将 (x, y) 作为一个整体进行处理并输出。 - -此时需要注意,x 和 y 需要具有相同的 shape,否则无法将两者转换为一个 Tensor。 - -此时正确的转写方式为: +#### tensors: 输入为 tuple(Tensor)时 ```python # Pytorch 写法