diff --git a/docs/api/paddle/Overview_cn.rst b/docs/api/paddle/Overview_cn.rst index 725f01b4651..b0e8ea31bb7 100755 --- a/docs/api/paddle/Overview_cn.rst +++ b/docs/api/paddle/Overview_cn.rst @@ -395,6 +395,11 @@ tensor 元素操作相关(如:转置,reshape 等) " :ref:`paddle.masked_fill ` ", "根据 mask 信息,将 value 中的值填充到 x 中 mask 对应为 True 的位置。" " :ref:`paddle.diagonal_scatter ` ", "根据给定的轴 axis 和偏移量 offset,将张量 y 的值填充到张量 x 中" " :ref:`paddle.index_fill ` ", "沿着指定轴 axis 将 index 中指定位置的 x 的值填充为 value" + " :ref:`paddle.column_stack ` ", "沿水平轴堆叠输入 x 中的所有张量。" + " :ref:`paddle.row_stack ` ", "沿垂直轴堆叠输入 x 中的所有张量。" + " :ref:`paddle.hstack ` ", "沿水平轴堆叠输入 x 中的所有张量。" + " :ref:`paddle.vstack ` ", "沿垂直轴堆叠输入 x 中的所有张量。" + " :ref:`paddle.dstack ` ", "沿深度轴堆叠输入 x 中的所有张量。" .. _tensor_manipulation_inplace: diff --git a/docs/api/paddle/column_stack_cn.rst b/docs/api/paddle/column_stack_cn.rst new file mode 100644 index 00000000000..ac4987d501f --- /dev/null +++ b/docs/api/paddle/column_stack_cn.rst @@ -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 diff --git a/docs/api/paddle/dstack_cn.rst b/docs/api/paddle/dstack_cn.rst new file mode 100644 index 00000000000..a3059c7b28d --- /dev/null +++ b/docs/api/paddle/dstack_cn.rst @@ -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 diff --git a/docs/api/paddle/hstack_cn.rst b/docs/api/paddle/hstack_cn.rst new file mode 100644 index 00000000000..4bda43bc3af --- /dev/null +++ b/docs/api/paddle/hstack_cn.rst @@ -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 diff --git a/docs/api/paddle/row_stack_cn.rst b/docs/api/paddle/row_stack_cn.rst new file mode 100644 index 00000000000..597ed722236 --- /dev/null +++ b/docs/api/paddle/row_stack_cn.rst @@ -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 diff --git a/docs/api/paddle/vstack_cn.rst b/docs/api/paddle/vstack_cn.rst new file mode 100644 index 00000000000..32cfab44786 --- /dev/null +++ b/docs/api/paddle/vstack_cn.rst @@ -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 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.column_stack.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.column_stack.md index 712b5a36b59..2dfc04f84ec 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.column_stack.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.column_stack.md @@ -1,4 +1,4 @@ -## [ 组合替代实现 ]torch.column_stack +## [ 仅参数名不一致 ]torch.column_stack ### [torch.column_stack](https://pytorch.org/docs/stable/generated/torch.column_stack.html#torch.column_stack) @@ -6,17 +6,16 @@ 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 ,仅参数名不一致。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.dstack.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.dstack.md new file mode 100644 index 00000000000..fd48962f602 --- /dev/null +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.dstack.md @@ -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 ,仅参数名不一致。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hstack.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hstack.md index e66f0349dfc..736c619e5e3 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hstack.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.hstack.md @@ -1,4 +1,4 @@ -## [ 组合替代实现 ]torch.hstack +## [ 仅参数名不一致 ]torch.hstack ### [torch.hstack](https://pytorch.org/docs/stable/generated/torch.hstack.html#torch.hstack) @@ -6,17 +6,16 @@ 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 ,仅参数名不一致。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.row_stack.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.row_stack.md index ca266cd879f..b0ca60f0cde 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.row_stack.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.row_stack.md @@ -1,4 +1,4 @@ -## [ 组合替代实现 ]torch.row_stack +## [ 仅参数名不一致 ]torch.row_stack ### [torch.row_stack](https://pytorch.org/docs/stable/generated/torch.row_stack.html#torch.row_stack) @@ -6,17 +6,16 @@ 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 ,仅参数名不一致。 | diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vstack.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vstack.md index 56fa1e6237e..e826fef7c3d 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vstack.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/ops/torch.vstack.md @@ -1,4 +1,4 @@ -## [ 组合替代实现 ]torch.vstack +## [ 仅参数名不一致 ]torch.vstack ### [torch.vstack](https://pytorch.org/docs/stable/generated/torch.vstack.html#torch.vstack) @@ -6,17 +6,16 @@ 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 ,仅参数名不一致。 | 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 2e056f8c2cf..c898eb9dc87 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 @@ -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) | @@ -318,8 +316,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) | @@ -330,7 +332,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) |