已合并
[test] add tests for torch.fx Graph APIs #34401
[test] add tests for torch.fx Graph APIs #34401
已合并
lihaokun-2026创建于 4月25日
lihaokun-2026
lihaokun-2026
4月25日

【合入来源】

如有社区issue,请关联issue链接
【开源实习】Torch-NPU API一致性对齐:补齐测试用例、API功能对齐、补齐文档(30) #1636
请勿携带内部流程信息(需求链接、问题单、内部issue等)

  • torch.fx.Graph.output_node
  • torch.fx.Graph.placeholder
  • torch.fx.Graph.print_tabular
  • torch.fx.Graph.process_inputs
  • torch.fx.Graph.process_outputs

【修改方案】

  1. 对目标 API 进行现状核查,确认在当前Pytorch环境中已实际支持,不需要补齐底层实现。
  2. 补充独立测试文件test/fx/test_fx_graph.py文件。
  3. 采用最小化修改方案,不改动已有底层实现,仅补齐测试覆盖。

【资料变更】

不涉及

【接口变更】

不涉及

【功能验证】

测试场景:

  1. torch.fx.Graph的5个API进行验证
  2. NPU 设备下 tensor shape 场景验证
    测试方法:
cd /data
TORCH_DEVICE_BACKEND_AUTOLOAD=1 /usr/local/python3.11.14/bin/python3 /data/pytorch/test/fx/test_fx_graph.py -v

【CheckList】

PR提交人对以下CheckList自检项进行全量自检,自检通过或不涉及,均修改 [ ] 为 [x]

likedislike
Pull Request已成功合入, 合并人@ascend-robot
(感谢 lihaokun-2026 的贡献)
lihaokun-2026lihaokun-2026
4月25日 创建了 pull request,commit abb4d750
lihaokun-2026lihaokun-2026
4月25日 关联了issue:【开源实习】Torch-NPU API一致性对齐:补齐测试用例、API功能对齐、补齐文档(30)
ascend-robot
ascend-robot成员
4月25日 评论:

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 huangjingwei, 李伟 (2/2) 李伟 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

lihaokun-2026, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
ascend-robotascend-robot成员
4月25日 添加了label:ascend-cla/yes
ascend-robot
ascend-robot成员
4月25日 评论:

当前仓库存在以下 保护分支

Protected Branch Version Release
master
v2.7.1
v2.8.0
v2.9.0
v2.10.0
v2.11.0

评论 /sync <branch1> <branch2> ... 可将当前 PR 修改同步到其它分支(创建同步 PR):
a) 如果当前 PR 是 Open 状态,同步操作将延迟到 PR 被合并时执行
b) 如果当前 PR 已经 Merged,将立即执行同步操作

注意:

  1. /sync 命令可以指定同步到多个分支,仅最后一个 /sync 命令生效
  2. 如果创建的同步 PR 不正确,可通过向同步 PR 的源分支提交轻量级 PR 完善,或使用 /close 命令关闭
likedislike
lihaokun-2026
lihaokun-2026
4月25日 评论:

compile

likedislike
ascend-robotascend-robot成员
4月25日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
4月25日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
4月25日 添加了label:ci-pipeline-failed
ascend-robot
ascend-robot成员
4月25日 评论:
流水线 PR-pipeline_pytorch#17366 运行失败
阶段 任务名 状态 详情
编译构建 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_DIST_X86_Part_01 🕚 >>>
UT_DIST_X86_Part_02 🕚 >>>
UT_DIST_X86_Part_03 🕚 >>>
UT_DIST_X86_Part_04 🕚 >>>
UT_inductor_Part_01 🕚 >>>
UT_inductor_Part_02 🕚 >>>
UT_inductor_Part_03 🕚 >>>
UT_inductor_Part_04 🕚 >>>
UT_ARM_A2_Part_01 🕚 >>>
UT_ARM_A2_Part_02 🕚 >>>
UT_ARM_A2_Part_03 🕚 >>>
流水线 PR-pipeline_pytorch >>>
likedislike
lihaokun-2026
lihaokun-2026
4月26日 评论:

compile

likedislike
ascend-robotascend-robot成员
4月26日 删除了label:ci-pipeline-failed
ascend-robotascend-robot成员
4月26日 添加了label:ci-pipeline-running
ascend-robotascend-robot成员
4月26日 删除了label:ci-pipeline-running
ascend-robotascend-robot成员
4月26日 添加了label:ci-pipeline-passed
ascend-robot
ascend-robot成员
4月26日 评论:
流水线 PR-pipeline_pytorch#17477 已完成
阶段 任务名 状态 详情
编译构建 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_DIST_X86_Part_01 🛑 >>>
UT_DIST_X86_Part_02 🛑 >>>
UT_DIST_X86_Part_03 🛑 >>>
UT_DIST_X86_Part_04 🛑 >>>
UT_inductor_Part_01 🛑 >>>
UT_inductor_Part_02 🛑 >>>
UT_inductor_Part_03 🛑 >>>
UT_inductor_Part_04 🛑 >>>
UT_ARM_A2_Part_01 >>>
UT_ARM_A2_Part_02 >>>
UT_ARM_A2_Part_03 >>>
流水线 PR-pipeline_pytorch >>>
likedislike
Jingwei Huang
Jingwei Huang成员
5月7日 评论:

/lgtm

likedislike
lihaokun-2026lihaokun-2026
5月9日 修改了pull request 的描述
openLiBingCI成员
5月9日 评论:

本PR中共发现代码检查告警抑制1处,请Committer检视合理性

本评论自动扫描PR中使用的开源代码检查工具(ruff、clang-tidy、CodeQL等)的屏蔽注释。
这些屏蔽注释会阻止开源代码检查工具对特定代码区域的检测,可能导致潜在问题被忽略。

点击下载完整报告

文件路径 行号 屏蔽类型 代码片段 工具名称
test/fx/test_fx_graph.py 68 行级屏蔽 63: self.assertTrue(torch.allclose(cpu_out, npu_out, rtol=1e-3, atol=1e-3))
65: @unittest.skipUnless(torch.npu.is_available(), "requires npu")
66: def test_graph_print_tabular_with_npu_meta(self):
67: try:
68: import tabulate # noqa: F401
69: except ImportError:
70: self.skipTest("tabulate is not installed")
72: graph = Graph()
74: x = graph.placeholder("x")
75: x.meta["example_value"] = torch.randn(2, 3).npu()
flake8
likedislike
liwei386成员
5月11日 评论:

/approve

likedislike
ascend-robotascend-robot成员
5月11日 添加了label:approvedlgtm
openLiBingCI成员
5月11日 评论:

本PR中共发现代码检查告警抑制1处,请Committer检视合理性

本评论自动扫描PR中使用的开源代码检查工具(ruff、clang-tidy、CodeQL等)的屏蔽注释。
这些屏蔽注释会阻止开源代码检查工具对特定代码区域的检测,可能导致潜在问题被忽略。

点击下载完整报告

文件路径 行号 屏蔽类型 代码片段 工具名称
test/fx/test_fx_graph.py 68 行级屏蔽 63: self.assertTrue(torch.allclose(cpu_out, npu_out, rtol=1e-3, atol=1e-3))
65: @unittest.skipUnless(torch.npu.is_available(), "requires npu")
66: def test_graph_print_tabular_with_npu_meta(self):
67: try:
68: import tabulate # noqa: F401
69: except ImportError:
70: self.skipTest("tabulate is not installed")
72: graph = Graph()
74: x = graph.placeholder("x")
75: x.meta["example_value"] = torch.randn(2, 3).npu()
flake8
likedislike
ascend-robot
ascend-robot成员
5月11日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: 李伟.
Reviewers who wrote a comment of /lgtm are: 李伟, huangjingwei.

likedislike
ascend-robotascend-robot成员
5月11日 合入了pull request