libTorch cannot pass a const module into function

   22 void get_optical_flow(                                                                                                                                                                               
    23     const cv::Mat & image1,                                                                                                                                                                          
    24     const cv::Mat & image2,                                                                                                                                                                          
    25     cv::Mat & flow, //output                                                                                                                                                                         
 >> 26     const torch::jit::script::Module & module,                                                                                                                                                       
    27     const int module_input_h,                                                                                                                                                                        
    28     const int module_input_w){

get error

error: passing ‘const Module {aka const torch::jit::Module}’ as ‘this’ argument discards qualifiers [-fpermissive]
   at::Tensor output = module.forward(inputs).toTensor();

looks like the forward will change the module

Hey, I found the same issue. If I provide the module with const, the forward function throws the same error as you got. I am unsure if it is a good idea that const cannot be applied to the module.