60 using namespace tensorflow;
61 static_assert(
sizeof(int64_t) ==
sizeof(int64_t),
62 "int64_t type is not compatible");
63 const Tensor& filter =
context->input(0);
65 const Tensor& out_positions =
context->input(1);
67 out_positions.shape().dim_size(0) <=
68 std::numeric_limits<TIndex>::max(),
69 absl::InvalidArgumentError(
"Too many output points"));
71 const Tensor& out_importance =
context->input(2);
74 out_importance.shape().dim_size(0) == 0 ||
75 out_importance.shape().dim_size(0) ==
76 out_positions.shape().dim_size(0),
77 absl::InvalidArgumentError(
"length of out_importance must "
78 "match the number of output points "
81 const Tensor& extents =
context->input(3);
86 absl::InvalidArgumentError(
"offset must be a rank 1 tensor"));
88 absl::InvalidArgumentError(
"offset length must be 3"));
90 const Tensor& inp_positions =
context->input(5);
92 inp_positions.shape().dim_size(0) <=
93 std::numeric_limits<TIndex>::max(),
94 absl::InvalidArgumentError(
"Too many input points"));
96 const Tensor& inp_features =
context->input(6);
98 const Tensor& inp_neighbors_importance_sum =
context->input(7);
100 const Tensor& inp_neighbors_row_splits =
context->input(8);
102 const Tensor& neighbors_index =
context->input(9);
104 const Tensor& neighbors_importance =
context->input(10);
106 const Tensor& neighbors_row_splits =
context->input(11);
108 const Tensor& out_features_gradient =
context->input(12);
111 context, extents.shape().dims() == 2,
112 absl::InvalidArgumentError(
"extents must be a rank 2 tensor"));
115 extents.shape().dim_size(0) ==
116 inp_positions.shape().dim_size(0) ||
117 extents.shape().dim_size(0) == 1,
118 absl::InvalidArgumentError(
"number of extents must match the "
119 "number of inp_positions or must "
122 extents.shape().dim_size(1) == 3 ||
123 extents.shape().dim_size(1) == 1,
124 absl::InvalidArgumentError(
125 "number of components for extents must be 3 or 1"));
128 inp_positions.shape().dim_size(0) ==
129 inp_features.shape().dim_size(0),
130 absl::InvalidArgumentError(
131 "first dim of inp_positions does not "
132 "match the first dim of inp_features"));
136 inp_neighbors_importance_sum.shape().dim_size(0) ==
137 inp_positions.shape().dim_size(0) ||
138 inp_neighbors_importance_sum.shape().dim_size(0) == 0,
139 absl::InvalidArgumentError(
140 "first dim of inp_neighbors_importance_sum does not "
141 "match the first dim of inp_positions"));
145 out_positions.shape().dim_size(0) ==
146 out_importance.shape().dim_size(0) ||
147 out_importance.shape().dim_size(0) == 0,
148 absl::InvalidArgumentError(
"first dim of out_positions does "
149 "not match the first dim of "
154 neighbors_importance.shape().dim_size(0) ==
155 neighbors_index.shape().dim_size(0) ||
156 neighbors_importance.shape().dim_size(0) == 0,
157 absl::InvalidArgumentError(
"first dim of neighbors_importance "
158 "does not match the first dim of "
163 filter.shape().dim_size(3) == inp_features.shape().dim_size(1),
164 absl::InvalidArgumentError(
"number of input channels in filter "
165 "and inp_features does not match"));
168 out_features_gradient.shape().dim_size(0) ==
169 out_positions.shape().dim_size(0),
170 absl::InvalidArgumentError(
171 std::string(
"first dim of out_positions, does "
172 "not match the first dim of "
173 "out_features_gradient")));
175 TensorShape filter_backprop_shape(filter.shape());
176 Tensor* filter_backprop =
nullptr;
178 context->allocate_output(0, filter_backprop_shape,
181 std::vector<int> filter_dims({
182 int(filter.shape().dim_size(0)),
183 int(filter.shape().dim_size(1)),
184 int(filter.shape().dim_size(2)),
185 int(filter.shape().dim_size(3)),
186 int(filter.shape().dim_size(4)),
189 bool individual_extents = extents.shape().dim_size(0) ==
190 out_positions.shape().dim_size(0) &&
191 extents.shape().dim_size(0) > 1;
193 bool isotropic_extents = extents.shape().dim_size(1) == 1;
195 bool point_importances = out_importance.shape().dim_size(0) != 0;
197 bool has_neighbors_importances =
198 neighbors_importance.shape().dim_size(0) != 0;
201 inp_positions, inp_features, inp_neighbors_importance_sum,
202 inp_neighbors_row_splits, neighbors_index, neighbors_importance,
203 neighbors_row_splits, out_features_gradient, filter_dims,
204 individual_extents, isotropic_extents, point_importances,
205 has_neighbors_importances, *filter_backprop);