-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Add the support of BallQuery op for Ascend device
- Loading branch information
Showing
2 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
// transpose new_xyz from [B, M, 3] to [M, B, 3] | ||
at::Tensor new_xyz_transpose = new_xyz.transpose(0, 1); | ||
|
||
// transpose xyz from [B, N, 3] to [B, 3, N] | ||
at::Tensor xyz_transpose = xyz.transpose(1, 2); | ||
|
||
// transpose idx from [B, M, nsample] to [M, B, nsample] | ||
at::Tensor idx_transpose = NpuUtils::format_contiguous(idx.transpose(0, 1)); | ||
|
||
OpCommand cmd; | ||
cmd.Name("BallQuery") | ||
.Input(xyz_transpose) | ||
.Input(new_xyz_transpose) | ||
.Output(idx_transpose) | ||
.Attr("min_radius", min_radius) | ||
.Attr("max_radius", max_radius) | ||
.Attr("sample_num", nsample_i64) | ||
.Run(); | ||
|
||
idx_transpose = NpuUtils::format_contiguous(idx_transpose.transpose(0, 1)); | ||
idx.copy_(idx_transpose); | ||
} | ||
|
||
|
||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters