-
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.
Co-authored-by: lizekai <[email protected]>
- Loading branch information
1 parent
b91cfde
commit 8f23a0b
Showing
3 changed files
with
54 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,21 @@ | ||
#include "pytorch_npu_helper.hpp" | ||
#include "torch_npu/csrc/aten/NPUNativeFunctions.h" | ||
#include "torch_npu/csrc/framework/utils/OpAdapter.h" | ||
|
||
using namespace NPU_NAME_SPACE; | ||
using namespace std; | ||
|
||
void knn_forward_npu(int b, int n, int m, int nsample, const Tensor xyz, | ||
const Tensor new_xyz, Tensor idx, Tensor dist2) { | ||
// transpose known from [B, N, 3] to [B, 3, N] | ||
at::Tensor source = xyz.transpose(1, 2).contiguous(); | ||
at::Tensor target = new_xyz.contiguous(); | ||
|
||
bool is_from_knn = true; | ||
EXEC_NPU_CMD(aclnnKnn, source, target, nsample, is_from_knn, idx, dist2); | ||
} | ||
|
||
void knn_forward_impl(int b, int n, int m, int nsample, const Tensor xyz, | ||
const Tensor new_xyz, Tensor idx, Tensor dist2); | ||
|
||
REGISTER_NPU_IMPL(knn_forward_impl, knn_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "pytorch_npu_helper.hpp" | ||
#include "torch_npu/csrc/aten/NPUNativeFunctions.h" | ||
#include "torch_npu/csrc/framework/utils/OpAdapter.h" | ||
|
||
using namespace NPU_NAME_SPACE; | ||
using namespace std; | ||
|
||
void three_nn_forward_npu(int b, int n, int m, const Tensor unknown, | ||
const Tensor known, Tensor dist2, Tensor idx) { | ||
// transpose known [B, N, 3] -> [B, 3, N] | ||
at::Tensor source = known.transpose(1, 2).contiguous(); | ||
at::Tensor target = unknown.contiguous(); | ||
auto originDtype = source.scalar_type(); | ||
if (originDtype == at::kHalf) { | ||
source = source.to(at::kFloat); | ||
target = target.to(at::kFloat); | ||
} | ||
|
||
bool is_from_knn = false; | ||
uint32_t nsample = 3; | ||
EXEC_NPU_CMD(aclnnKnn, source, target, nsample, is_from_knn, idx, dist2); | ||
if (originDtype == at::kHalf) { | ||
dist2 = dist2.to(at::kHalf); | ||
} | ||
} | ||
|
||
void three_nn_forward_impl(int b, int n, int m, const Tensor unknown, | ||
const Tensor known, Tensor dist2, Tensor idx); | ||
|
||
REGISTER_NPU_IMPL(three_nn_forward_impl, three_nn_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