I'm trying to change a code in this repo from 2D to 3D; https://github.com/sadeepj/crfasrnn_keras
However, my C++ is super rusty and I'm having a hard time with one problem. I'm trying to pass the Tensor& out to this function;
void ModifiedPermutohedral::compute(Tensor& out, const Tensor& in, int value_size, bool reverse, bool add) const
with this line
ModifiedPermutohedral mp;
const Tensor& input_tensor = context->input(0);
Tensor* output_tensor = NULL;
OP_REQUIRES_OK(context, context->allocate_output(0, input_tensor.shape(), &output_tensor));
mp.compute(output_tensor->SubSlice(b), input_tensor.SubSlice(b), channels, backwards_);
where b is the batch index I want to pass to this compute function. However, it gives me an error that
error: cannot bind non-const lvalue reference of type ‘tensorflow::Tensor&’ to an rvalue of type ‘tensorflow::Tensor’
I believe it's because output_tensor is a pointer, but how am I supposed to pass it then? Shouldn't the SubSlice function return a tensor? I've tried
&(output_tensor->SubSlice(b))
*(output_tensor->SubSlice(b))
too but all creates a different error. Can anyone provide insights on how I should pass this? Thank you!
Although I am not familiar with tensorflow C++, I noticed that in mp.compute(output_tensor->SubSlice(b), input_tensor.SubSlice(b), channels, backwards_);
, first argument is a rvalue such that which cannot be used for value assigning purpose. I suggest:
auto sliced_putput = output_tensor->SubSlice(b);
mp.compute(sliced_output, input_tensor.SubSlice(b), channels, backwards_);
//Assign sliced output to the output_tensor's appropriate dimensiton