Thank you very much for your response here is the minimal working code:

#include <iostream>
#include <torch/torch.h>
#include <torch/script.h>
#include <cuda_runtime_api.h>

int main() {
    torch::jit::script::Module script_module = torch::jit::load("detector.pt");
    std::vector <torch::jit::IValue> inputs;
    auto img_tensor = torch::zeros({1,3,640,640}).cuda();
    inputs.emplace_back(img_tensor);
    for(int i=0;i<10000;i++){
        clock_t begin = clock();
        torch::NoGradGuard no_grad_guard;
        cudaDeviceSynchronize();
        auto output = script_module.forward(inputs);
        cudaDeviceSynchronize();
        clock_t end = clock();
        double elapsed_time = double(end - begin) / 1000;
        if(i%100==0) {
            std::cout << "Iteration : "<<i<<" Elapsed time " << elapsed_time << std::endl;
        }
    }
    return 0;
}

Here is the output

Iteration : 0 Elapsed time 586.484
Iteration : 100 Elapsed time 29.035
Iteration : 200 Elapsed time 28.963
Iteration : 300 Elapsed time 29.021
Iteration : 400 Elapsed time 29.029
Iteration : 500 Elapsed time 29.407
Iteration : 600 Elapsed time 112.363
Iteration : 700 Elapsed time 141.069
Iteration : 800 Elapsed time 34.88
Iteration : 900 Elapsed time 104.44
Iteration : 1000 Elapsed time 116.31
Iteration : 1100 Elapsed time 100.833

Environtment :  NVIDIA-SMI 440.100      Driver Version: 440.100      CUDA Version: 10.1, Ubuntu 18.04, GTX1050M, libtorch 1.6