Solved by Stonepia in post #2 
              
              
                Well, I found that this is a stupid question. I wrongly passed the module as const, remove it to 
int64_t print_shape(torch::jit::Module &mod)

would solve the problem.