10 #include <tensorflow/core/framework/op.h>
11 #include <tensorflow/core/framework/op_kernel.h>
12 #include <tensorflow/core/lib/core/errors.h>
16 template <
class TIndex>
20 : OpKernel(construction) {
21 using namespace tensorflow;
23 OP_REQUIRES_OK(construction,
24 construction->GetAttr(
"normalize", &
normalize));
26 OP_REQUIRES_OK(construction, construction->GetAttr(
"max_temp_mem_MB",
31 using namespace tensorflow;
33 static_assert(
sizeof(int64) ==
sizeof(int64_t),
34 "int64 type is not compatible");
35 const Tensor& filters =
context->input(0);
36 const Tensor& inp_features =
context->input(1);
37 const Tensor& inp_importance =
context->input(2);
38 const Tensor& neighbors_index =
context->input(3);
39 const Tensor& neighbors_kernel_index =
context->input(4);
40 const Tensor& neighbors_importance =
context->input(5);
41 const Tensor& neighbors_row_splits =
context->input(6);
43 Dim num_out(
"num_out");
44 Dim num_inp(
"num_inp");
45 Dim num_kernel_elements(
"num_kernel_elements");
46 Dim in_channels(
"in_channels");
47 Dim out_channels(
"out_channels");
48 Dim num_neighbors(
"num_neighbors");
51 in_channels, out_channels);
59 TensorShape out_features_shape({num_out.
value(), out_channels.
value()});
60 Tensor* out_features =
nullptr;
61 OP_REQUIRES_OK(
context,
context->allocate_output(0, out_features_shape,
64 std::vector<int> filter_dims;
65 for (
int i = 0; i < filters.dims(); ++i) {
66 filter_dims.push_back(filters.dim_size(i));
69 bool point_importances = inp_importance.shape().dim_size(0) != 0;
71 bool has_neighbors_importances =
72 neighbors_importance.shape().dim_size(0) != 0;
74 Kernel(
context, filters, inp_features, inp_importance, neighbors_index,
75 neighbors_kernel_index, neighbors_importance,
76 neighbors_row_splits, filter_dims, point_importances,
77 has_neighbors_importances, *out_features);
81 const tensorflow::Tensor& filters,
82 const tensorflow::Tensor& inp_features,
83 const tensorflow::Tensor& inp_importance,
84 const tensorflow::Tensor& neighbors_index,
85 const tensorflow::Tensor& neighbors_kernel_index,
86 const tensorflow::Tensor& neighbors_importance,
87 const tensorflow::Tensor& neighbors_row_splits,
88 const std::vector<int>& filter_dims,
89 const bool point_importances,
90 const bool has_neighbors_importances,
91 tensorflow::Tensor& out_features) = 0;
#define CHECK_SHAPE_COMBINE_FIRST_DIMS(tensor,...)
Definition: TorchHelper.h:195
#define CHECK_SHAPE(tensor,...)
Definition: TorchHelper.h:186
ImGuiContext * context
Definition: Window.cpp:76
Definition: SparseConvOpKernel.h:17
int max_temp_mem_MB
Definition: SparseConvOpKernel.h:95
void Compute(tensorflow::OpKernelContext *context) override
Definition: SparseConvOpKernel.h:30
bool normalize
Definition: SparseConvOpKernel.h:94
SparseConvOpKernel(tensorflow::OpKernelConstruction *construction)
Definition: SparseConvOpKernel.h:19
virtual void Kernel(tensorflow::OpKernelContext *context, const tensorflow::Tensor &filters, const tensorflow::Tensor &inp_features, const tensorflow::Tensor &inp_importance, const tensorflow::Tensor &neighbors_index, const tensorflow::Tensor &neighbors_kernel_index, const tensorflow::Tensor &neighbors_importance, const tensorflow::Tensor &neighbors_row_splits, const std::vector< int > &filter_dims, const bool point_importances, const bool has_neighbors_importances, tensorflow::Tensor &out_features)=0
Class for dimensions for which the value should be inferred.
Definition: ShapeChecking.h:50
int64_t & value()
Definition: ShapeChecking.h:70
Definition: ShapeChecking.h:16