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& out_importance =
context->input(2);
88 out_importance.shape().dim_size(0) == 0 ||
89 out_importance.shape().dim_size(0) ==
90 out_positions.shape().dim_size(0),
91 errors::InvalidArgument(
"length of out_importance must "
92 "match the number of output points "
95 const Tensor& extents =
context->input(3);
99 errors::InvalidArgument(
"offset must be a rank 1 tensor"));
101 errors::InvalidArgument(
"offset length must be 3"));
103 const Tensor& inp_positions =
context->input(5);
105 inp_positions.shape().dim_size(0) <=
106 std::numeric_limits<TIndex>::max(),
107 errors::InvalidArgument(
"Too many input points"));
109 const Tensor& inp_features =
context->input(6);
114 const Tensor& inp_neighbors_importance_sum =
context->input(8);
116 const Tensor& inp_neighbors_row_splits =
context->input(9);
118 const Tensor& neighbors_index =
context->input(10);
120 const Tensor& neighbors_importance =
context->input(11);
122 const Tensor& neighbors_row_splits =
context->input(12);
124 OP_REQUIRES(
context, extents.shape().dims() == 2,
125 errors::InvalidArgument(
"extents must be a rank 2 tensor"));
127 extents.shape().dim_size(0) ==
128 inp_positions.shape().dim_size(0) ||
129 extents.shape().dim_size(0) == 1,
130 errors::InvalidArgument(
"number of extents must match the "
131 "number of inp_positions or must "
134 extents.shape().dim_size(1) == 3 ||
135 extents.shape().dim_size(1) == 1,
136 errors::InvalidArgument(
137 "number of components for extents must be 3 or 1"));
141 inp_positions.shape().dim_size(0) ==
142 inp_features.shape().dim_size(0),
143 errors::InvalidArgument(
"first dim of inp_positions does not "
144 "match the first dim of inp_features"));
148 inp_neighbors_importance_sum.shape().dim_size(0) ==
149 inp_positions.shape().dim_size(0) ||
150 inp_neighbors_importance_sum.shape().dim_size(0) == 0,
151 errors::InvalidArgument(
152 "first dim of inp_neighbors_importance_sum does not "
153 "match the first dim of inp_positions",
154 inp_neighbors_importance_sum.shape().dim_size(0),
" ",
155 inp_positions.shape().dim_size(0)));
158 out_positions.shape().dim_size(0) ==
159 out_importance.shape().dim_size(0) ||
160 out_importance.shape().dim_size(0) == 0,
161 errors::InvalidArgument(
"first dim of out_positions does "
162 "not match the first dim of "
166 neighbors_importance.shape().dim_size(0) ==
167 neighbors_index.shape().dim_size(0) ||
168 neighbors_importance.shape().dim_size(0) == 0,
169 errors::InvalidArgument(
"first dim of neighbors_importance "
170 "does not match the first dim of "
175 filter.shape().dim_size(3) == inp_features.shape().dim_size(1),
176 errors::InvalidArgument(
"number of input channels in filter "
177 "and inp_features does not match"));
179 TensorShape out_features_shape({out_positions.shape().dim_size(0),
180 filter.shape().dim_size(4)});
181 Tensor* out_features =
nullptr;
182 OP_REQUIRES_OK(
context,
context->allocate_output(0, out_features_shape,
185 std::vector<int> filter_dims({
186 int(filter.shape().dim_size(0)),
187 int(filter.shape().dim_size(1)),
188 int(filter.shape().dim_size(2)),
189 int(filter.shape().dim_size(3)),
190 int(filter.shape().dim_size(4)),
193 bool individual_extents = extents.shape().dim_size(0) ==
194 out_positions.shape().dim_size(0) &&
195 extents.shape().dim_size(0) > 1;
197 bool isotropic_extents = extents.shape().dim_size(1) == 1;
199 bool point_importances = out_importance.shape().dim_size(0) != 0;
201 bool has_neighbors_importances =
202 neighbors_importance.shape().dim_size(0) != 0;
205 inp_positions, inp_features, inp_neighbors_importance_sum,
206 inp_neighbors_row_splits, neighbors_index, neighbors_importance,
207 neighbors_row_splits, filter_dims, individual_extents,
208 isotropic_extents, point_importances, has_neighbors_importances,
213 const tensorflow::Tensor& filter,
214 const tensorflow::Tensor& out_positions,
215 const tensorflow::Tensor& out_importance,
216 const tensorflow::Tensor& extents,
217 const tensorflow::Tensor&
offset,
218 const tensorflow::Tensor& inp_positions,
219 const tensorflow::Tensor& inp_features,
220 const tensorflow::Tensor& inp_neighbors_importance_sum,
221 const tensorflow::Tensor& inp_neighbors_row_splits,
222 const tensorflow::Tensor& neighbors_index,
223 const tensorflow::Tensor& neighbors_importance,
224 const tensorflow::Tensor& neighbors_row_splits,
225 const std::vector<int>& filter_dims,
226 const bool individual_extents,
227 const bool isotropic_extents,
228 const bool point_importances,
229 const bool has_neighbors_importances,
230 tensorflow::Tensor& out_features) = 0;
ImGuiContext * context
Definition: Window.cpp:95
Definition: ContinuousConvTransposeOpKernel.h:35
open3d::ml::impl::CoordinateMapping coordinate_mapping
Definition: ContinuousConvTransposeOpKernel.h:236
int max_temp_mem_MB
Definition: ContinuousConvTransposeOpKernel.h:237
open3d::ml::impl::InterpolationMode interpolation
Definition: ContinuousConvTransposeOpKernel.h:235
bool normalize
Definition: ContinuousConvTransposeOpKernel.h:234
ContinuousConvTransposeOpKernel(tensorflow::OpKernelConstruction *construction)
Definition: ContinuousConvTransposeOpKernel.h:37
void Compute(tensorflow::OpKernelContext *context) override
Definition: ContinuousConvTransposeOpKernel.h:74
bool align_corners
Definition: ContinuousConvTransposeOpKernel.h:233
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 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
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