Skip to content

Commit

Permalink
print available modules in predictor error message (pytorch#78101)
Browse files Browse the repository at this point in the history
Summary:
print available modules when throwing a module not found exception

I believe that improves UX

Differential Revision: D36580924

Pull Request resolved: pytorch#78101
Approved by: https://github.com/mikeiovine
  • Loading branch information
tenpercent authored and pytorchmergebot committed May 24, 2022
1 parent 3a921f2 commit e4f5203
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion caffe2/predictor/predictor_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,22 @@ namespace caffe2 {
namespace predictor_utils {

TORCH_API const NetDef& getNet(const MetaNetDef& def, const std::string& name) {
std::string net_names;
bool is_first = true;
for (const auto& n : def.nets()) {
if (!is_first) {
net_names += ", ";
}
is_first = false;
net_names += n.key();
if (n.key() == name) {
return n.value();
}
}
CAFFE_THROW("Net not found: ", name);
CAFFE_THROW("Net not found: ",
name,
"; available nets: ",
net_names);
}

std::unique_ptr<MetaNetDef> extractMetaNetDef(
Expand Down

0 comments on commit e4f5203

Please sign in to comment.