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& out_importance =
context->input(2);
69 out_importance.shape().dim_size(0) == 0 ||
70 out_importance.shape().dim_size(0) ==
71 out_positions.shape().dim_size(0),
72 errors::InvalidArgument(
"length of out_importance must "
73 "match the number of output points "
76 const Tensor& extents =
context->input(3);
80 errors::InvalidArgument(
"offset must be a rank 1 tensor"));
82 errors::InvalidArgument(
"offset length must be 3"));
84 const Tensor& inp_positions =
context->input(5);
86 inp_positions.shape().dim_size(0) <=
87 std::numeric_limits<TIndex>::max(),
88 errors::InvalidArgument(
"Too many input points"));
90 const Tensor& inp_features =
context->input(6);
95 const Tensor& inp_neighbors_importance_sum =
context->input(8);
97 const Tensor& inp_neighbors_row_splits =
context->input(9);
99 const Tensor& neighbors_index =
context->input(10);
101 const Tensor& neighbors_importance =
context->input(11);
103 const Tensor& neighbors_row_splits =
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"));
160 TensorShape out_features_shape({out_positions.shape().dim_size(0),
161 filter.shape().dim_size(4)});
162 Tensor* out_features =
nullptr;
163 OP_REQUIRES_OK(
context,
context->allocate_output(0, out_features_shape,
166 std::vector<int> filter_dims({
167 int(filter.shape().dim_size(0)),
168 int(filter.shape().dim_size(1)),
169 int(filter.shape().dim_size(2)),
170 int(filter.shape().dim_size(3)),
171 int(filter.shape().dim_size(4)),
174 bool individual_extents = extents.shape().dim_size(0) ==
175 out_positions.shape().dim_size(0) &&
176 extents.shape().dim_size(0) > 1;
178 bool isotropic_extents = extents.shape().dim_size(1) == 1;
180 bool point_importances = out_importance.shape().dim_size(0) != 0;
182 bool has_neighbors_importances =
183 neighbors_importance.shape().dim_size(0) != 0;
186 inp_positions, inp_features, inp_neighbors_importance_sum,
187 inp_neighbors_row_splits, neighbors_index, neighbors_importance,
188 neighbors_row_splits, filter_dims, individual_extents,
189 isotropic_extents, point_importances, has_neighbors_importances,
194 const tensorflow::Tensor& filter,
195 const tensorflow::Tensor& out_positions,
196 const tensorflow::Tensor& out_importance,
197 const tensorflow::Tensor& extents,
198 const tensorflow::Tensor&
offset,
199 const tensorflow::Tensor& inp_positions,
200 const tensorflow::Tensor& inp_features,
201 const tensorflow::Tensor& inp_neighbors_importance_sum,
202 const tensorflow::Tensor& inp_neighbors_row_splits,
203 const tensorflow::Tensor& neighbors_index,
204 const tensorflow::Tensor& neighbors_importance,
205 const tensorflow::Tensor& neighbors_row_splits,
206 const std::vector<int>& filter_dims,
207 const bool individual_extents,
208 const bool isotropic_extents,
209 const bool point_importances,
210 const bool has_neighbors_importances,
211 tensorflow::Tensor& out_features) = 0;
ImGuiContext * context
Definition: Window.cpp:76
Definition: ContinuousConvTransposeOpKernel.h:16
open3d::ml::impl::CoordinateMapping coordinate_mapping
Definition: ContinuousConvTransposeOpKernel.h:217
int max_temp_mem_MB
Definition: ContinuousConvTransposeOpKernel.h:218
open3d::ml::impl::InterpolationMode interpolation
Definition: ContinuousConvTransposeOpKernel.h:216
bool normalize
Definition: ContinuousConvTransposeOpKernel.h:215
ContinuousConvTransposeOpKernel(tensorflow::OpKernelConstruction *construction)
Definition: ContinuousConvTransposeOpKernel.h:18
void Compute(tensorflow::OpKernelContext *context) override
Definition: ContinuousConvTransposeOpKernel.h:55
bool align_corners
Definition: ContinuousConvTransposeOpKernel.h:214
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:474
Definition: ContinuousConv.h:16
InterpolationMode
Definition: ContinuousConvTypes.h:18
@ NEAREST_NEIGHBOR
Definition: VoxelPooling.h:21
CoordinateMapping
Definition: ContinuousConvTypes.h:26