From 4f87c6e7d249e75213a08f8c5a49ded34ac477f5 Mon Sep 17 00:00:00 2001 From: Aidenwu0209 <1418557225@qq.com> Date: Sun, 15 Feb 2026 23:47:21 +0800 Subject: [PATCH 1/5] [API Compatibility No.114] update torch.masked_fill docs for input kwarg compatibility -part --- .../args_name_diff/torch.masked_fill.md | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md index a10257123c3..9a3f314e173 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md @@ -1,20 +1,25 @@ -## [ 仅参数名不一致 ]torch.masked_fill +## [ 参数名兼容 ]torch.masked_fill ### [torch.masked_fill](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_fill.html#torch.Tensor.masked_fill) ```python torch.masked_fill(input, mask, value) ``` -### [paddle.masked\_fill](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/masked_fill_cn.html#paddle.masked_fill) +### [paddle.masked_fill](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/masked_fill_cn.html#paddle.masked_fill) ```python paddle.masked_fill(x, mask, value, name=None) ``` -两者功能一致,参数完全一致,具体如下: +两者功能一致。Paddle 已兼容 PyTorch 风格关键字 `input`,因此: + +- `paddle.masked_fill(input=..., mask=..., value=...)` +- `paddle.masked_fill(x=..., mask=..., value=...)` + +两种写法等价,无需手动改名。 ### 参数映射 -| PyTorch | PaddlePaddle | 备注 | -| ------- | ------------ | ------------------------------- | -| input | x | 输入的 Tensor,仅参数名不一致。 | -| mask | mask | 布尔张量,表示要填充的位置。 | -| value | value | 用于填充目标张量的值。 | +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | ---------------------------------------- | +| input | x / input | 默认参数名是 `x`,同时兼容 `input`。 | +| mask | mask | 布尔张量,表示要填充的位置。 | +| value | value | 用于填充目标张量的值。 | From 78a2b268d2a0fb747c7435ecde10dd39f54cc587 Mon Sep 17 00:00:00 2001 From: Aidenwu0209 <1418557225@qq.com> Date: Mon, 2 Mar 2026 21:08:56 +0800 Subject: [PATCH 2/5] fix: use valid category tag and param format to pass Docs-NEW CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Revert category from invalid "参数名兼容" to valid "仅参数名不一致" - Fix PaddlePaddle param column from "x / input" to "x" (matches signature) - Keep input kwarg compatibility info in remarks Co-Authored-By: Claude Opus 4.6 --- .../args_name_diff/torch.masked_fill.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md index 9a3f314e173..6adb5b708ff 100644 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md +++ b/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md @@ -1,4 +1,4 @@ -## [ 参数名兼容 ]torch.masked_fill +## [ 仅参数名不一致 ]torch.masked_fill ### [torch.masked_fill](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_fill.html#torch.Tensor.masked_fill) ```python torch.masked_fill(input, mask, value) @@ -9,17 +9,12 @@ torch.masked_fill(input, mask, value) paddle.masked_fill(x, mask, value, name=None) ``` -两者功能一致。Paddle 已兼容 PyTorch 风格关键字 `input`,因此: - -- `paddle.masked_fill(input=..., mask=..., value=...)` -- `paddle.masked_fill(x=..., mask=..., value=...)` - -两种写法等价,无需手动改名。 +两者功能一致,Paddle 已兼容 `input` 关键字参数,两者可直接使用。 ### 参数映射 -| PyTorch | PaddlePaddle | 备注 | -| ------- | ------------ | ---------------------------------------- | -| input | x / input | 默认参数名是 `x`,同时兼容 `input`。 | -| mask | mask | 布尔张量,表示要填充的位置。 | -| value | value | 用于填充目标张量的值。 | +| PyTorch | PaddlePaddle | 备注 | +| ------- | ------------ | --------------------------------------------------------- | +| input | x | 输入的 Tensor,仅参数名不一致,Paddle 同时支持 `input`。 | +| mask | mask | 布尔张量,表示要填充的位置。 | +| value | value | 用于填充目标张量的值。 | From 916c8344592f81649124efd7b30049bca3d4b761 Mon Sep 17 00:00:00 2001 From: Aidenwu0209 <1418557225@qq.com> Date: Tue, 3 Mar 2026 20:54:50 +0800 Subject: [PATCH 3/5] fix: address review - delete api_difference doc, update masked_fill_cn.rst Per reviewer feedback: - Remove torch.masked_fill.md since API params are now fully aligned - Update masked_fill_cn.rst to document `input` as alias for `x` kwarg Co-Authored-By: Claude Opus 4.6 --- docs/api/paddle/masked_fill_cn.rst | 3 ++- .../args_name_diff/torch.masked_fill.md | 20 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-) delete mode 100644 docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md diff --git a/docs/api/paddle/masked_fill_cn.rst b/docs/api/paddle/masked_fill_cn.rst index 36c7675fa4c..af2ddf16496 100644 --- a/docs/api/paddle/masked_fill_cn.rst +++ b/docs/api/paddle/masked_fill_cn.rst @@ -5,7 +5,8 @@ masked_fill .. py:function:: paddle.masked_fill(x, mask, value, name=None) - +.. note:: + 该 API 同时支持 ``input`` 作为 ``x`` 的别名关键字参数,与 PyTorch 用法兼容。 返回一个 1-D 的 Tensor,Tensor 的值是根据 ``mask`` 信息,将 ``value`` 中的值填充到 ``x`` 中 ``mask`` 对应为 ``True`` 的位置,``mask`` 的数据类型是 bool。 diff --git a/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md b/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md deleted file mode 100644 index 6adb5b708ff..00000000000 --- a/docs/guides/model_convert/convert_from_pytorch/api_difference/args_name_diff/torch.masked_fill.md +++ /dev/null @@ -1,20 +0,0 @@ -## [ 仅参数名不一致 ]torch.masked_fill -### [torch.masked_fill](https://pytorch.org/docs/stable/generated/torch.Tensor.masked_fill.html#torch.Tensor.masked_fill) -```python -torch.masked_fill(input, mask, value) -``` - -### [paddle.masked_fill](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/masked_fill_cn.html#paddle.masked_fill) -```python -paddle.masked_fill(x, mask, value, name=None) -``` - -两者功能一致,Paddle 已兼容 `input` 关键字参数,两者可直接使用。 - -### 参数映射 - -| PyTorch | PaddlePaddle | 备注 | -| ------- | ------------ | --------------------------------------------------------- | -| input | x | 输入的 Tensor,仅参数名不一致,Paddle 同时支持 `input`。 | -| mask | mask | 布尔张量,表示要填充的位置。 | -| value | value | 用于填充目标张量的值。 | From c7e65fbc0a7512e53a81a8623b9da690b9aed481 Mon Sep 17 00:00:00 2001 From: Aidenwu0209 <1418557225@qq.com> Date: Sun, 15 Mar 2026 23:22:37 +0800 Subject: [PATCH 4/5] fix: move masked_fill input compatibility into x param docs --- docs/api/paddle/masked_fill_cn.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/api/paddle/masked_fill_cn.rst b/docs/api/paddle/masked_fill_cn.rst index af2ddf16496..e7a13ed73ae 100644 --- a/docs/api/paddle/masked_fill_cn.rst +++ b/docs/api/paddle/masked_fill_cn.rst @@ -5,12 +5,10 @@ masked_fill .. py:function:: paddle.masked_fill(x, mask, value, name=None) -.. note:: - 该 API 同时支持 ``input`` 作为 ``x`` 的别名关键字参数,与 PyTorch 用法兼容。 返回一个 1-D 的 Tensor,Tensor 的值是根据 ``mask`` 信息,将 ``value`` 中的值填充到 ``x`` 中 ``mask`` 对应为 ``True`` 的位置,``mask`` 的数据类型是 bool。 -下图展示了一个例子:假设我们有一个所有元素值为 1 的 3x3 矩阵 `x` 和一个相同尺寸的掩码矩阵 `Mask`,`Value` 值为 3。 +下图展示了一个例子:假设我们有一个所有元素值为 1 的 3x3 矩阵 ``x`` 和一个相同尺寸的掩码矩阵 ``Mask``,``Value`` 值为 3。 .. image:: ../../images/api_legend/masked_fill.png :width: 700 @@ -19,7 +17,7 @@ masked_fill 参数 :::::::::::: - - **x** (Tensor) - 输入 Tensor,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。 + - **x** (Tensor) - 输入 Tensor,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。同时支持关键字参数 ``input`` 传入该参数,与 PyTorch 用法兼容。 - **mask** (Tensor) - 布尔张量,表示要填充的位置。mask 的数据类型必须为 bool。 - **value** (Scalar or 0-D Tensor):用于填充目标张量的值,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。 From 841fc70bdbc03d12006231aedcc72f7c24a0812d Mon Sep 17 00:00:00 2001 From: Aidenwu0209 <1418557225@qq.com> Date: Mon, 16 Mar 2026 20:05:31 +0800 Subject: [PATCH 5/5] fix: use standard alias wording in masked_fill docs --- docs/api/paddle/masked_fill_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/masked_fill_cn.rst b/docs/api/paddle/masked_fill_cn.rst index e7a13ed73ae..47351dfbe76 100644 --- a/docs/api/paddle/masked_fill_cn.rst +++ b/docs/api/paddle/masked_fill_cn.rst @@ -17,7 +17,7 @@ masked_fill 参数 :::::::::::: - - **x** (Tensor) - 输入 Tensor,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。同时支持关键字参数 ``input`` 传入该参数,与 PyTorch 用法兼容。 + - **x** (Tensor) - 输入 Tensor,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。别名 ``input``。 - **mask** (Tensor) - 布尔张量,表示要填充的位置。mask 的数据类型必须为 bool。 - **value** (Scalar or 0-D Tensor):用于填充目标张量的值,数据类型为 float,double,int,int64_t,float16 或者 bfloat16。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name`,一般无需设置,默认值为 None。