已合并
[feat] 支持 torch.nested.to_padded_tensor 在 Ascend NPU 上的算子注册与原生实现复用 #5879
[feat] 支持 torch.nested.to_padded_tensor 在 Ascend NPU 上的算子注册与原生实现复用 #5879
已合并
yucaopanmu创建于 9月14日
共 3 个文件变更+34-0
@@ -5132,6 +5132,9 @@ official:
5132 dtype: self5132 dtype: self
5133 exec: aclnnThresholdBackward5133 exec: aclnnThresholdBackward
5134 5134 
5135+ - func: to_padded_tensor(Tensor self, float padding, SymInt[]? output_size=None) -> Tensor
梁松伟
梁松伟梁松伟9月16日

补充symint声明及实现

likedislike
5136+ op_api: [v2.1, newest]
5137+ 
5135 - func: topk(Tensor self, SymInt k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices)5138 - func: topk(Tensor self, SymInt k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices)
5136 acl_op: [v2.1, newest]5139 acl_op: [v2.1, newest]
5137 op_api: [v2.1, newest]5140 op_api: [v2.1, newest]
@@ -0,0 +1,28 @@
1+// Copyright (c) 2026 Huawei Technologies Co., Ltd
2+// All rights reserved.
3+//
4+// Licensed under the BSD 3-Clause License (the "License");
5+// you may not use this file except in compliance with the License.
6+// You may obtain a copy of the License at
7+//
8+// https://opensource.org/licenses/BSD-3-Clause
9+//
10+// Unless required by applicable law or agreed to in writing, software
11+// distributed under the License is distributed on an "AS IS" BASIS,
12+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+// See the License for the specific language governing permissions and
14+// limitations under the License.
15+ 
16+#include "op_plugin/OpApiInterface.h"
17+#include <ATen/native/nested/NestedTensorMath.h>
18+ 
19+namespace op_api {
20+at::Tensor to_padded_tensor(
21+ const at::Tensor& self,
22+ double padding,
23+ at::OptionalIntArrayRef output_size) {
24+ // 调用 PyTorch 原生 CPU 实现
25+ return at::native::NestedTensor_to_padded_tensor_generic(
26+ self, padding, output_size);
27+}
28+} // namespace op_api
@@ -4073,6 +4073,9 @@
4073 "func: threshold_backward(Tensor grad_output, Tensor self, Scalar threshold) -> Tensor": {4073 "func: threshold_backward(Tensor grad_output, Tensor self, Scalar threshold) -> Tensor": {
4074 "version": ["all_version"]4074 "version": ["all_version"]
4075 },4075 },
4076+ "func: to_padded_tensor(Tensor self, float padding, SymInt[]? output_size=None) -> Tensor": {
4077+ "version": ["v2.1", "newest"]
4078+ },
4076 "func: topk(Tensor self, SymInt k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices)": {4079 "func: topk(Tensor self, SymInt k, int dim=-1, bool largest=True, bool sorted=True) -> (Tensor values, Tensor indices)": {
4077 "version": ["all_version"]4080 "version": ["all_version"]
4078 },4081 },