Is there a way to read .pt files in C++?


(Joong Kun Lee) #1

Is there a way to read .pt files in C++ without a python wrapper?


(Nilay Shrivastava) #2

Yes there is

int main(int argc, const char* argv[])
{
    if(argc != 2) {
        std::cerr << "path to the model not mentioned!!";
        return -1;
    }

    std::shared_ptr<torch::jit::script::Module> module = torch::jit::load(argv[1]);

    std::vector<torch::jit::IValue> inputs;
    inputs.push_back(torch::ones({1,1,29,22,22}));

    for (int i=0; i<COUNT; ++i) {
        auto output = at::argmax(module->forward(inputs).toTensor());
    }
    
 
    return 0;
}

(Joong Kun Lee) #3

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)


(Joong Kun Lee) #4

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)