Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,24 @@ std::shared_ptr<IGraph> PluginCompilerAdapter::compile(const std::shared_ptr<con
auto [tensor, compatibilityDescriptor] = _compiler->compile(model, config);
_logger.debug("compile end");

if (config.get<COMPILATION_MODE>().find("HostCompile") == 0) {
auto isHostCompiledBlob = [&]() {
// when compilation mode is not set,
// vpux compiler may generate a blob for HostCompile mode when both input and output shapes are dynamic,
// we need to detect it and use the right runtime to get metadata
if (!config.has<COMPILATION_MODE>()) {
const size_t headerSize = std::min(tensor.get_byte_size(), size_t{20});
const std::string_view header(static_cast<const char*>(tensor.data()), headerSize);
if (header.find("llvm") != std::string_view::npos ||
header.find("NPUByte\x00") != std::string_view::npos) {
_logger.debug("HostCompile mode is detected based on blob header, use internal function to get metadata!");
return true;
}
}
return false;
};

if ((config.get<COMPILATION_MODE>().find("HostCompile") == 0) ||
isHostCompiledBlob()) {
NPUVMRuntimeApi::initializeFromBlob(tensor.data(), tensor.get_byte_size());

// metadata will be obtained in initialze() of DynamicGraph
Expand Down
Loading