Commit 3b474dfb authored by Nick Korovaiko's avatar Nick Korovaiko Committed by Robert Kimball

Fix a segfault due to an unhandled op (#530)

* fix a segfault due to an unhandled op

* fix a missing new line
parent c29c9f89
......@@ -462,7 +462,14 @@ using namespace ngraph::runtime;
{
continue;
}
Node& node = *op_list[i];
auto handler = dispatcher.find(type_index(typeid(node)));
if (handler == dispatcher.end())
{
throw ngraph_error("Unhandled op during code generation : " + node.description());
}
string s = emit_op_as_function(node, "f");
node_cache.insert({&node, s});
}
......
......@@ -288,3 +288,23 @@ TEST(cpu_fusion, fuse_fprop_bn)
size_t ccg = count_ops_of_type<op::BatchNorm>(func);
ASSERT_EQ(ccg, 1);
}
class UnhandledOp : public ngraph::op::Abs
{
public:
UnhandledOp(const std::shared_ptr<Node>& arg)
: Abs(arg)
{
}
};
TEST(cpu_fusion, unhandled_op)
{
auto A = make_shared<op::Parameter>(element::f32, Shape{});
auto unhandled = make_shared<UnhandledOp>(A);
auto f = make_shared<Function>(unhandled, op::Parameters{A});
auto manager = runtime::Manager::get("CPU");
auto backend = manager->allocate_backend();
auto external = manager->compile(f);
ASSERT_THROW(backend->make_call_frame(external), 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