Skip to content

Commit

Permalink
torch_npu support aclnn
Browse files Browse the repository at this point in the history
  • Loading branch information
momo609 committed Nov 23, 2023
1 parent 3718a0d commit 54fb06e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 0 additions & 1 deletion mmcv/ops/csrc/common/pytorch_npu_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef PYTORCH_NPU_HELPER_HPP_
#define PYTORCH_NPU_HELPER_HPP_

#include <torch_npu/csrc/aten/CustomFunctions.h>
#include <torch_npu/csrc/framework/utils/CalcuOpUtil.h>
#include <torch_npu/csrc/framework/utils/OpAdapter.h>

Expand Down
11 changes: 10 additions & 1 deletion mmcv/ops/csrc/pytorch/npu/focal_loss_npu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ void softmax_focal_loss_forward_npu(Tensor input, Tensor target, Tensor weight,
c10::SmallVector<int64_t, 2> 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<int64_t, N> offsetVec = array_to_small_vector(offset);
c10::SmallVector<int64_t, N> 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,
Expand Down

0 comments on commit 54fb06e

Please sign in to comment.