Skip to content

Commit a493480

Browse files
authored
Dump IE graphs when NGRAPH_TF_DUMP_GRAPHS is set (#589)
Also, make sure IE exceptions are caught in case of compilation errors
1 parent 7e83928 commit a493480

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ngraph_bridge/ie_executable.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ IE_Executable::IE_Executable(shared_ptr<Function> func, string device)
4444
m_network = InferenceEngine::CNNNetwork(func);
4545
set_parameters_and_results(*func);
4646

47+
if (std::getenv("NGRAPH_TF_DUMP_GRAPHS")) {
48+
auto& name = m_network.getName();
49+
m_network.serialize(name + ".xml", name + ".bin");
50+
}
51+
4752
NGRAPH_VLOG(2) << "Loading IE CNN network to device " << m_device;
4853

4954
InferenceEngine::Core ie;

ngraph_bridge/ngraph_encapsulate_impl.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,12 @@ Status NGraphEncapsulateImpl::Compile(
9494
BackendManager::LockBackend(backend_name);
9595
try {
9696
ng_exec = op_backend->compile(ng_function);
97-
} catch (...) {
97+
} catch (const std::exception& ex) {
9898
BackendManager::UnlockBackend(backend_name);
9999
string fn_name = ng_function->get_friendly_name();
100-
Status st =
101-
NgraphSerialize("tf_function_" + fn_name + ".json", ng_function);
100+
NgraphSerialize("tf_function_" + fn_name + ".json", ng_function);
102101
BackendManager::ReleaseBackend(backend_name);
103-
return errors::Internal(
104-
"Failed to compile ng_function.",
105-
(st.ok() ? ""
106-
: " Failed to serialize as well with error: " +
107-
st.error_message()));
102+
return errors::Internal("Failed to compile ng_function: ", ex.what());
108103
}
109104
BackendManager::UnlockBackend(backend_name);
110105
return Status::OK();

0 commit comments

Comments
 (0)