From 651ff9ffb418a3665bac55efc3fe42bbe4b68640 Mon Sep 17 00:00:00 2001 From: Robert Kimball Date: Mon, 15 Oct 2018 15:02:11 -0700 Subject: [PATCH] handle unsupported ops (#1816) --- src/ngraph/cpio.cpp | 15 +++++---------- src/ngraph/cpio.hpp | 1 - src/ngraph/serializer.cpp | 15 +++++++++++---- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/ngraph/cpio.cpp b/src/ngraph/cpio.cpp index c1b6daca193..1b476814051 100644 --- a/src/ngraph/cpio.cpp +++ b/src/ngraph/cpio.cpp @@ -152,7 +152,11 @@ cpio::Writer::Writer(const string& filename) cpio::Writer::~Writer() { - close(); + write("TRAILER!!!", nullptr, 0); + if (m_my_stream.is_open()) + { + m_my_stream.close(); + } } void cpio::Writer::open(ostream& out) @@ -166,15 +170,6 @@ void cpio::Writer::open(const string& filename) m_my_stream.open(filename, ios_base::binary | ios_base::out); } -void cpio::Writer::close() -{ - write("TRAILER!!!", nullptr, 0); - if (m_my_stream.is_open()) - { - m_my_stream.close(); - } -} - void cpio::Writer::write(const string& record_name, const void* data, uint32_t size_in_bytes) { if (m_stream) diff --git a/src/ngraph/cpio.hpp b/src/ngraph/cpio.hpp index c9877e806c6..765b4ec1277 100644 --- a/src/ngraph/cpio.hpp +++ b/src/ngraph/cpio.hpp @@ -88,7 +88,6 @@ class ngraph::cpio::Writer void open(std::ostream& out); void open(const std::string& filename); - void close(); void write(const std::string& file_name, const void* data, uint32_t size_in_bytes); private: diff --git a/src/ngraph/serializer.cpp b/src/ngraph/serializer.cpp index 8e344eaac40..b193d7d091c 100644 --- a/src/ngraph/serializer.cpp +++ b/src/ngraph/serializer.cpp @@ -109,6 +109,7 @@ using const_data_callback_t = shared_ptr(const string&, const element::Typ enum class OP_TYPEID { #include "ngraph/op/op_tbl.hpp" + UnknownOp }; #undef NGRAPH_OP @@ -123,7 +124,13 @@ static OP_TYPEID get_typeid(const string& s) #include "ngraph/op/op_tbl.hpp" }; #undef NGRAPH_OP - return typeid_map.at(s); + OP_TYPEID rc = OP_TYPEID::UnknownOp; + auto it = typeid_map.find(s); + if (it != typeid_map.end()) + { + rc = it->second; + } + return rc; } template @@ -208,8 +215,6 @@ void ngraph::serialize(ostream& out, shared_ptr func, size_t i }, true); }); - - writer.close(); } static string serialize(shared_ptr func, size_t indent, bool binary_constant_data) @@ -1024,7 +1029,7 @@ static shared_ptr node = make_shared(args[0]); break; } - default: + case OP_TYPEID::UnknownOp: { stringstream ss; ss << "unsupported op " << node_op; @@ -1514,6 +1519,8 @@ static json write(const Node& n, bool binary_constant_data) node["compute_max"] = tmp->get_compute_max(); break; } + case OP_TYPEID::UnknownOp: { break; + } } #pragma GCC diagnostic pop