Skip to content

Commit

Permalink
[Add] hack5 31 doc (PaddlePaddle#6394)
Browse files Browse the repository at this point in the history
  • Loading branch information
megemini authored Dec 18, 2023
1 parent 0ee8411 commit 26f1888
Show file tree
Hide file tree
Showing 12 changed files with 190 additions and 52 deletions.
5 changes: 5 additions & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ tensor 元素操作相关(如:转置,reshape 等)
" :ref:`paddle.masked_fill <cn_api_paddle_masked_fill>` ", "根据 mask 信息,将 value 中的值填充到 x 中 mask 对应为 True 的位置。"
" :ref:`paddle.diagonal_scatter <cn_api_paddle_diagonal_scatter>` ", "根据给定的轴 axis 和偏移量 offset,将张量 y 的值填充到张量 x 中"
" :ref:`paddle.index_fill <cn_api_paddle_index_fill>` ", "沿着指定轴 axis 将 index 中指定位置的 x 的值填充为 value"
" :ref:`paddle.column_stack <cn_api_paddle_column_stack>` ", "沿水平轴堆叠输入 x 中的所有张量。"
" :ref:`paddle.row_stack <cn_api_paddle_row_stack>` ", "沿垂直轴堆叠输入 x 中的所有张量。"
" :ref:`paddle.hstack <cn_api_paddle_hstack>` ", "沿水平轴堆叠输入 x 中的所有张量。"
" :ref:`paddle.vstack <cn_api_paddle_vstack>` ", "沿垂直轴堆叠输入 x 中的所有张量。"
" :ref:`paddle.dstack <cn_api_paddle_dstack>` ", "沿深度轴堆叠输入 x 中的所有张量。"

.. _tensor_manipulation_inplace:

Expand Down
23 changes: 23 additions & 0 deletions docs/api/paddle/column_stack_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _cn_api_paddle_column_stack:

column_stack
-------------------------------

.. py:function:: paddle.column_stack(x, name=None)
沿水平轴堆叠输入 ``x`` 中的所有张量。 ``x`` 中的每个张量 ``tensor`` 如果在堆叠之前 ``tensor.ndim < 2`` ,则首先被整形为 ``(tensor.numel(), 1)``。所有张量必须具有相同的数据类型。

参数
::::::::::::

- **x** (list[Tensor]|tuple[Tensor]) - 输入 ``x`` 可以是张量的 list 或 tuple, ``x`` 中张量的数据类型必须相同。支持的数据类型: ``float16`` 、 ``float32`` 、 ``float64`` 、 ``int32`` 、 ``int64`` 或 ``bfloat16`` 。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::
Tensor,与输入数据类型相同的堆叠张量。

代码示例
::::::::::::

COPY-FROM: paddle.column_stack
23 changes: 23 additions & 0 deletions docs/api/paddle/dstack_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _cn_api_paddle_dstack:

dstack
-------------------------------

.. py:function:: paddle.dstack(x, name=None)
沿深度轴堆叠输入 ``x`` 中的所有张量。所有张量必须具有相同的数据类型。

参数
::::::::::::

- **x** (list[Tensor]|tuple[Tensor]) - 输入 ``x`` 可以是张量的 list 或 tuple, ``x`` 中张量的数据类型必须相同。支持的数据类型: ``float16`` 、 ``float32`` 、 ``float64`` 、 ``int32`` 、 ``int64`` 或 ``bfloat16`` 。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::
Tensor,与输入数据类型相同的堆叠张量。

代码示例
::::::::::::

COPY-FROM: paddle.dstack
23 changes: 23 additions & 0 deletions docs/api/paddle/hstack_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _cn_api_paddle_hstack:

hstack
-------------------------------

.. py:function:: paddle.hstack(x, name=None)
沿水平轴堆叠输入 ``x`` 中的所有张量。所有张量必须具有相同的数据类型。

参数
::::::::::::

- **x** (list[Tensor]|tuple[Tensor]) - 输入 ``x`` 可以是张量的 list 或 tuple, ``x`` 中张量的数据类型必须相同。支持的数据类型: ``float16`` 、 ``float32`` 、 ``float64`` 、 ``int32`` 、 ``int64`` 或 ``bfloat16`` 。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::
Tensor,与输入数据类型相同的堆叠张量。

代码示例
::::::::::::

COPY-FROM: paddle.hstack
23 changes: 23 additions & 0 deletions docs/api/paddle/row_stack_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _cn_api_paddle_row_stack:

row_stack
-------------------------------

.. py:function:: paddle.row_stack(x, name=None)
:ref:`cn_api_paddle_vstack` 的别名。沿垂直轴堆叠输入 ``x`` 中的所有张量。所有张量必须具有相同的数据类型。

参数
::::::::::::

- **x** (list[Tensor]|tuple[Tensor]) - 输入 ``x`` 可以是张量的 list 或 tuple, ``x`` 中张量的数据类型必须相同。支持的数据类型: ``float16`` 、 ``float32`` 、 ``float64`` 、 ``int32`` 、 ``int64`` 或 ``bfloat16`` 。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::
Tensor,与输入数据类型相同的堆叠张量。

代码示例
::::::::::::

COPY-FROM: paddle.row_stack
23 changes: 23 additions & 0 deletions docs/api/paddle/vstack_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. _cn_api_paddle_vstack:

vstack
-------------------------------

.. py:function:: paddle.vstack(x, name=None)
沿垂直轴堆叠输入 ``x`` 中的所有张量。所有张量必须具有相同的数据类型。

参数
::::::::::::

- **x** (list[Tensor]|tuple[Tensor]) - 输入 ``x`` 可以是张量的 list 或 tuple, ``x`` 中张量的数据类型必须相同。支持的数据类型: ``float16`` 、 ``float32`` 、 ``float64`` 、 ``int32`` 、 ``int64`` 或 ``bfloat16`` 。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。

返回
::::::::::::
Tensor,与输入数据类型相同的堆叠张量。

代码示例
::::::::::::

COPY-FROM: paddle.vstack
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
## [ 组合替代实现 ]torch.column_stack
## [ 仅参数名不一致 ]torch.column_stack

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

```python
torch.column_stack(tensors, *, out=None)
```

按水平方向拼接张量; Paddle 无此 API,需要组合实现。

### 转写示例
### [paddle.column_stack](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/column_stack_cn.html)

```python
# Pytorch 写法
y = torch.column_stack((a, b))

# Paddle 写法
if a.ndim == 1:
y = paddle.stack((a, b), axis=1)
else:
y = paddle.concat((a, b), axis=1)
paddle.column_stack(x, name=None)
```

其中 Paddle 相比 Pytorch 仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| tensors | x | 表示输入的 Tensor ,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## [ 仅参数名不一致 ]torch.dstack

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

```python
torch.dstack(tensors, *, out=None)
```

### [paddle.dstack](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/dstack_cn.html)

```python
paddle.dstack(x, name=None)
```

其中 Paddle 相比 Pytorch 仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| tensors | x | 表示输入的 Tensor ,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
## [ 组合替代实现 ]torch.hstack
## [ 仅参数名不一致 ]torch.hstack

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

```python
torch.hstack(tensors, *, out=None)
```

按水平方向拼接张量; Paddle 无此 API,需要组合实现。

### 转写示例
### [paddle.hstack](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/hstack_cn.html)

```python
# Pytorch 写法
y = torch.hstack((a, b))

# Paddle 写法
if a.ndim == 1:
y = paddle.concat((a, b), axis=0)
else:
y = paddle.concat((a, b), axis=1)
paddle.hstack(x, name=None)
```

其中 Paddle 相比 Pytorch 仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| tensors | x | 表示输入的 Tensor ,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
## [ 组合替代实现 ]torch.row_stack
## [ 仅参数名不一致 ]torch.row_stack

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

```python
torch.row_stack(tensors, *, out=None)
```

按垂直方向拼接张量; Paddle 无此 API,需要组合实现。

### 转写示例
### [paddle.row_stack](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/row_stack_cn.html)

```python
# Pytorch 写法
y = torch.row_stack((a, b))

# Paddle 写法
if a.ndim == 1:
y = paddle.stack((a, b))
else:
y = paddle.concat((a, b))
paddle.row_stack(x, name=None)
```

其中 Paddle 相比 Pytorch 仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| tensors | x | 表示输入的 Tensor ,仅参数名不一致。 |
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
## [ 组合替代实现 ]torch.vstack
## [ 仅参数名不一致 ]torch.vstack

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

```python
torch.vstack(tensors, *, out=None)
```

按垂直方向拼接张量; Paddle 无此 API,需要组合实现。

### 转写示例
### [paddle.vstack](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/vstack_cn.html)

```python
# Pytorch 写法
y = torch.vstack((a, b))

# Paddle 写法
if a.ndim == 1:
y = paddle.stack((a, b))
else:
y = paddle.concat((a, b))
paddle.vstack(x, name=None)
```

其中 Paddle 相比 Pytorch 仅参数名不一致,具体如下:

### 参数映射

| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| tensors | x | 表示输入的 Tensor ,仅参数名不一致。 |
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,11 @@
| REFERENCE-MAPPING-ITEM(`torch.is_nonzero`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.is_nonzero.md) |
| REFERENCE-MAPPING-ITEM(`torch.polar`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.polar.md) |
| REFERENCE-MAPPING-ITEM(`torch.rand_like`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.rand_like.md) |
| REFERENCE-MAPPING-ITEM(`torch.row_stack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.row_stack.md) |
| REFERENCE-MAPPING-ITEM(`torch.seed`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.seed.md) |
| REFERENCE-MAPPING-ITEM(`torch.set_printoptions`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.set_printoptions.md) |
| REFERENCE-MAPPING-ITEM(`torch.set_rng_state`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.set_rng_state.md) |
| REFERENCE-MAPPING-ITEM(`torch.swapaxes`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.swapaxes.md) |
| REFERENCE-MAPPING-ITEM(`torch.swapdims`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.swapdims.md) |
| REFERENCE-MAPPING-ITEM(`torch.vstack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vstack.md) |
| REFERENCE-MAPPING-ITEM(`torch.arcsinh`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.arcsinh.md) |
| REFERENCE-MAPPING-ITEM(`torch.arctanh`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.arctanh.md) |
| REFERENCE-MAPPING-ITEM(`torch.asinh`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.asinh.md) |
Expand Down Expand Up @@ -319,8 +317,12 @@
| REFERENCE-MAPPING-ITEM(`torch.bucketize`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.bucketize.md) |
| REFERENCE-MAPPING-ITEM(`torch.cdist`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cdist.md) |
| REFERENCE-MAPPING-ITEM(`torch.clamp_min`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.clamp_min.md) |
| REFERENCE-MAPPING-ITEM(`torch.column_stack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.column_stack.md) |
| REFERENCE-MAPPING-ITEM(`torch.concat`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.concat.md) |
| REFERENCE-MAPPING-ITEM(`torch.column_stack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.column_stack.md) |
| REFERENCE-MAPPING-ITEM(`torch.row_stack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.row_stack.md) |
| REFERENCE-MAPPING-ITEM(`torch.hstack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hstack.md) |
| REFERENCE-MAPPING-ITEM(`torch.vstack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vstack.md) |
| REFERENCE-MAPPING-ITEM(`torch.dstack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.dstack.md) |
| REFERENCE-MAPPING-ITEM(`torch.conj_physical`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.conj_physical.md) |
| REFERENCE-MAPPING-ITEM(`torch.copysign`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.copysign.md) |
| REFERENCE-MAPPING-ITEM(`torch.cosine_similarity`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.cosine_similarity.md) |
Expand All @@ -331,7 +333,6 @@
| REFERENCE-MAPPING-ITEM(`torch.erfc`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.erfc.md) |
| REFERENCE-MAPPING-ITEM(`torch.exp2`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.exp2.md) |
| REFERENCE-MAPPING-ITEM(`torch.from_dlpack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.from_dlpack.md) |
| REFERENCE-MAPPING-ITEM(`torch.hstack`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hstack.md) |
| REFERENCE-MAPPING-ITEM(`torch.hypot`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hypot.md) |
| REFERENCE-MAPPING-ITEM(`torch.i0`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.i0.md) |
| REFERENCE-MAPPING-ITEM(`torch.index_add`, https://github.com/PaddlePaddle/docs/tree/develop/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.index_add.md) |
Expand Down

0 comments on commit 26f1888

Please sign in to comment.