caffe2/opt/onnxifi_transformer.cc
// TODO(yinghai): Remove the awkward conversion between unordered_map and map
Remove the awkward conversion between unordered_map and map
Remove the awkward conversion between unordered_map and map
std::unordered_map<std::string, TensorShape> InferShapes(
    Workspace* ws,
    NetDef* pred_net,
    CaffeMap<std::string, TensorShape>* shape_hints_ordered) {
  const std::vector<std::string>& ws_blobs = ws->Blobs();
  for (const auto& s : ws_blobs) {
    auto shape = GetTensorShapeOfBlob(ws->GetBlob(s));
    if (!shape.unknown_shape()) {
      shape_hints_ordered->emplace(s, std::move(shape));
    }
  }
  std::vector<NetDef*> nets;
  nets.emplace_back(pred_net);
  InferBlobShapesAndTypes(*shape_hints_ordered, nets);
  std::unordered_map<std::string, TensorShape> shape_hints;
  for (const auto& kv : *shape_hints_ordered) {
    shape_hints.emplace(kv.first, kv.second);
  }
  return shape_hints;
}
std :: unordered_map < std :: string , TensorShape > InferShapes ( Workspace * ws , NetDef * pred_net , CaffeMap < std :: string , TensorShape > * shape_hints_ordered ) { const std :: vector < std :: string > & ws_blobs = ws -> Blobs ( ) ; for ( const auto & s : ws_blobs ) { auto shape = GetTensorShapeOfBlob ( ws -> GetBlob ( s ) ) ; if ( ! shape . unknown_shape ( ) ) { shape_hints_ordered -> emplace ( s , std :: move ( shape ) ) ; } } std :: vector < NetDef * > nets ; nets . emplace_back ( pred_net ) ; InferBlobShapesAndTypes ( * shape_hints_ordered , nets ) ; std :: unordered_map < std :: string , TensorShape > shape_hints ; for ( const auto & kv : * shape_hints_ordered ) { shape_hints . emplace ( kv . first , kv . second ) ; } return shape_hints ; }
TODO(yinghai): Remove the awkward conversion between unordered_map and map
TODO ( yinghai ) : Remove the awkward conversion between unordered_map and map
// Populate shapes from workplace