11 #include "tensorflow/core/framework/op.h"
12 #include "tensorflow/core/framework/op_kernel.h"
13 #include "tensorflow/core/lib/core/errors.h"
15 template <
class TIndex>
17 :
public tensorflow::OpKernel {
20 tensorflow::OpKernelConstruction* construction)
21 : OpKernel(construction) {
22 using namespace tensorflow;
24 OP_REQUIRES_OK(construction,
26 OP_REQUIRES_OK(construction,
27 construction->GetAttr(
"normalize", &
normalize));
29 std::string interpolation_str;
30 OP_REQUIRES_OK(construction, construction->GetAttr(
"interpolation",
33 if (interpolation_str ==
"linear")
35 else if (interpolation_str ==
"linear_border")
40 std::string mapping_str;
41 OP_REQUIRES_OK(construction, construction->GetAttr(
"coordinate_mapping",
44 if (mapping_str ==
"ball_to_cube_radial")
46 else if (mapping_str ==
"ball_to_cube_volume_preserving")
48 CoordinateMapping::BALL_TO_CUBE_VOLUME_PRESERVING;
52 OP_REQUIRES_OK(construction, construction->GetAttr(
"max_temp_mem_MB",
57 using namespace tensorflow;
58 static_assert(
sizeof(int64) ==
sizeof(int64_t),
59 "int64 type is not compatible");
60 const Tensor& filter =
context->input(0);
62 const Tensor& out_positions =
context->input(1);
64 out_positions.shape().dim_size(0) <=
65 std::numeric_limits<TIndex>::max(),
66 errors::InvalidArgument(
"Too many output points"));
68 const Tensor& out_importance =
context->input(2);
70 out_importance.shape().dim_size(0) == 0 ||
71 out_importance.shape().dim_size(0) ==
72 out_positions.shape().dim_size(0),
73 errors::InvalidArgument(
"length of out_importance must "
74 "match the number of output points "
77 const Tensor& extents =
context->input(3);
81 errors::InvalidArgument(
"offset must be a rank 1 tensor"));
83 errors::InvalidArgument(
"offset length must be 3"));
85 const Tensor& inp_positions =
context->input(5);
87 inp_positions.shape().dim_size(0) <=
88 std::numeric_limits<TIndex>::max(),
89 errors::InvalidArgument(
"Too many input points"));
91 const Tensor& inp_features =
context->input(6);
93 const Tensor& inp_neighbors_importance_sum =
context->input(7);
95 const Tensor& inp_neighbors_row_splits =
context->input(8);
97 const Tensor& neighbors_index =
context->input(9);
99 const Tensor& neighbors_importance =
context->input(10);
101 const Tensor& neighbors_row_splits =
context->input(11);
103 const Tensor& out_features_gradient =
context->input(12);
105 OP_REQUIRES(
context, extents.shape().dims() == 2,
106 errors::InvalidArgument(
"extents must be a rank 2 tensor"));
108 extents.shape().dim_size(0) ==
109 inp_positions.shape().dim_size(0) ||
110 extents.shape().dim_size(0) == 1,
111 errors::InvalidArgument(
"number of extents must match the "
112 "number of inp_positions or must "
115 extents.shape().dim_size(1) == 3 ||
116 extents.shape().dim_size(1) == 1,
117 errors::InvalidArgument(
118 "number of components for extents must be 3 or 1"));
122 inp_positions.shape().dim_size(0) ==
123 inp_features.shape().dim_size(0),
124 errors::InvalidArgument(
"first dim of inp_positions does not "
125 "match the first dim of inp_features"));
129 inp_neighbors_importance_sum.shape().dim_size(0) ==
130 inp_positions.shape().dim_size(0) ||
131 inp_neighbors_importance_sum.shape().dim_size(0) == 0,
132 errors::InvalidArgument(
133 "first dim of inp_neighbors_importance_sum does not "
134 "match the first dim of inp_positions",
135 inp_neighbors_importance_sum.shape().dim_size(0),
" ",
136 inp_positions.shape().dim_size(0)));
139 out_positions.shape().dim_size(0) ==
140 out_importance.shape().dim_size(0) ||
141 out_importance.shape().dim_size(0) == 0,
142 errors::InvalidArgument(
"first dim of out_positions does "
143 "not match the first dim of "
147 neighbors_importance.shape().dim_size(0) ==
148 neighbors_index.shape().dim_size(0) ||
149 neighbors_importance.shape().dim_size(0) == 0,
150 errors::InvalidArgument(
"first dim of neighbors_importance "
151 "does not match the first dim of "
156 filter.shape().dim_size(3) == inp_features.shape().dim_size(1),
157 errors::InvalidArgument(
"number of input channels in filter "
158 "and inp_features does not match"));
161 out_features_gradient.shape().dim_size(0) ==
162 out_positions.shape().dim_size(0),
163 errors::InvalidArgument(
"first dim of out_positions, does "
164 "not match the first dim of "
165 "out_features_gradient"));
167 TensorShape filter_backprop_shape(filter.shape());
168 Tensor* filter_backprop =
nullptr;
170 context->allocate_output(0, filter_backprop_shape,
173 std::vector<int> filter_dims({
174 int(filter.shape().dim_size(0)),
175 int(filter.shape().dim_size(1)),
176 int(filter.shape().dim_size(2)),
177 int(filter.shape().dim_size(3)),
178 int(filter.shape().dim_size(4)),
181 bool individual_extents = extents.shape().dim_size(0) ==
182 out_positions.shape().dim_size(0) &&
183 extents.shape().dim_size(0) > 1;
185 bool isotropic_extents = extents.shape().dim_size(1) == 1;
187 bool point_importances = out_importance.shape().dim_size(0) != 0;
189 bool has_neighbors_importances =
190 neighbors_importance.shape().dim_size(0) != 0;
193 inp_positions, inp_features, inp_neighbors_importance_sum,
194 inp_neighbors_row_splits, neighbors_index, neighbors_importance,
195 neighbors_row_splits, out_features_gradient, filter_dims,
196 individual_extents, isotropic_extents, point_importances,
197 has_neighbors_importances, *filter_backprop);
201 const tensorflow::Tensor& filter,
202 const tensorflow::Tensor& out_positions,
203 const tensorflow::Tensor& out_importance,
204 const tensorflow::Tensor& extents,
205 const tensorflow::Tensor&
offset,
206 const tensorflow::Tensor& inp_positions,
207 const tensorflow::Tensor& inp_features,
208 const tensorflow::Tensor& inp_neighbors_importance_sum,
209 const tensorflow::Tensor& inp_neighbors_row_splits,
210 const tensorflow::Tensor& neighbors_index,
211 const tensorflow::Tensor& neighbors_importance,
212 const tensorflow::Tensor& neighbors_row_splits,
213 const tensorflow::Tensor& out_features_gradient,
214 const std::vector<int>& filter_dims,
215 const bool individual_extents,
216 const bool isotropic_extents,
217 const bool point_importances,
218 const bool has_neighbors_importances,
219 tensorflow::Tensor& filter_backprop) = 0;
ImGuiContext * context
Definition: Window.cpp:76
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:17
ContinuousConvTransposeBackpropFilterOpKernel(tensorflow::OpKernelConstruction *construction)
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:19
virtual void Kernel(tensorflow::OpKernelContext *context, const tensorflow::Tensor &filter, const tensorflow::Tensor &out_positions, const tensorflow::Tensor &out_importance, const tensorflow::Tensor &extents, const tensorflow::Tensor &offset, const tensorflow::Tensor &inp_positions, const tensorflow::Tensor &inp_features, const tensorflow::Tensor &inp_neighbors_importance_sum, const tensorflow::Tensor &inp_neighbors_row_splits, const tensorflow::Tensor &neighbors_index, const tensorflow::Tensor &neighbors_importance, const tensorflow::Tensor &neighbors_row_splits, const tensorflow::Tensor &out_features_gradient, const std::vector< int > &filter_dims, const bool individual_extents, const bool isotropic_extents, const bool point_importances, const bool has_neighbors_importances, tensorflow::Tensor &filter_backprop)=0
bool align_corners
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:222
void Compute(tensorflow::OpKernelContext *context) override
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:56
open3d::ml::impl::InterpolationMode interpolation
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:224
open3d::ml::impl::CoordinateMapping coordinate_mapping
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:225
bool normalize
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:223
int max_temp_mem_MB
Definition: ContinuousConvTransposeBackpropFilterOpKernel.h:226
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c int
Definition: K4aPlugin.cpp:474
Definition: ContinuousConv.h:16
InterpolationMode
Definition: ContinuousConvTypes.h:18
@ NEAREST_NEIGHBOR
Definition: VoxelPooling.h:21
CoordinateMapping
Definition: ContinuousConvTypes.h:26