55 void Compute(tensorflow::OpKernelContext* context)
override {
56 using namespace tensorflow;
57 static_assert(
sizeof(int64) ==
sizeof(int64_t),
58 "int64 type is not compatible");
59 const Tensor& filter = context->input(0);
61 const Tensor& out_positions = context->input(1);
63 out_positions.shape().dim_size(0) <=
64 std::numeric_limits<TIndex>::max(),
65 errors::InvalidArgument(
"Too many output points"));
67 const Tensor& extents = context->input(2);
68 OP_REQUIRES(context, extents.shape().dims() == 2,
69 errors::InvalidArgument(
"extents must be a rank 2 tensor"));
71 extents.shape().dim_size(0) ==
72 out_positions.shape().dim_size(0) ||
73 extents.shape().dim_size(0) == 1,
74 errors::InvalidArgument(
"number of extents must match the "
75 "number of out_positions or must "
78 extents.shape().dim_size(1) == 3 ||
79 extents.shape().dim_size(1) == 1,
80 errors::InvalidArgument(
81 "number of components for extents must be 3 or 1"));
83 const Tensor& offset = context->input(3);
84 OP_REQUIRES(context, offset.shape().dims() == 1,
85 errors::InvalidArgument(
"offset must be a rank 1 tensor"));
86 OP_REQUIRES(context, offset.shape().dim_size(0) == 3,
87 errors::InvalidArgument(
"offset length must be 3"));
89 const Tensor& inp_positions = context->input(4);
91 inp_positions.shape().dim_size(0) <=
92 std::numeric_limits<TIndex>::max(),
93 errors::InvalidArgument(
"Too many input points"));
95 const Tensor& inp_features = context->input(5);
97 const Tensor& inp_importance = context->input(6);
99 const Tensor& neighbors_index = context->input(7);
101 const Tensor& neighbors_importance = context->input(8);
103 const Tensor& neighbors_row_splits = context->input(9);
105 const Tensor& out_features_gradient = context->input(10);
109 inp_positions.shape().dim_size(0) ==
110 inp_features.shape().dim_size(0),
111 errors::InvalidArgument(
"first dim of inp_positions does not "
112 "match the first dim of inp_features"));
115 inp_positions.shape().dim_size(0) ==
116 inp_importance.shape().dim_size(0) ||
117 inp_importance.shape().dim_size(0) == 0,
118 errors::InvalidArgument(
"first dim of inp_positions does "
119 "not match the first dim of "
123 neighbors_importance.shape().dim_size(0) ==
124 neighbors_index.shape().dim_size(0) ||
125 neighbors_importance.shape().dim_size(0) == 0,
126 errors::InvalidArgument(
"first dim of neighbors_importance "
127 "does not match the first dim of "
132 filter.shape().dim_size(3) == inp_features.shape().dim_size(1),
133 errors::InvalidArgument(
"number of input channels in filter "
134 "and inp_features does not match"));
137 out_features_gradient.shape().dim_size(0) ==
138 out_positions.shape().dim_size(0),
139 errors::InvalidArgument(
"first dim of out_positions, does "
140 "not match the first dim of "
141 "out_features_gradient"));
143 TensorShape filter_backprop_shape(filter.shape());
144 Tensor* filter_backprop =
nullptr;
145 OP_REQUIRES_OK(context,
146 context->allocate_output(0, filter_backprop_shape,
149 std::vector<int> filter_dims({
150 int(filter.shape().dim_size(0)),
151 int(filter.shape().dim_size(1)),
152 int(filter.shape().dim_size(2)),
153 int(filter.shape().dim_size(3)),
154 int(filter.shape().dim_size(4)),
157 bool individual_extents = extents.shape().dim_size(0) ==
158 out_positions.shape().dim_size(0) &&
159 extents.shape().dim_size(0) > 1;
161 bool isotropic_extents = extents.shape().dim_size(1) == 1;
163 bool point_importances = inp_importance.shape().dim_size(0) != 0;
165 bool has_neighbors_importances =
166 neighbors_importance.shape().dim_size(0) != 0;
168 Kernel(context, filter, out_positions, extents, offset, inp_positions,
169 inp_features, inp_importance, neighbors_index,
170 neighbors_importance, neighbors_row_splits,
171 out_features_gradient, filter_dims, individual_extents,
172 isotropic_extents, point_importances, has_neighbors_importances,