Skip to content

[API Compatibility] add torch.randint -part#801

Open
Manfredss wants to merge 3 commits into
PaddlePaddle:masterfrom
Manfredss:ApiEnhance352_372
Open

[API Compatibility] add torch.randint -part#801
Manfredss wants to merge 3 commits into
PaddlePaddle:masterfrom
Manfredss:ApiEnhance352_372

Conversation

@Manfredss
Copy link
Copy Markdown
Contributor

@Manfredss Manfredss commented Jan 10, 2026

PR Docs

add torch.randint

PR APIs

torch.randint

related paddle pr: 77194

@paddle-bot
Copy link
Copy Markdown

paddle-bot Bot commented Jan 10, 2026

Thanks for your contribution!

@paddle-bot paddle-bot Bot added the contributor External developers label Jan 10, 2026
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jan 23, 2026
@PaddlePaddle PaddlePaddle unlocked this conversation Jan 23, 2026
@Manfredss Manfredss changed the title [API Compatibility No.352、372] add torch.std and torch.randint -part [API Compatibility No.372] add torch.randint -part Jan 30, 2026
@zhwesky2010
Copy link
Copy Markdown
Collaborator

这个需要修改torch.randint的Matcher为ChangePrefixMatcher

@luotao1 luotao1 changed the title [API Compatibility No.372] add torch.randint -part [API Compatibility] add torch.randint -part Mar 4, 2026
@Manfredss Manfredss closed this Apr 11, 2026
@Manfredss Manfredss deleted the ApiEnhance352_372 branch April 11, 2026 08:09
@Manfredss Manfredss restored the ApiEnhance352_372 branch April 11, 2026 08:21
@Manfredss Manfredss reopened this Apr 11, 2026
…fixMatcher unsupported args

- Change torch.randint matcher from RandintMatcher to ChangePrefixMatcher
- Add requires_grad, pin_memory, device to ChangePrefixMatcher unsupported args list
- Disable 2 incompatible test cases (2-arg form)
- Add 15 new test cases covering keyword args, shuffled args, *args/**kwargs unpacking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread paconvert/api_matcher.py Outdated

# temporary delete these unsupport args, which paddle does not support now
for k in ["layout", "generator", "memory_format", "sparse_grad", "foreach"]:
for k in ["layout", "generator", "memory_format", "sparse_grad", "requires_grad", "pin_memory", "device", "foreach"]:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这些不能改,这些参数都是需要支持的

@zhwesky2010
Copy link
Copy Markdown
Collaborator

@Manfredss PR还需要改下

@Manfredss
Copy link
Copy Markdown
Contributor Author

Manfredss commented Apr 28, 2026

@Manfredss PR还需要改下

这样改了之后 test_case_12 会报错, 因为 paddle.randint 现在不支持 pin_memory=True on CPU(会 raise error),但是 torch 支持分配 pinned host memory. 需要修改 paddle.randint 吗 @zhwesky2010

@Manfredss
Copy link
Copy Markdown
Contributor Author

image

@zhwesky2010 修改后的 randint api 在 paconvert 上测试通过

Copy link
Copy Markdown
Collaborator

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

这个API还有其他地方没对齐吗

Comment thread tests/test_randint.py Outdated


def test_case_2():
def _test_case_2(): # 2-arg form: paddle.randint(low, high, shape) signature differs from torch.randint(high, size)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个是什么bug,也需要修下

Comment thread tests/test_randint.py Outdated


def test_case_10():
def _test_case_10(): # 2-arg form: paddle.randint(low, high, shape) signature differs from torch.randint(high, size)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个是什么bug,也需要修下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants