10 #include "../TensorFlowHelper.h"
12 #include "tensorflow/core/framework/op.h"
13 #include "tensorflow/core/framework/op_kernel.h"
14 #include "tensorflow/core/lib/core/errors.h"
18 namespace radius_search_opkernel {
20 class RadiusSearchOpKernel :
public tensorflow::OpKernel {
22 explicit RadiusSearchOpKernel(
23 tensorflow::OpKernelConstruction* construction)
24 : OpKernel(construction) {
26 using namespace tensorflow;
27 std::string metric_str;
28 OP_REQUIRES_OK(construction,
29 construction->GetAttr(
"metric", &metric_str));
30 if (metric_str ==
"L1")
35 OP_REQUIRES_OK(construction,
36 construction->GetAttr(
"ignore_query_point",
37 &ignore_query_point));
39 OP_REQUIRES_OK(construction, construction->GetAttr(
"return_distances",
41 OP_REQUIRES_OK(construction,
42 construction->GetAttr(
"normalize_distances",
43 &normalize_distances));
46 void Compute(tensorflow::OpKernelContext*
context)
override {
47 using namespace tensorflow;
48 static_assert(
sizeof(int64) ==
sizeof(int64_t),
49 "int64 type is not compatible");
52 const Tensor& queries =
context->input(1);
53 const Tensor& radii =
context->input(2);
54 const Tensor& points_row_splits =
context->input(3);
55 const Tensor& queries_row_splits =
context->input(4);
59 Dim num_points(
"num_points");
60 Dim num_queries(
"num_queries");
61 Dim batch_size(
"batch_size");
69 Tensor* query_neighbors_row_splits = 0;
70 TensorShape query_neighbors_row_splits_shape(
71 {queries.shape().dim_size(0) + 1});
73 1, query_neighbors_row_splits_shape,
74 &query_neighbors_row_splits));
77 queries_row_splits, *query_neighbors_row_splits);
80 virtual void Kernel(tensorflow::OpKernelContext*
context,
81 const tensorflow::Tensor&
points,
82 const tensorflow::Tensor& queries,
83 const tensorflow::Tensor& radius,
84 const tensorflow::Tensor& points_row_splits,
85 const tensorflow::Tensor& queries_row_splits,
86 tensorflow::Tensor& query_neighbors_row_splits) = 0;
90 bool ignore_query_point;
91 bool return_distances;
92 bool normalize_distances;
#define CHECK_SHAPE(tensor,...)
Definition: TorchHelper.h:186
ImGuiContext * context
Definition: Window.cpp:76
Class for dimensions for which the value should be inferred.
Definition: ShapeChecking.h:50
Definition: FixedRadiusIndex.cpp:16
Metric
Supported metrics.
Definition: NeighborSearchCommon.h:19
@ L1
Definition: NeighborSearchCommon.h:19
@ L2
Definition: NeighborSearchCommon.h:19
Definition: ShapeChecking.h:16