Skip to content

[API Compatibility No.252] Map torch.autograd.enable_grad to autograd namespace#890

Draft
neu-hsc wants to merge 1 commit into
PaddlePaddle:masterfrom
neu-hsc:codex/autograd-enable-grad
Draft

[API Compatibility No.252] Map torch.autograd.enable_grad to autograd namespace#890
neu-hsc wants to merge 1 commit into
PaddlePaddle:masterfrom
neu-hsc:codex/autograd-enable-grad

Conversation

@neu-hsc

@neu-hsc neu-hsc commented Jun 18, 2026

Copy link
Copy Markdown

Description

Update the mapping for PyTorch compatibility task No.252 in PaddlePaddle/Paddle#76301.

Changes:

  • convert torch.autograd.enable_grad with ChangePrefixMatcher
  • make PaConvert emit paddle.autograd.enable_grad() instead of paddle.enable_grad()
  • add a conversion-result assertion for the autograd namespace

Depends on PaddlePaddle/Paddle#79338.

Tests

  • python -m json.tool paconvert/api_mapping.json
  • python -m py_compile tests/test_autograd_enable_grad.py
  • python -m pytest tests/test_autograd_enable_grad.py::test_convert_to_autograd_namespace -q

Note: full tests/test_autograd_enable_grad.py execution was not available locally because this Windows environment does not have the paddle package installed. The two existing value-alignment cases failed only when executing converted Paddle code with ModuleNotFoundError: No module named 'paddle'.

@CLAassistant

CLAassistant commented Jun 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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