Skip to content

Commit 1157e18

Browse files
committed
fix torch
1 parent d7962b1 commit 1157e18

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

mmcv/ops/csrc/common/pytorch_npu_helper.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef PYTORCH_NPU_HELPER_HPP_
1919
#define PYTORCH_NPU_HELPER_HPP_
2020

21-
#include <torch_npu/csrc/aten/CustomFunctions.h>
2221
#include <torch_npu/csrc/framework/utils/CalcuOpUtil.h>
2322
#include <torch_npu/csrc/framework/utils/OpAdapter.h>
2423

mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,19 @@ void softmax_focal_loss_forward_npu(Tensor input, Tensor target, Tensor weight,
100100
c10::SmallVector<int64_t, 2> sizes = {n_batch, 1};
101101
at::IntArrayRef offset = at::IntArrayRef(offsets);
102102
at::IntArrayRef size = at::IntArrayRef(sizes);
103-
at_npu::native::custom_ops::npu_slice_out(op_output, offset, size, output);
103+
104+
c10::SmallVector<int64_t, SIZE> output_size = convert_array_to_vector(size);
105+
at::Tensor result = at::empty(output_size, op_output.options());
106+
c10::SmallVector<int64_t, N> offsetVec = array_to_small_vector(offset);
107+
c10::SmallVector<int64_t, N> sizeVec = array_to_small_vector(size);
108+
OpCommand cmd;
109+
cmd.Name("Slice")
110+
.Input(self)
111+
.Input(offsetVec)
112+
.Input(sizeVec)
113+
.Output(result)
114+
.Run();
115+
return result;
104116
}
105117

106118
void softmax_focal_loss_forward_impl(Tensor input, Tensor target, Tensor weight,

0 commit comments

Comments
 (0)