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>
19 tensorflow::OpKernelConstruction* construction)
20 : OpKernel(construction) {
21 using namespace tensorflow;
23 OP_REQUIRES_OK(construction,
25 OP_REQUIRES_OK(construction,
26 construction->GetAttr(
"normalize", &
normalize));
28 std::string interpolation_str;
29 OP_REQUIRES_OK(construction, construction->GetAttr(
"interpolation",
32 if (interpolation_str ==
"linear")
34 else if (interpolation_str ==
"linear_border")
39 std::string mapping_str;
40 OP_REQUIRES_OK(construction, construction->GetAttr(
"coordinate_mapping",
43 if (mapping_str ==
"ball_to_cube_radial")
45 else if (mapping_str ==
"ball_to_cube_volume_preserving")
47 CoordinateMapping::BALL_TO_CUBE_VOLUME_PRESERVING;
51 OP_REQUIRES_OK(construction, construction->GetAttr(
"max_temp_mem_MB",
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"));
85 errors::InvalidArgument(
"offset must be a rank 1 tensor"));
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;
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;
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,
177 const tensorflow::Tensor& filter,
178 const tensorflow::Tensor& out_positions,
179 const tensorflow::Tensor& extents,
180 const tensorflow::Tensor&
offset,
181 const tensorflow::Tensor& inp_positions,
182 const tensorflow::Tensor& inp_features,
183 const tensorflow::Tensor& inp_importance,
184 const tensorflow::Tensor& neighbors_index,
185 const tensorflow::Tensor& neighbors_importance,
186 const tensorflow::Tensor& neighbors_row_splits,
187 const tensorflow::Tensor& out_features_gradient,
188 const std::vector<int>& filter_dims,
189 const bool individual_extents,
190 const bool isotropic_extents,
191 const bool point_importances,
192 const bool has_neighbors_importances,
193 tensorflow::Tensor& filter_backprop) = 0;
ImGuiContext * context
Definition: Window.cpp:76
Definition: ContinuousConvBackpropFilterOpKernel.h:16
bool align_corners
Definition: ContinuousConvBackpropFilterOpKernel.h:196
int max_temp_mem_MB
Definition: ContinuousConvBackpropFilterOpKernel.h:200
open3d::ml::impl::CoordinateMapping coordinate_mapping
Definition: ContinuousConvBackpropFilterOpKernel.h:199
ContinuousConvBackpropFilterOpKernel(tensorflow::OpKernelConstruction *construction)
Definition: ContinuousConvBackpropFilterOpKernel.h:18
bool normalize
Definition: ContinuousConvBackpropFilterOpKernel.h:197
void Compute(tensorflow::OpKernelContext *context) override
Definition: ContinuousConvBackpropFilterOpKernel.h:55
open3d::ml::impl::InterpolationMode interpolation
Definition: ContinuousConvBackpropFilterOpKernel.h:198
virtual void Kernel(tensorflow::OpKernelContext *context, const tensorflow::Tensor &filter, const tensorflow::Tensor &out_positions, const tensorflow::Tensor &extents, const tensorflow::Tensor &offset, const tensorflow::Tensor &inp_positions, const tensorflow::Tensor &inp_features, const tensorflow::Tensor &inp_importance, 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
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