torch/csrc/jit/import.cpp
// Given a full name of a parameter or method,
// return the parent submodule and local name
Given a full name of a parameter or method,
return the parent submodule and local name
Given a full name of a parameter or method return the parent submodule and local name
std::pair<std::shared_ptr<script::Module>, std::string> ModuleDecoder::parseFullName(
    std::shared_ptr<script::Module> root_module,
    const std::string fullname) {
  std::vector<std::string> vec;
  std::stringstream ss(fullname);
  std::string name;
  while (std::getline(ss, name, '.')) {
    vec.push_back(name);
  }
  std::shared_ptr<script::Module> curr = root_module;
  for (size_t i = 0; i < vec.size() - 1; i++) {
    if (curr->find_module(vec[i]) == nullptr) {
      curr->register_module(vec[i], std::make_shared<script::Module>());
    }
    curr = curr->get_module(vec[i]);
  }
  return std::make_pair(curr, vec.back());
}
std :: pair < std :: shared_ptr < script :: Module > , std :: string > ModuleDecoder :: parseFullName ( std :: shared_ptr < script :: Module > root_module , const std :: string fullname ) { std :: vector < std :: string > vec ; std :: stringstream ss ( fullname ) ; std :: string name ; while ( std :: getline ( ss , name , ' ' ) ) { vec . push_back ( name ) ; } std :: shared_ptr < script :: Module > curr = root_module ; for ( size_t i = 0 ; i < vec . size ( ) - 1 ; i ++ ) { if ( curr -> find_module ( vec [ i ] ) == nullptr ) { curr -> register_module ( vec [ i ] , std :: make_shared < script :: Module > ( ) ) ; } curr = curr -> get_module ( vec [ i ] ) ; } return std :: make_pair ( curr , vec . back ( ) ) ; }
Given a full name of a parameter or method,
return the parent submodule and local name
Given a full name of a parameter or method return the parent submodule and local name