dimanche 18 février 2018

How to a conversion Eigen::TensorMap to float* ?

I am implementing a tensorflow::op (https://www.tensorflow.org/versions/r0.12/how_tos/adding_an_op/#verify_it_works).

I want to call a function forward(), which takes float pointer as arguments. On the first argument, I am not able to convert the tensor to a float pointer.

REGISTER_OP("ForwardMatching")
.Input("input0: float32")
.Input("input1: float32")
.Input("disparities: float32")
.Input("output: float32")
.Input("in: int32")
.Input("ic: int32")
.Input("ih: int32")
.Input("iw: int32")
.Input("lendisps: int32")
.Input("memorylayout: int32")
.Input("rectcorr: int32")
.Output("zeroed: int32")
.SetShapeFn([](::tensorflow::shape_inference::InferenceContext* c) {
    c->set_output(0, c->input(0));
    return Status::OK();
});
class ForwardMatchingOp : public OpKernel {
public:
    std::vector<cudnnTensorDescriptor_t> a;
    StereoCorrelation* sc = new StereoCorrelation(a);
    explicit ForwardMatchingOp(OpKernelConstruction* context) : OpKernel(context) {}
        void Compute(OpKernelContext* context) override {
            // Grab the input tensor
            const Tensor& input0_tensor = context->input(0);
            iu::TensorGpu_32f::MemoryLayout ml;
            float *i0, *i1, *disp;
            int in, ic, ih, iw, lendisps, rectcor;
            float *output;
            sc->forward(input0,i1,disp, output, in, ic, ih, iw, lendisps, ml, rectcor);
    } 
};

the error message:

note:   no known conversion for argument 1 from ‘Eigen::TensorMap<Eigen::Tensor<const float, 1, 1, long int>, 16, Eigen::MakePointer>’ to ‘float*’

Aucun commentaire:

Enregistrer un commentaire