Commit a2d97200 authored by Christian Convey's avatar Christian Convey Committed by Christian Convey

Better error message from runtime::Manager.

parent 4345e39d
......@@ -91,7 +91,16 @@ Manager::FactoryMap& Manager::get_factory_map()
std::shared_ptr<Manager> Manager::get(const std::string& name)
{
Manager::load_plugins(RUNTIME_PLUGIN_LIBS);
return get_factory_map().at(name)(name);
auto iter = get_factory_map().find(name);
if (iter == get_factory_map().end())
{
throw ngraph_error("No nGraph runtime with name '" + name + "' has been registered.");
}
Factory& f = iter->second;
return f(name);
}
Manager::Factory Manager::register_factory(const std::string& name, Factory factory)
......
......@@ -36,6 +36,7 @@ set (SRC
pass_liveness.cpp
pass_manager.cpp
pass_memory_layout.cpp
runtime_manager.cpp
serialize.cpp
pattern.cpp
shape.cpp
......
// ----------------------------------------------------------------------------
// Copyright 2018 Nervana Systems Inc.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
using namespace std;
TEST(runtime_manager, invalidName)
{
ASSERT_THROW(ngraph::runtime::Manager::get("COMPLETELY-BOGUS-MANAGER-NAME"),
ngraph::ngraph_error);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment