已合并
[feat] 支持 torch.nested.to_padded_tensor 在 Ascend NPU 上的算子注册与原生实现复用 #5879
yucaopanmu创建于 25 天前
[feat] 支持 torch.nested.to_padded_tensor 在 Ascend NPU 上的算子注册与原生实现复用 #5879
已合并
Pull Request已成功合入, 合并人@ascend-robot
(感谢 yucaopanmu 的贡献)25 天前 创建了 pull request,commit 6095fec3
atomgit-bot
25 天前 评论:
25 天前 评论:
变更摘要
本 PR 为 to_padded_tensor 算子新增 NPU op_api 支持:在 op_plugin_functions.yaml 中注册该算子的 op_api 接口配置,并新增 NestedTensorToPaddedTensorKernelNpuOpApi.cpp 实现文件,在 op_api 命名空间中提供 to_padded_tensor 实现,将 SymInt[]? 参数转换为 OptionalIntArrayRef 后调用 PyTorch 原生实现 NestedTensor_to_padded_tensor_generic。
主要改动
- 注册算子接口: 在
op_plugin/config/op_plugin_functions.yaml中新增to_padded_tensor(Tensor self, float padding, SymInt[]? output_size=None) -> Tensor的接口注册,配置op_api: [v2.1, newest]版本支持。 - 新增 opapi 内核实现: 新增文件
op_plugin/ops/opapi/NestedTensorToPaddedTensorKernelNpuOpApi.cpp,在op_api命名空间中实现to_padded_tensor函数,接收at::OptionalSymIntArrayRef类型的output_size参数。 - 参数类型转换与实现委托: 将
SymInt[]?通过expect_int()逐元素转换为std::vector<int64_t>,构造at::OptionalIntArrayRef(无值时使用c10::nullopt),最终委托给at::native::NestedTensor_to_padded_tensor_generic执行。


不准确?
AtlasAccount
25 天前 评论:
25 天前 评论:
atomgit-bot
25 天前 评论:
25 天前 评论:
25 天前 添加了label:ascend-cla/yes
此处折叠了106条消息 查看更多
ascend-robot
23 天前 评论:
23 天前 评论:
Pull Request 已合并或已关闭。
If you want to solve this problem, you can click here to do it in the FAQs.


action-bot
23 天前 评论:
23 天前 评论:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


23 天前 删除了label:ci-pipeline-passed
21 天前 添加了label:ci-pipeline-passed
ascend-robot
21 天前 评论:
21 天前 评论:
The following label is not ready.
ci-pipeline-passed: You can't add ci-pipeline-passed label manually. Please remove it and wait for the CI test to be completed.


【合入来源】
【修改方案】
采用 双仓联动 的方式打通该路径:
torchnpugen/gen_backend_stubs.py)为NestedTensorRegister补充to_padded_tensor的注册,并引入op_plugin/OpApiInterface.h头文件,将算子注册到NestedTensorPrivateUse1dispatch key。op_api命名空间中提供to_padded_tensor的 kernel 实现,复用 PyTorch 原生设备泛化实现at::native::NestedTensor_to_padded_tensor_generic,完成实际的补齐转换。【资料变更】
不涉及
【接口变更】
不涉及
【功能验证】
本地端到端验证已通过
【CheckList】