Couldn't deduce template parameter for Eigen::Matrix

Viewed 144

When I try to compile the following function (forward) using MSVC 19.latest I get the following error message.

'Eigen::Matrix<float,ann_output_len<LayerNodeConfig...>::value,1,0,_Rows,1> forward(const  
 ArtificialNeuralNetwork<InputSize,LayerNodeConfig...> &,const Eigen::Matrix<float,Rows,1,0,_Rows,1> &)':  
 could not deduce template argument for 'const Eigen::Matrix<float,Rows,1,0,_Rows,1> &' from  
 'Eigen::Matrix<float,2,1,0,2,1>'

forward interface

template<int InputSize, int ... LayerNodeConfig>
auto forward(const ArtificialNeuralNetwork<InputSize, LayerNodeConfig...>& ann,   
             const RL::Arrayf<InputSize>& input)     
  -> typename ANN::output_t<LayerNodeConfig...>

In main function

  RL::Arrayf<2> X;
  auto Y = forward(sampling_policy, X);

Now what I don't understand is why can't the compiler substitute Rows and _Rows with 2.

Any insight is appreciated. You can try the full code in godbolt.org using this link, https://godbolt.org/z/7Mj5ee and try to compile it yourself if you like.

Note: I tried to compile the same code with latest GCC compiler and it compiled.

Update - Mar 06, 2021: I made a workaround by changing the interface of function forward to accept Eigen::DenseBase<Derived> instead of RL::Arrayf<InputSize>. Anyone who is interested can read more about it here, https://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html

0 Answers
Related