Skip to content

[API Compatibility No.114] support torch.masked_fill(input=...) with change-prefix mapping -part#828

Open
Aidenwu0209 wants to merge 2 commits intoPaddlePaddle:masterfrom
Aidenwu0209:api-compat-no114-masked-fill-part
Open

[API Compatibility No.114] support torch.masked_fill(input=...) with change-prefix mapping -part#828
Aidenwu0209 wants to merge 2 commits intoPaddlePaddle:masterfrom
Aidenwu0209:api-compat-no114-masked-fill-part

Conversation

@Aidenwu0209
Copy link
Contributor

@Aidenwu0209 Aidenwu0209 commented Feb 15, 2026

PR Docs

PR APIs

torch.masked_fill

Paddle PR

Description

  • Switch torch.masked_fill mapping from GenericMatcher to ChangePrefixMatcher.

Test

  • python -m pytest tests/test_masked_fill.py -q

@paddle-bot
Copy link

paddle-bot bot commented Feb 15, 2026

Thanks for your contribution!

@luotao1
Copy link
Collaborator

luotao1 commented Feb 26, 2026

请修复 CodeStyle 流水线。

@Aidenwu0209
Copy link
Contributor Author

Aidenwu0209 commented Mar 2, 2026

@luotao1 已修复,原因是 api_mapping.json 中 torch.nn.utils.rnn.pad_sequencetorch.nn.utils.rnn.unpad_sequence 的键排序位置不正确,现已按字母序重新排列,CodeStyle 流水线已通过。

},
"min_input_args": 1
},
"torch.nn.utils.rnn.pad_sequence": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个已经修改了,拉下最新即可

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已拉取最新upstream master,该排序问题已在上游修复,不再需要额外处理。

paddle_code = (
"import paddle\n\n"
"x = paddle.ones(2, 4)\n"
"result = paddle.masked_fill(mask=x > 0, input=x, value=2)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个不需要改,只有代码无法运行的时候,才改成字符串比对。正常情况下都需要直接运行来对比

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已还原,test_case_3 和 test_case_4 恢复为 obj.run(pytorch_code, ["result"]) 直接运行对比。

"import paddle\n\n"
"x = paddle.ones(2, 4)\n"
"mask = x > 0\n"
"result = paddle.masked_fill(input=x, mask=mask, value=2)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已还原。

@zhwesky2010
Copy link
Collaborator

@Aidenwu0209 PR描述里可以附录一下paddle的修改PR

…tcher

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Aidenwu0209 Aidenwu0209 force-pushed the api-compat-no114-masked-fill-part branch from 26253d0 to a3caf88 Compare March 3, 2026 12:56
@Aidenwu0209
Copy link
Contributor Author

@zhwesky2010 已根据review意见修改:

  1. 基于最新upstream master重建分支,排序问题已随上游修复
  2. test_case_3 和 test_case_4 还原为直接运行对比
  3. PR描述已补充Paddle修改PR链接

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Mar 5, 2026
@PaddlePaddle PaddlePaddle unlocked this conversation Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers HappyOpenSource 快乐开源活动issue与PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants