已合并
test(fx): add create_args_for_root testcases into test_fx_tracer_create_arg.py #37611
q15546010075创建于 6月4日
test(fx): add create_args_for_root testcases into test_fx_tracer_create_arg.py #37611
已合并
Q
q15546010075
6月4日
6月4日
# 【合入来源】
- [x] 问题单
> https://gitcode.com/Ascend/pytorch/issues/2235
pytorch社区用例没有验证torch.fx.Tracer.create_args_for_root,故将该API测试用例合入已有的test_fx_tracer_create_arg.py中统一维护。
# 【修改方案】
一、API 功能说明
`torch.fx.Tracer.create_args_for_root(root_fn, is_module, concrete_args=None)` 在符号追踪过程中,根据被追踪函数/模块的签名为每个参数创建 placeholder 代理节点。纯 Python 层操作,不涉及张量计算或硬件驱动。
二、修改内容
在已有的 `test/fx/test_fx_tracer_create_arg.py` 基础上追加 `create_args_for_root` 的 7 个测试方法到 `TestTracerCreateArg` 类中,覆盖 Module 模式、Function 模式、concrete_args(dict/tuple)、默认值参数等核心路径。同时在文件顶部(类外)新增 TwoArgModule、DefaultArgModule 供新用例使用。原有代码零修改。
三、NPU适配
该 API 纯粹操作 Python 函数签名和 FX Graph IR 节点,内部仅调用 inspect 标准库和 PyTorch 纯 Python 层数据结构,不依赖 CUDA/NPU 扩展库或底层驱动,无需 NPU 适配。用例中所有断言均针对 Python 对象属性,无张量创建或设备操作。
# 【资料变更】
已检查 `docs/zh/native_apis` 各版本目录,`torch.fx.Tracer.create_args_for_root` 均已标注为"是"(支持),文档状态与实际一致,无需修改文档。
# 【接口变更】
> 不涉及
# 【功能验证】
在 v2.10.0 环境上执行该用例,通过,日志如下:
```
(venv_2.10.0) root@npu1-2:/tmp# python3 test_fx_tracer_create_arg.py
............
......
----------------------------------------------------------------------
Ran 19 tests in 1.161s
OK
```
# 【CheckList】
- [x] 代码注释完备,正确记录错误日志
- [x] 代码实现进行了返回值、空指针等校验
- [x] PR标题正确使用类型标签,如:feat、fix、refactor、docs、test等
- [x] PR持续集成流水线(CI)执行通过,代码检查无异常


Pull Request已成功合入, 合并人@ascend-robot
(感谢 q15546010075 的贡献)6月4日 创建了 pull request,commit dbc2f8aa
6月4日 关联了issue:[Usage]: API一致性说明:torch.fx.Tracer.create_args_for_root 需补充 NPU 环境测试用例
ascend-robot
6月4日 评论:
6月4日 评论:
6月4日 添加了label:ascend-cla/yes
ascend-robot
6月4日 评论:
6月4日 评论:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| test | ✅ 李伟, sunyu-xuan (2/2) | ✅ 李伟 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
q15546010075, thanks for your pull request. All authors of the commits have signed the CLA. 👍


ascend-robot
6月4日 评论:
6月4日 评论:
当前仓库存在以下 保护分支 :
| Protected Branch | Version | Release |
|---|---|---|
| master | ||
| v2.7.1 | ||
| v2.10.0 | ||
| v2.9.0 | ||
| v2.11.0 | ||
| v2.12.0 | ||
| ci-test | ||
| sync-pr28113--to-v2.9.0 |
评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作
注意:
- /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
- 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭


ascend-robot
6月4日 评论:
6月4日 评论:
Ascend docs pipeline is running...


6月4日 添加了label:docs-ci-pipeline-running
ascend-robot
6月4日 评论:
6月4日 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


6月4日 删除了label:docs-ci-pipeline-running
6月4日 添加了label:docs-ci-pipeline-success
q15546010075
6月4日 评论:
6月4日 评论:
compile


6月4日 添加了label:ci-pipeline-running
ascend-robot
6月4日 评论:
6月4日 评论:
Ascend docs pipeline is running...


6月4日 删除了label:docs-ci-pipeline-success
6月4日 添加了label:docs-ci-pipeline-running
ascend-robot
6月4日 评论:
6月4日 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


6月4日 删除了label:docs-ci-pipeline-running
6月4日 添加了label:docs-ci-pipeline-success
6月4日 删除了label:ci-pipeline-running
6月4日 添加了label:ci-pipeline-passed
ascend-robot
6月4日 评论:
6月4日 评论:
流水线 PR-pipeline_pytorch#29767 已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_DIST_ARM_Part_01 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04 | 🛑 | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |


sunyu-xuan
6月5日 评论:
6月5日 评论:
/lgtm


q15546010075
6月8日 评论:
6月8日 评论:
compile


6月8日 删除了label:ci-pipeline-passed
6月8日 添加了label:ci-pipeline-running
ascend-robot
6月8日 评论:
6月8日 评论:
Ascend docs pipeline is running...


6月8日 删除了label:docs-ci-pipeline-success
6月8日 添加了label:docs-ci-pipeline-running
ascend-robot
6月8日 评论:
6月8日 评论:
✅ 跳过 docs ci 检查,没有需要检查的文档文件


6月8日 删除了label:docs-ci-pipeline-running
6月8日 添加了label:docs-ci-pipeline-success
6月8日 删除了label:ci-pipeline-running
6月8日 添加了label:ci-pipeline-passed
ascend-robot
6月8日 评论:
6月8日 评论:
流水线 PR-pipeline_pytorch#30168 已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | Build_X86 | ✅ | >>> |
| Build_ARM | ✅ | >>> | |
| Build_LibTorch_x86 | ✅ | >>> | |
| Build_LibTorch_ARM | ✅ | >>> | |
| Build_X86_torchair | 🛑 | >>> | |
| Build_ARM_torchair | 🛑 | >>> | |
| patch_test | 🛑 | >>> | |
| 恶意代码检查 | Antipoison | ✅ | >>> |
| 编码安全与规范检查 | CodeCheck | ✅ | >>> |
| check_error | ✅ | >>> | |
| CodeCheck_lintrunner | ✅ | >>> | |
| 开源片段检查 | SCA | ✅ | >>> |
| 开发者测试 | UT_X86_Part_01 | 🛑 | >>> |
| UT_X86_Part_02 | 🛑 | >>> | |
| UT_ARM_A3_Part_01 | 🛑 | >>> | |
| UT_ARM_A3_Part_02 | 🛑 | >>> | |
| UT_ARM_A2_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Part_02 | ✅ | >>> | |
| UT_ARM_A2_Part_03 | ✅ | >>> | |
| UT_inductor_Part_01 | 🛑 | >>> | |
| UT_inductor_Part_02 | 🛑 | >>> | |
| UT_inductor_Part_03 | 🛑 | >>> | |
| UT_inductor_Part_04 | 🛑 | >>> | |
| UT_DIST_ARM_Part_01 | 🛑 | >>> | |
| UT_DIST_ARM_Part_02 | 🛑 | >>> | |
| UT_DIST_ARM_Part_03 | 🛑 | >>> | |
| UT_DIST_ARM_Part_04 | 🛑 | >>> | |
| UT_ARM_A2_Select_Part_01 | ✅ | >>> | |
| UT_ARM_A2_Select_Part_02 | ✅ | >>> | |
| 流水线 | PR-pipeline_pytorch | ✅ | >>> |


6月8日 添加了label:approvedlgtm
6月8日 合入了pull request
ascend-robot
6月8日 评论:
6月8日 评论:
流水线 pytorch_gitcode_PR_multiVersion#10197 [ commitID:a8a72dbf ] 已完成

