Skip to content

Commit

Permalink
[Feature] Add the support of BallQuery op for Ascend device
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginray committed Sep 8, 2023
1 parent 7208406 commit c8605b2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions mmcv/ops/csrc/pytorch/npu/ball_query_npu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "pytorch_npu_helper.hpp"

using namespace NPU_NAME_SPACE;
using namespace std;

void ball_query_forward_npu(int b, int n, int m, float min_radius,
float max_radius, int nsample,
const Tensor new_xyz, const Tensor xyz,
Tensor idx) {
int64_t nsample_i64 = nsample;
at::Tensor new_xyz_transpose = at::zeros_like(new_xyz);
at::Tensor xyz_transpose = at::zeros_like(xyz);

// transpose new_xyz from [B, M, 3] to [M, B, 3]
new_xyz_transpose = new_xyz.transpose(0, 1)

// transpose xyz from [B, N, 3] to [B, 3, N]
xyz_transpose = xyz.transpose(1, 2)

OpCommand cmd;
cmd.Name("BallQuery")
.Input(xyz_transpose)
.Input(new_xyz_transpose)
.Output(idx)
.Attr("min_radius", min_radius)
.Attr("max_radius", max_radius)
.Attr("sample_num", nsample_i64)
.Run();

// transpose idx from [M, B, nsample] to [B, M, nsample]
idx = idx.transpose(0,1);
}


void ball_query_forward_impl(int b, int n, int m, float min_radius,
float max_radius, int nsample,
const Tensor new_xyz, const Tensor xyz,
Tensor idx);

REGISTER_NPU_IMPL(ball_query_forward_impl, ball_query_forward_npu);

0 comments on commit c8605b2

Please sign in to comment.