已合并
test(hub): add test cases for torch.hub.help and torch.hub._get_torch_home APIs #34080
xiemingda1002创建于 4月21日
test(hub): add test cases for torch.hub.help and torch.hub._get_torch_home APIs #34080
已合并
从已删除 :add-test-hub-help-api-v2.10.0合入到Ascend/pytorchv2.10.0
Pull Request已成功合入, 合并人@ascend-robot
(感谢 xiemingda1002 的贡献)4月21日 创建了 pull request,commit c5d06272
4月21日 关联了issue:[Usage]: test目录下 torch.hub.help 和 torch.hub._get_torch_home API测试用例缺失
ascend-robot
4月21日 评论:
4月21日 评论:
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 | ✅ 李伟, yuhaiyan (2/2) | ✅ 李伟 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
xiemingda1002, thanks for your pull request. All authors of the commits have signed the CLA. 👍


ascend-robot
4月21日 评论:
4月21日 评论:
4月21日 添加了label:ascend-cla/yes
此处折叠了100条消息 查看更多
haiyan8
4月25日 评论:
4月25日 评论:
/lgtm


4月25日 添加了label:approvedlgtm
ascend-robot
4月25日 评论:
4月25日 评论:
4月25日 合入了pull request
【合入来源】
【修改方案】
一、API 功能说明
torch.hub.help 和 torch.hub._get_torch_home 是 PyTorch hub 模块中用于文档查询和路径管理的辅助 API,功能说明如下:
torch.hub.help(github, model, force_reload=False, skip_validation=False, trust_repo=None)
torch.hub._get_torch_home()
上述 API 均为纯 Python 层实现,不涉及张量计算,仅负责文档查询和路径解析。
二、测试文件 test/test_hub_api.py 完整验证该 API 的原因
本测试文件针对 PyTorch 社区原生 test/test_hub.py 覆盖不足的 torch.hub.help / _get_torch_home API 进行补充验证,确保昇腾 NPU 环境下功能完整可用:
torch.hub.help API 验证
torch.hub._get_torch_home API 验证
测试隔离性保障
测试完整性
所有用例覆盖 API 的基础功能验证、接口存在性检查、环境变量交互、测试隔离性保障,完整覆盖昇腾 NPU 适配所需的最小功能集合。
三、昇腾 NPU 适配说明(解释为什么无需 NPU 适配)
torch.hub.help 和 torch.hub._get_torch_home 均具备硬件无关性、纯 Python 层实现、无底层算子依赖三大核心特征,决定了其无需针对昇腾 NPU 做适配,具体分析:
纯 Python 层抽象,无硬件相关逻辑
无底层算子 / 内核依赖
核心逻辑与硬件解耦
结论
torch.hub.help 和 torch.hub._get_torch_home 均是「硬件无关的纯 Python 层抽象」,核心逻辑不耦合任何特定硬件。测试用例无需导入 torch_npu,API 本身无需适配修改,可直接复用。
【资料变更】
刷新2.7.1版本下有多个版本资料。
1、torch.hub._get_torch_home API该API昇腾支持,但是在文档中并无描述,因此需要增加。
文档修改PR链接:https://gitcode.com/Ascend/pytorch/pull/34365
【接口变更】
不涉及
【功能验证】
测试文件路径:test/test_hub_api.py
本地验证结果:
所有测试用例执行通过。torch.hub.help 和 torch.hub._get_torch_home API 核心功能验证正常。
两个 API 均为纯 Python 层实现,不涉及张量操作,无需 NPU 设备适配。测试用例无需导入 torch_npu,API 本身可在任意硬件环境稳定运行。验证结果表明,torch.hub.help 和 torch.hub._get_torch_home 在昇腾 NPU 环境下功能正常可用,无需修改源码。
【CheckList】