-
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.
add a new aicore operator 'points_in_polyogns'
- Loading branch information
1 parent
4f51a93
commit f4037c3
Showing
4 changed files
with
67 additions
and
5 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
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,25 @@ | ||
#include "pytorch_npu_helper.hpp" | ||
|
||
using namespace NPU_NAME_SPACE; | ||
using namespace std; | ||
|
||
constexpr int32_t MAX_POLYGONS_BATCH = 2800; | ||
|
||
|
||
void points_in_polygons_npu(const Tensor points, Tensor polygons, Tensor output, const int rows, | ||
const int cols) { | ||
TORCH_CHECK((polygons.sizes()[0] <= MAX_POLYGONS_BATCH), | ||
"The batch of polygons tensor must be less than MAX_POLYGONS_BATCH"); | ||
at::Tensor trans_polygons = polygons.transpose(0, 1); | ||
OpCommand cmd; | ||
at::Tensor new_trans_polygons = NpuUtils::format_contiguous(trans_polygons); | ||
cmd.Name("PointsInPolygons") | ||
.Input(points, (string)"points") | ||
.Input(new_trans_polygons, (string)"polygons") | ||
.Output(output) | ||
.Run(); | ||
} | ||
|
||
void points_in_polygons_forward_impl(const Tensor points, Tensor polygons, Tensor output, const int rows, const int cols); | ||
|
||
REGISTER_NPU_IMPL(points_in_polygons_forward_impl, points_in_polygons_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
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