-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NPU] Create compiler adapter factory (#27962)
### Details: Clean-up code - create compiler adapter factory class to create the proper compiler adapter. ### Tickets: - *CVS-158848* Signed-off-by: Bogdan Pereanu <[email protected]>
- Loading branch information
Showing
12 changed files
with
88 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/plugins/intel_npu/src/common/include/intel_npu/common/icompiler_adapter.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "intel_npu/common/igraph.hpp" | ||
|
||
namespace intel_npu { | ||
|
||
class ICompilerAdapter { | ||
public: | ||
virtual std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model, | ||
const Config& config) const = 0; | ||
virtual std::shared_ptr<IGraph> parse(std::vector<uint8_t> network, const Config& config) const = 0; | ||
virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const = 0; | ||
|
||
virtual ~ICompilerAdapter() = default; | ||
}; | ||
|
||
} // namespace intel_npu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/plugins/intel_npu/src/compiler_adapter/include/compiler_adapter_factory.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (C) 2018-2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "driver_compiler_adapter.hpp" | ||
#include "intel_npu/common/icompiler_adapter.hpp" | ||
#include "intel_npu/config/compiler.hpp" | ||
#include "intel_npu/config/config.hpp" | ||
#include "plugin_compiler_adapter.hpp" | ||
|
||
namespace intel_npu { | ||
|
||
class CompilerAdapterFactory final { | ||
public: | ||
const std::unique_ptr<ICompilerAdapter> getCompiler(const ov::SoPtr<IEngineBackend>& engineBackend, | ||
const Config& config) const { | ||
auto compilerType = config.get<COMPILER_TYPE>(); | ||
switch (compilerType) { | ||
case ov::intel_npu::CompilerType::MLIR: { | ||
if (engineBackend->getName() != "LEVEL0") { | ||
return std::make_unique<PluginCompilerAdapter>(nullptr); | ||
} | ||
|
||
return std::make_unique<PluginCompilerAdapter>(engineBackend->getInitStructs()); | ||
} | ||
case ov::intel_npu::CompilerType::DRIVER: { | ||
if (engineBackend->getName() != "LEVEL0") { | ||
OPENVINO_THROW("NPU Compiler Adapter must be used with LEVEL0 backend"); | ||
} | ||
|
||
return std::make_unique<DriverCompilerAdapter>(engineBackend->getInitStructs()); | ||
} | ||
default: | ||
OPENVINO_THROW("Invalid NPU_COMPILER_TYPE"); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace intel_npu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters