Skip to content

Commit

Permalink
Fix clang formats
Browse files Browse the repository at this point in the history
  • Loading branch information
MirceaDan99 committed Sep 24, 2024
1 parent fdd49db commit b3c45b7
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ class ICompiler : public std::enable_shared_from_this<ICompiler> {
virtual void release([[maybe_unused]] std::shared_ptr<const NetworkDescription> networkDescription){};

virtual CompiledNetwork getCompiledNetwork(std::shared_ptr<const NetworkDescription> networkDescription) {
return CompiledNetwork{networkDescription->compiledNetwork.data(), networkDescription->compiledNetwork.size(), networkDescription->compiledNetwork};
return CompiledNetwork{networkDescription->compiledNetwork.data(),
networkDescription->compiledNetwork.size(),
networkDescription->compiledNetwork};
}

protected:
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/intel_npu/src/backend/include/zero_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ struct ze_graph_dditable_ext_decorator final {
}

// version 1.7
ze_result_t ZE_APICALL pfnGetNativeBinary2(ze_graph_handle_t hGraph,
size_t* pSize, uint8_t** pGraphNativeBinary) {
ze_result_t ZE_APICALL pfnGetNativeBinary2(ze_graph_handle_t hGraph, size_t* pSize, uint8_t** pGraphNativeBinary) {
throwWhenUnsupported("pfnGetNativeBinary2", ZE_GRAPH_EXT_VERSION_1_7);
return _impl->pfnGetNativeBinary2(hGraph, pSize, pGraphNativeBinary);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,17 @@ class LevelZeroCompilerInDriver final : public ICompiler {

template <typename T = TableExtension, typename std::enable_if_t<UseCopyForNativeBinary(T), bool> = true>
void getNativeBinary(TableExtension* graphDdiTableExt,
ze_graph_handle_t graphHandle, std::vector<uint8_t>& blob,
uint8_t** blobPtr, size_t* blobSize) const;
ze_graph_handle_t graphHandle,
std::vector<uint8_t>& blob,
uint8_t** blobPtr,
size_t* blobSize) const;

template <typename T = TableExtension, typename std::enable_if_t<!UseCopyForNativeBinary(T), bool> = true>
void getNativeBinary(TableExtension* graphDdiTableExt,
ze_graph_handle_t graphHandle, std::vector<uint8_t>& /* unusedBlob */,
uint8_t** blobPtr, size_t* blobSize) const;
ze_graph_handle_t graphHandle,
std::vector<uint8_t>& /* unusedBlob */,
uint8_t** blobPtr,
size_t* blobSize) const;

template <typename T = TableExtension, typename std::enable_if_t<SupportAPIGraphQueryNetworkV2(T), bool> = true>
ze_result_t seriazlideIRModelAndQueryNetworkCreateV2(const std::shared_ptr<const ov::Model>& model,
Expand Down
93 changes: 48 additions & 45 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 @@ -367,55 +367,57 @@ template <typename T, std::enable_if_t<UseCopyForNativeBinary(T), bool>>
void LevelZeroCompilerInDriver<TableExtension>::getNativeBinary(TableExtension* graphDdiTableExt,
ze_graph_handle_t graphHandle,
std::vector<uint8_t>& blob,
uint8_t** blobPtr, size_t* blobSize) const {
// Get blob size first
auto result = _graphDdiTableExt->pfnGetNativeBinary(graphHandle, blobSize, nullptr);
blob.resize(*blobSize);

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

// Get blob data
result = _graphDdiTableExt->pfnGetNativeBinary(graphHandle, blobSize, blob.data());

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

*blobPtr = blob.data();
uint8_t** blobPtr,
size_t* blobSize) const {
// Get blob size first
auto result = _graphDdiTableExt->pfnGetNativeBinary(graphHandle, blobSize, nullptr);
blob.resize(*blobSize);

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

// Get blob data
result = _graphDdiTableExt->pfnGetNativeBinary(graphHandle, blobSize, blob.data());

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

*blobPtr = blob.data();
}

template <typename TableExtension>
template <typename T, std::enable_if_t<!UseCopyForNativeBinary(T), bool>>
void LevelZeroCompilerInDriver<TableExtension>::getNativeBinary(TableExtension* graphDdiTableExt,
ze_graph_handle_t graphHandle,
std::vector<uint8_t>& /* unusedBlob */,
uint8_t** blobPtr, size_t* blobSize) const {
// Get blob ptr and size
auto result = _graphDdiTableExt->pfnGetNativeBinary2(graphHandle, blobSize, blobPtr);

OPENVINO_ASSERT(result == ZE_RESULT_SUCCESS,
"Failed to compile network. L0 pfnGetNativeBinary get blob size",
" result: ",
ze_result_to_string(result),
", code 0x",
std::hex,
uint64_t(result),
". ",
getLatestBuildError());
uint8_t** blobPtr,
size_t* blobSize) const {
// Get blob ptr and size
auto result = _graphDdiTableExt->pfnGetNativeBinary2(graphHandle, blobSize, blobPtr);

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

template <typename TableExtension>
Expand All @@ -433,10 +435,11 @@ CompiledNetwork LevelZeroCompilerInDriver<TableExtension>::getCompiledNetwork(

_logger.info("LevelZeroCompilerInDriver getCompiledNetwork returning blob");
return CompiledNetwork{blobPtr, blobSize, std::move(blob)};
} else {
_logger.info("return the blob from network description");
return CompiledNetwork{networkDescription->compiledNetwork.data(), networkDescription->compiledNetwork.size(), networkDescription->compiledNetwork};
}
_logger.info("return the blob from network description");
return CompiledNetwork{networkDescription->compiledNetwork.data(),
networkDescription->compiledNetwork.size(),
networkDescription->compiledNetwork};
}

template <typename TableExtension>
Expand Down
17 changes: 8 additions & 9 deletions src/plugins/intel_npu/src/plugin/src/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,15 @@ void CompiledModel::export_model(std::ostream& stream) const {
const auto&& blob = _compiler->getCompiledNetwork(_networkPtr);
stream.write(reinterpret_cast<const char*>(blob.data), blob.size);

if (_logger.level() == ov::log::Level::INFO) {
std::stringstream str;
str << "Blob size: " << blob.size << ", hash: " << std::hex << hash(blob);
_logger.info(str.str().c_str());

if (!stream) {
_logger.error("Write blob to stream failed. Blob is broken!");
} else {
_logger.info("Write blob to stream successfully.");
if (!stream) {
_logger.error("Write blob to stream failed. Blob is broken!");
} else {
if (_logger.level() == ov::log::Level::INFO) {
std::stringstream str;
str << "Blob size: " << blob.size << ", hash: " << std::hex << hash(blob);
_logger.info(str.str().c_str());
}
_logger.info("Write blob to stream successfully.");
}
}

Expand Down

0 comments on commit b3c45b7

Please sign in to comment.