28 void Compute(tensorflow::OpKernelContext* context)
override {
29 using namespace tensorflow;
30 const Tensor& coords = context->input(0);
32 context, coords.dims() == 3 && coords.shape().dim_size(1) == 3,
33 errors::InvalidArgument(
"TrilinearDevoxelize expects "
34 "(batch_size, 3, N) coordinate shape"));
35 const Tensor& feat = context->input(1);
36 OP_REQUIRES(context, feat.dims() == 5,
37 errors::InvalidArgument(
"TrilinearDevoxelize expects "
38 "5 dimensions for features"));
40 int batch_size = coords.shape().dim_size(0);
41 int num_points = coords.shape().dim_size(2);
42 int feat_dim = feat.shape().dim_size(1);
44 auto coords_flat = coords.flat<
float>();
45 auto feat_flat = feat.flat<
float>();
47 const float* inp_coords = &(coords_flat(0));
48 const float* inp_feat = &(feat_flat(0));
51 OP_REQUIRES_OK(context,
52 context->allocate_output(
53 0, TensorShape{batch_size, feat_dim, num_points},
56 OP_REQUIRES_OK(context,
57 context->allocate_output(
58 1, TensorShape{batch_size, 8, num_points},
61 OP_REQUIRES_OK(context,
62 context->allocate_output(
63 2, TensorShape{batch_size, 8, num_points},
65 auto flat_0 = out_tensor_0->flat<
float>();
66 auto flat_1 = out_tensor_1->flat<
int>();
67 auto flat_2 = out_tensor_2->flat<
float>();
69 float* out_0 = &(flat_0(0));
70 int* out_1 = &(flat_1(0));
71 float* out_2 = &(flat_2(0));
74 Kernel(context, batch_size, feat_dim, num_points,
r,
r *
r,
75 r *
r *
r,
true, inp_coords, inp_feat, out_1, out_2, out_0);
77 Kernel(context, batch_size, feat_dim, num_points,
r,
r *
r,
78 r *
r *
r,
false, inp_coords, inp_feat, out_1, out_2, out_0);