Skip to content

Commit

Permalink
List all registered backends in case particular backend is not found (#…
Browse files Browse the repository at this point in the history
…3088)

Summary:
Print all backends, improve debuggability in case particular backend is missing.

Documentation:
n/a
Pull Request resolved: #3088

Differential Revision: D15781780

Pulled By: rdzhabarov

fbshipit-source-id: 5edb63be413dfd934effafcda18f54b7aa41b9df
  • Loading branch information
Roman Dzhabarov authored and facebook-github-bot committed Jun 12, 2019
1 parent 4ad57d7 commit b2844bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/glow/Support/Register.h
Expand Up @@ -62,7 +62,7 @@ template <class Key, class Base> class FactoryRegistry {
return it->second->create(); return it->second->create();
} }


private: /// \returns all registered factories.
static FactoryMap &factories() { static FactoryMap &factories() {
static FactoryMap *factories = new FactoryMap(); static FactoryMap *factories = new FactoryMap();
return *factories; return *factories;
Expand Down
8 changes: 8 additions & 0 deletions lib/Backends/Backends.cpp
Expand Up @@ -25,6 +25,14 @@ Backend *createBackend(BackendKind backendKind) {


Backend *createBackend(llvm::StringRef backendName) { Backend *createBackend(llvm::StringRef backendName) {
auto *backend = FactoryRegistry<std::string, Backend>::get(backendName); auto *backend = FactoryRegistry<std::string, Backend>::get(backendName);

if (backend == nullptr) {
LOG(INFO) << "List of all registered backends:";
for (const auto &factory :
FactoryRegistry<std::string, Backend>::factories()) {
LOG(INFO) << factory.first;
}
}
CHECK(backend) << strFormat("Cannot find registered backend: %s", CHECK(backend) << strFormat("Cannot find registered backend: %s",
backendName.data()); backendName.data());
return backend; return backend;
Expand Down

0 comments on commit b2844bb

Please sign in to comment.