已合并
test(fx): add tests for symbolic shapes APIs #37374
chenlan114514创建于 6月1日
test(fx): add tests for symbolic shapes APIs #37374
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 chenlan114514 的贡献)6月1日 创建了 pull request,commit 82edecc6
6月1日 关联了issue:【开源实习】Torch-NPU API一致性对齐:补齐测试用例、API功能对齐、补齐文档(15)
ascend-robot
6月1日 评论:
6月1日 评论:
6月1日 添加了label:ascend-cla/yes
ascend-robot
6月1日 评论:
6月1日 评论:
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
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
zhufu-2026, thanks for your pull request. All authors of the commits have signed the CLA. 👍


此处折叠了251条消息 查看更多
ascend-robot
6月23日 评论:
6月23日 评论:
流水线 PR-pipeline_pytorch#38648 已完成
| 阶段 | 任务名 | 状态 | 详情 |
|---|---|---|---|
| 编译构建 | 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月25日 添加了label:approvedlgtm
6月25日 合入了pull request
ascend-robot
6月25日 评论:
6月25日 评论:
流水线 pytorch_gitcode_PR_multiVersion#11304 [ commitID:2598757a ] 已完成


【合入来源】
任务:【开源实习】Torch-NPU API一致性对齐:补齐测试用例、API功能对齐、补齐文档(15)#1621
关联issue:API一致性说明:torch.fx.experimental.symbolic_shapes.ShapeEnv 系列方法在 NPU 环境无需适配
本次提交对应 Torch-NPU API 补齐任务,涉及以下 5 个 API:
torch.fx.experimental.symbolic_shapes.ShapeEnv.create_symboltorch.fx.experimental.symbolic_shapes.ShapeEnv.bound_sympytorch.fx.experimental.symbolic_shapes.ShapeEnv.check_equaltorch.fx.experimental.symbolic_shapes.ShapeEnv.cleanuptorch.fx.experimental.symbolic_shapes.ShapeEnv.bind_symbols【API 功能介绍】
create_symbol:在ShapeEnv中创建一个带初始值的符号变量,返回sympy.Symbol对象。属于符号形状管理基础操作。bound_sympy:计算符号表达式的上下界,返回包含lower和upper属性的边界对象。属于符号表达式分析操作。check_equal:校验两个ShapeEnv实例的符号状态是否完全一致。属于符号环境对比操作。cleanup:清理ShapeEnv中未使用的符号变量,释放内存。属于符号环境管理操作。bind_symbols:将符号变量与具体值绑定,返回绑定后的映射字典。属于符号变量绑定操作。【社区用例分析】
所有5个API均属于1.3类API(上游无专门测试用例,需自行编写并提交PR到test目录):
test/fx/目录下无任何针对ShapeEnv核心方法的独立测试文件test/dynamo/、test/export/等目录中有间接使用ShapeEnv的代码,但都是作为其他功能的依赖组件调用【修改方案】
test/fx/test_shape_env_methods.py,为每个API编写独立的测试用例torch.testing._internal.common_utils.TestCase基类test_create_symbol:验证符号变量的类型和命名规则test_bound_sympy:验证简单符号表达式的边界计算正确性test_check_equal:验证空ShapeEnv实例的相等性校验test_cleanup:验证环境清理后可以正常创建新的符号变量test_bind_symbols:验证空符号列表的绑定行为【资料变更】
不涉及。本PR仅补充测试用例,不包含文档修改。
【接口变更】
不涉及。未修改任何跨仓接口,也未改变用户可见的API行为。
【功能验证】
测试环境
测试场景1:新增测试用例验证
执行命令:
python -m pytest test/fx/experimental/test_symbolic_shapes.py::TestShapeEnvCoreMethods -v测试日志:
=========================================================================== test session starts =========================================================================== platform linux -- Python 3.11.13, pytest-9.0.2, pluggy-1.6.0 -- /usr/local/bin/python cachedir: .pytest_cache rootdir: /workspace/pytorch_2373 configfile: pyproject.toml collected 5 items test/fx/experimental/test_symbolic_shapes.py::TestShapeEnvCoreMethods::test_bind_symbols PASSED [ 20%] test/fx/experimental/test_symbolic_shapes.py::TestShapeEnvCoreMethods::test_bound_sympy PASSED [ 40%] test/fx/experimental/test_symbolic_shapes.py::TestShapeEnvCoreMethods::test_check_equal PASSED [ 60%] test/fx/experimental/test_symbolic_shapes.py::TestShapeEnvCoreMethods::test_cleanup PASSED [ 80%] test/fx/experimental/test_symbolic_shapes.py::TestShapeEnvCoreMethods::test_create_symbol PASSED [100%] ============================================================================ 5 passed in 4.11s ============================================================================【CheckList】