From 54fb06efab85fa54b6455725af661441117b155e Mon Sep 17 00:00:00 2001 From: momo609 <963372609@qq.com> Date: Thu, 23 Nov 2023 18:53:36 +0800 Subject: [PATCH] torch_npu support aclnn --- mmcv/ops/csrc/common/pytorch_npu_helper.hpp | 1 - mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mmcv/ops/csrc/common/pytorch_npu_helper.hpp b/mmcv/ops/csrc/common/pytorch_npu_helper.hpp index d01d313c56a..82e80276ed6 100644 --- a/mmcv/ops/csrc/common/pytorch_npu_helper.hpp +++ b/mmcv/ops/csrc/common/pytorch_npu_helper.hpp @@ -18,7 +18,6 @@ #ifndef PYTORCH_NPU_HELPER_HPP_ #define PYTORCH_NPU_HELPER_HPP_ -#include #include #include diff --git a/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp b/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp index b7c995a223e..c032317d751 100644 --- a/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp +++ b/mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp @@ -100,7 +100,16 @@ void softmax_focal_loss_forward_npu(Tensor input, Tensor target, Tensor weight, c10::SmallVector sizes = {n_batch, 1}; at::IntArrayRef offset = at::IntArrayRef(offsets); at::IntArrayRef size = at::IntArrayRef(sizes); - at_npu::native::custom_ops::npu_slice_out(op_output, offset, size, output); + at::IntArrayRef size_array = at::IntArrayRef(sizes); + c10::SmallVector offsetVec = array_to_small_vector(offset); + c10::SmallVector sizeVec = array_to_small_vector(size_array); + OpCommand cmd2; + cmd2.Name("Slice") + .Input(op_output) + .Input(offsetVec) + .Input(sizeVec) + .Output(output) + .Run(); } void softmax_focal_loss_forward_impl(Tensor input, Tensor target, Tensor weight,