已合并
fix: relax _copy_from_and_resize resize condition #39354
我应该是一阵风创建于 6月26日
fix: relax _copy_from_and_resize resize condition #39354
已合并
我应该是一阵风创建于 6月26日
1 个文件变更+3-3
Mtorch_npu/csrc/aten/ops/CopyFromAndResizeKernelNpu.cpp+3-3
@@ -9,12 +9,12 @@ at::Tensor NPUNativeFunctions::_copy_from_and_resize(const at::Tensor& self, con
9 TORCH_CHECK(dst.defined(), "dst is undefined", OPS_ERROR(ErrCode::NOT_SUPPORT));9 TORCH_CHECK(dst.defined(), "dst is undefined", OPS_ERROR(ErrCode::NOT_SUPPORT));
10 TORCH_CHECK(self.defined(), "self is undefined", OPS_ERROR(ErrCode::NOT_SUPPORT));10 TORCH_CHECK(self.defined(), "self is undefined", OPS_ERROR(ErrCode::NOT_SUPPORT));
11 11 
12- if (dst.numel() == 0) {12+ if (self.sizes() != dst.sizes()) {
13 dst.resize_as_(self);13 dst.resize_as_(self);
14 }14 }
15 TORCH_CHECK(self.sizes() == dst.sizes(),15 TORCH_CHECK(self.sizes() == dst.sizes(),
16- "_copy_from_and_resize now only support copy with same size, or dst.numel() == 0!",16+ "_copy_from_and_resize size mismatch after resize: self=", self.sizes(),
17- OPS_ERROR(ErrCode::NOT_SUPPORT));17+ " dst=", dst.sizes(), OPS_ERROR(ErrCode::NOT_SUPPORT));
18 TORCH_CHECK(self.is_cpu() && dst.device().is_privateuseone(),18 TORCH_CHECK(self.is_cpu() && dst.device().is_privateuseone(),
19 "_copy_from_and_resize now only support copy from cpu tensor to npu tensor, but got src tensor device is ",19 "_copy_from_and_resize now only support copy from cpu tensor to npu tensor, but got src tensor device is ",
20 self.device(), " and dst device is ", dst.device(), OPS_ERROR(ErrCode::NOT_SUPPORT));20 self.device(), " and dst device is ", dst.device(), OPS_ERROR(ErrCode::NOT_SUPPORT));