Skip to content

Commit

Permalink
call getLatestBuildError when pfn-related function is called and remo…
Browse files Browse the repository at this point in the history
…ve exception handle fuction that would never be called
  • Loading branch information
ShaojieZhuIntel committed Sep 25, 2024
1 parent e1c167a commit a4e8679
Showing 1 changed file with 67 additions and 42 deletions.
109 changes: 67 additions & 42 deletions src/plugins/intel_npu/src/compiler/src/zero_compiler_in_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,17 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::seriazlideIRModelAndQuery
// Create querynetwork handle
ze_result_t result = _graphDdiTableExt.pfnQueryNetworkCreate(_context, _deviceHandle, &desc, &hGraphQueryNetwork);

if (ZE_RESULT_SUCCESS != result) {
OPENVINO_THROW("L0 seriazlideIRModelAndQueryNetworkCreateV1",
" result: ",
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result),
". ",
getLatestBuildError());
}

return result;
}

Expand All @@ -646,7 +657,9 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::query
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr;
Expand Down Expand Up @@ -695,7 +708,9 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::seriazlideIRModelAndQuery
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

return result;
Expand All @@ -717,7 +732,9 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::query
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

ze_graph_query_network_handle_t hGraphQueryNetwork = nullptr;
Expand All @@ -736,15 +753,6 @@ template <typename T, std::enable_if_t<!NotSupportQuery(T), bool>>
std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQueryResultFromSupportedLayers(
ze_result_t result,
ze_graph_query_network_handle_t& hGraphQueryNetwork) const {
if (ZE_RESULT_SUCCESS != result) {
OPENVINO_THROW("L0 getQueryResultFromSupportedLayers",
" result: ",
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
}

// Get the size of query result
size_t size = 0;
result = _graphDdiTableExt.pfnQueryNetworkGetSupportedLayers(hGraphQueryNetwork, &size, nullptr);
Expand All @@ -755,7 +763,9 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQu
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

// Get the result data of query
Expand All @@ -768,7 +778,9 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQu
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

result = _graphDdiTableExt.pfnQueryNetworkDestroy(hGraphQueryNetwork);
Expand All @@ -778,7 +790,9 @@ std::unordered_set<std::string> LevelZeroCompilerInDriver<TableExtension>::getQu
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

return parseQueryResult(supportedLayers);
Expand Down Expand Up @@ -821,8 +835,21 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::createGraph(const ze_grap
serializedIR.second.get(),
buildFlags.c_str()};

_logger.debug("createGraph - performing pfnCreate");
// Create querynetwork handle
return _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, graph);
auto result = _graphDdiTableExt.pfnCreate(_context, _deviceHandle, &desc, graph);
if (ZE_RESULT_SUCCESS != result) {
OPENVINO_THROW("L0 pfnCreate",
" result: ",
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result),
". ",
getLatestBuildError());
}

return result;
}

// For ext version >= 1.5, calling pfnCreate2 api in _graphDdiTableExt
Expand Down Expand Up @@ -850,7 +877,9 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::createGraph(const ze_grap
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

return result;
Expand Down Expand Up @@ -885,14 +914,6 @@ ze_result_t LevelZeroCompilerInDriver<TableExtension>::seriazlideIRModelAndCreat
_logger.info("compileIR Using extension version: %s", typeid(TableExtension).name());
ze_result_t result = createGraph(format, serializedIR, buildFlags, flags, &graphHandle);

if (ZE_RESULT_SUCCESS != result) {
OPENVINO_THROW("Failed to create graph. L0 createGraph",
" result: ",
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
}
return result;
}

Expand All @@ -909,24 +930,16 @@ NetworkDescription LevelZeroCompilerInDriver<TableExtension>::compile(const std:
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

// Graph handle should be used only in scope of compile / parse functions.
ze_graph_handle_t graphHandle;

result = seriazlideIRModelAndCreateGraph(model, config, deviceGraphProperties, graphHandle);

OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,
"Failed to compile network. L0 createGraph",
" result: ",
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result),
". ",
getLatestBuildError());

auto networkMeta = getNetworkMeta(graphHandle);
networkMeta.name = model->get_friendly_name();

Expand Down Expand Up @@ -961,7 +974,9 @@ NetworkMetadata LevelZeroCompilerInDriver<TableExtension>::parse(const std::vect
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}
} else {
OPENVINO_THROW("Empty blob");
Expand Down Expand Up @@ -989,7 +1004,9 @@ uint32_t LevelZeroCompilerInDriver<TableExtension>::getSupportedOpsetVersion() c
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}
const auto maxOpsetVersion = graphProperties.maxOVOpsetVersionSupported;
_logger.info("getSupportedOpsetVersion Max supported version of opset in CiD: %d", maxOpsetVersion);
Expand Down Expand Up @@ -1067,7 +1084,9 @@ void LevelZeroCompilerInDriver<TableExtension>::getMetadata(ze_graph_dditable_ex
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

switch (arg.type) {
Expand Down Expand Up @@ -1098,7 +1117,9 @@ void LevelZeroCompilerInDriver<TableExtension>::getMetadata(ze_graph_dditable_ex
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

std::optional<ze_graph_argument_metadata_t> optionalMetadata = std::nullopt;
Expand All @@ -1112,7 +1133,9 @@ void LevelZeroCompilerInDriver<TableExtension>::getMetadata(ze_graph_dditable_ex
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

optionalMetadata = std::optional(metadata);
Expand Down Expand Up @@ -1143,7 +1166,9 @@ NetworkMetadata LevelZeroCompilerInDriver<TableExtension>::getNetworkMeta(ze_gra
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result));
uint64_t(result),
". ",
getLatestBuildError());
}

NetworkMetadata meta;
Expand Down

0 comments on commit a4e8679

Please sign in to comment.