forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
【Hackathon 5th No.33】为 Paddle 新增 atleast_1d / atleast_2d / atleast_3d…
… API (PaddlePaddle#6317) * [Add] atleast_Nd cn doc * [Update] return of list * [Add] torch paddle mapping * [Update] desc * [Change] params desc * [Change] atleast_xd with same shape tuple inputs * [Change] atleast for tuple input * [Update] convert pytorch * [Change] torch.atleast_xd.md
- Loading branch information
Showing
9 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. _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 组成的 list。当只有一个输入的时候返回一个 Tensor,当有多个输入的时候返回由 Tensor 组成的 list。 | ||
|
||
代码示例 | ||
:::::::::::: | ||
|
||
COPY-FROM: paddle.atleast_1d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. _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 组成的 list。当只有一个输入的时候返回一个 Tensor,当有多个输入的时候返回由 Tensor 组成的 list。 | ||
|
||
代码示例 | ||
:::::::::::: | ||
|
||
COPY-FROM: paddle.atleast_2d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. _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 组成的 list。当只有一个输入的时候返回一个 Tensor,当有多个输入的时候返回由 Tensor 组成的 list。 | ||
|
||
代码示例 | ||
:::::::::::: | ||
|
||
COPY-FROM: paddle.atleast_3d |
34 changes: 34 additions & 0 deletions
34
...uides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_1d.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## [ 参数不一致 ]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 | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> tensors </font> | <font color='red'> inputs </font> | 输入的 Tensor,仅当 torch 输入为 tuple(Tensor)时,两者处理方式不一致,需要转写。其他情形下均一致。 | | ||
|
||
PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 | ||
|
||
### 转写示例 | ||
|
||
#### tensors: 输入为 tuple(Tensor)时 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.atleast_1d((x, y)) | ||
|
||
# Paddle 写法 | ||
paddle.atleast_1d(x, y) | ||
``` |
34 changes: 34 additions & 0 deletions
34
...uides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_2d.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## [ 参数不一致 ]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 | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> tensors </font> | <font color='red'> inputs </font> | 输入的 Tensor,仅当 torch 输入为 tuple(Tensor)时,两者处理方式不一致,需要转写。其他情形下均一致。 | | ||
|
||
PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 | ||
|
||
### 转写示例 | ||
|
||
#### tensors: 输入为 tuple(Tensor)时 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.atleast_2d((x, y)) | ||
|
||
# Paddle 写法 | ||
paddle.atleast_2d(x, y) | ||
``` |
34 changes: 34 additions & 0 deletions
34
...uides/model_convert/convert_from_pytorch/api_difference/ops/torch.atleast_3d.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## [ 参数不一致 ]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 | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| <font color='red'> tensors </font> | <font color='red'> inputs </font> | 输入的 Tensor,仅当 torch 输入为 tuple(Tensor)时,两者处理方式不一致,需要转写。其他情形下均一致。 | | ||
|
||
PyTorch 与 Paddle 功能一致,但对于由多个 Tensor 组成 tuple|list 输入的处理方式略有不同,具体请看转写示例。 | ||
|
||
### 转写示例 | ||
|
||
#### tensors: 输入为 tuple(Tensor)时 | ||
|
||
```python | ||
# Pytorch 写法 | ||
torch.atleast_3d((x, y)) | ||
|
||
# Paddle 写法 | ||
paddle.atleast_3d(x, y) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters