30 #include "tensorflow/core/framework/op.h"
31 #include "tensorflow/core/framework/op_kernel.h"
32 #include "tensorflow/core/lib/core/errors.h"
34 template <
class TIndex>
38 tensorflow::OpKernelConstruction* construction)
39 : OpKernel(construction) {
40 using namespace tensorflow;
42 OP_REQUIRES_OK(construction,
44 OP_REQUIRES_OK(construction,
45 construction->GetAttr(
"normalize", &
normalize));
47 std::string interpolation_str;
48 OP_REQUIRES_OK(construction, construction->GetAttr(
"interpolation",
51 if (interpolation_str ==
"linear")
53 else if (interpolation_str ==
"linear_border")
58 std::string mapping_str;
59 OP_REQUIRES_OK(construction, construction->GetAttr(
"coordinate_mapping",
62 if (mapping_str ==
"ball_to_cube_radial")
64 else if (mapping_str ==
"ball_to_cube_volume_preserving")
66 CoordinateMapping::BALL_TO_CUBE_VOLUME_PRESERVING;
70 OP_REQUIRES_OK(construction, construction->GetAttr(
"max_temp_mem_MB",
75 using namespace tensorflow;
76 static_assert(
sizeof(int64) ==
sizeof(int64_t),
77 "int64 type is not compatible");
78 const Tensor& filter =
context->input(0);
80 const Tensor& out_positions =
context->input(1);
82 out_positions.shape().dim_size(0) <=
83 std::numeric_limits<TIndex>::max(),
84 errors::InvalidArgument(
"Too many output points"));
86 const Tensor& extents =
context->input(2);
87 OP_REQUIRES(
context, extents.shape().dims() == 2,
88 errors::InvalidArgument(
"extents must be a rank 2 tensor"));
90 extents.shape().dim_size(0) ==
91 out_positions.shape().dim_size(0) ||
92 extents.shape().dim_size(0) == 1,
93 errors::InvalidArgument(
"number of extents must match the "
94 "number of out_positions or must "
97 extents.shape().dim_size(1) == 3 ||
98 extents.shape().dim_size(1) == 1,
99 errors::InvalidArgument(
100 "number of components for extents must be 3 or 1"));
104 errors::InvalidArgument(
"offset must be a rank 1 tensor"));
106 errors::InvalidArgument(
"offset length must be 3"));
108 const Tensor& inp_positions =
context->input(4);
110 inp_positions.shape().dim_size(0) <=
111 std::numeric_limits<TIndex>::max(),
112 errors::InvalidArgument(
"Too many input points"));
114 const Tensor& inp_features =
context->input(5);
116 const Tensor& inp_importance =
context->input(6);
118 const Tensor& neighbors_index =
context->input(7);
120 const Tensor& neighbors_importance =
context->input(8);
122 const Tensor& neighbors_row_splits =
context->input(9);
126 inp_positions.shape().dim_size(0) ==
127 inp_features.shape().dim_size(0),
128 errors::InvalidArgument(
"first dim of inp_positions does not "
129 "match the first dim of inp_features"));
132 inp_positions.shape().dim_size(0) ==
133 inp_importance.shape().dim_size(0) ||
134 inp_importance.shape().dim_size(0) == 0,
135 errors::InvalidArgument(
"first dim of inp_positions does "
136 "not match the first dim of "
140 neighbors_importance.shape().dim_size(0) ==
141 neighbors_index.shape().dim_size(0) ||
142 neighbors_importance.shape().dim_size(0) == 0,
143 errors::InvalidArgument(
"first dim of neighbors_importance "
144 "does not match the first dim of "
149 filter.shape().dim_size(3) == inp_features.shape().dim_size(1),
150 errors::InvalidArgument(
"number of input channels in filter "
151 "and inp_features does not match"));
153 TensorShape out_features_shape({out_positions.shape().dim_size(0),
154 filter.shape().dim_size(4)});
155 Tensor* out_features =
nullptr;
156 OP_REQUIRES_OK(
context,
context->allocate_output(0, out_features_shape,
159 std::vector<int> filter_dims({
160 int(filter.shape().dim_size(0)),
161 int(filter.shape().dim_size(1)),
162 int(filter.shape().dim_size(2)),
163 int(filter.shape().dim_size(3)),
164 int(filter.shape().dim_size(4)),
167 bool individual_extents = extents.shape().dim_size(0) ==
168 out_positions.shape().dim_size(0) &&
169 extents.shape().dim_size(0) > 1;
171 bool isotropic_extents = extents.shape().dim_size(1) == 1;
173 bool point_importances = inp_importance.shape().dim_size(0) != 0;
175 bool has_neighbors_importances =
176 neighbors_importance.shape().dim_size(0) != 0;
179 inp_features, inp_importance, neighbors_index,
180 neighbors_importance, neighbors_row_splits, filter_dims,
181 individual_extents, isotropic_extents, point_importances,
182 has_neighbors_importances, *out_features);
186 const tensorflow::Tensor& filter,
187 const tensorflow::Tensor& out_positions,
188 const tensorflow::Tensor& extents,
189 const tensorflow::Tensor&
offset,
190 const tensorflow::Tensor& inp_positions,
191 const tensorflow::Tensor& inp_features,
192 const tensorflow::Tensor& inp_importance,
193 const tensorflow::Tensor& neighbors_index,
194 const tensorflow::Tensor& neighbors_importance,
195 const tensorflow::Tensor& neighbors_row_splits,
196 const std::vector<int>& filter_dims,
197 const bool individual_extents,
198 const bool isotropic_extents,
199 const bool point_importances,
200 const bool has_neighbors_importances,
201 tensorflow::Tensor& out_features) = 0;
ImGuiContext * context
Definition: Window.cpp:95
Definition: ContinuousConvOpKernel.h:35
bool normalize
Definition: ContinuousConvOpKernel.h:205
open3d::ml::impl::InterpolationMode interpolation
Definition: ContinuousConvOpKernel.h:206
void Compute(tensorflow::OpKernelContext *context) override
Definition: ContinuousConvOpKernel.h:74
bool align_corners
Definition: ContinuousConvOpKernel.h:204
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 std::vector< int > &filter_dims, const bool individual_extents, const bool isotropic_extents, const bool point_importances, const bool has_neighbors_importances, tensorflow::Tensor &out_features)=0
ContinuousConvOpKernel(tensorflow::OpKernelConstruction *construction)
Definition: ContinuousConvOpKernel.h:37
int max_temp_mem_MB
Definition: ContinuousConvOpKernel.h:208
open3d::ml::impl::CoordinateMapping coordinate_mapping
Definition: ContinuousConvOpKernel.h:207
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:493
Definition: ContinuousConv.h:35
InterpolationMode
Definition: ContinuousConvTypes.h:37
@ NEAREST_NEIGHBOR
Definition: VoxelPooling.h:40
CoordinateMapping
Definition: ContinuousConvTypes.h:45