Dictionary input to scripted model

I would like to use a dictionary as input to the ScriptModule in C++

  auto x = torch::OrderedDict<std::string, torch::Tensor>();
  x.insert("feat1", torch::rand({1, 10, 64, 64}));
  x.insert("feat2", torch::rand({1, 20, 16, 16}));
  x.insert("feat3", torch::rand({1, 30, 8, 8}));
  auto ouput = module({x});

however I got following error

error: no match for call to ‘(torch::jit::script::Module {aka torch::jit::Module}) ()’
35 | auto ouput = module({x});

do we have way to use dictionary as input in c++

solved
I can use torch::Dict instead of torch::OrderedDict.

    auto x = torch::Dict<std::string, torch::Tensor>();
    x.insert("feat1", torch::rand({1, 10, 64, 64}));
    x.insert("feat2", torch::rand({1, 20, 16, 16}));
    x.insert("feat3", torch::rand({1, 30, 8, 8}));
    auto ouput = module({x});
    std::cout << ouput.toGenericDict().at("feat1") << std::endl;
1 Like