Skip to content

Commit f11ca06

Browse files
committed
Refactor compiler type selection
1 parent 4ff7d8b commit f11ca06

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

src/plugins/intel_npu/src/common/include/intel_npu/common/npu.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,15 @@ class IEngineBackend : public std::enable_shared_from_this<IEngineBackend> {
5656

5757
class ICompilerAdapter {
5858
public:
59-
ICompilerAdapter(ov::intel_npu::CompilerType compilerType) : _compilerType(compilerType) {}
6059
virtual std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model,
6160
const Config& config) const = 0;
6261
virtual std::shared_ptr<IGraph> parse(std::vector<uint8_t> network, const Config& config) const = 0;
6362
virtual std::shared_ptr<IGraph> parse(const std::shared_ptr<ov::AlignedBuffer>& mmapNetwork, const Config& config) const = 0;
6463
virtual ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const = 0;
64+
virtual ov::intel_npu::CompilerType getCompilerType() const = 0;
6565

6666
virtual ~ICompilerAdapter() = default;
6767

68-
ov::intel_npu::CompilerType getCompilerType() {
69-
return _compilerType;
70-
}
7168
private:
7269
ov::intel_npu::CompilerType _compilerType;
7370
};

src/plugins/intel_npu/src/compiler_adapter/include/driver_compiler_adapter.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ namespace intel_npu {
2222

2323
class DriverCompilerAdapter final : public ICompilerAdapter {
2424
public:
25-
DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct, ov::intel_npu::CompilerType compilerType);
25+
DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct);
2626

2727
std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;
2828

2929
std::shared_ptr<IGraph> parse(std::vector<uint8_t> network, const Config& config) const override;
3030

31-
std::shared_ptr<IGraph> parse(const std::shared_ptr<ov::AlignedBuffer>& mmapNetwork, const Config& config) const;
31+
std::shared_ptr<IGraph> parse(const std::shared_ptr<ov::AlignedBuffer>& mmapNetwork, const Config& config) const override;
3232

3333
ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;
3434

35+
ov::intel_npu::CompilerType getCompilerType() const override {
36+
return ov::intel_npu::CompilerType::DRIVER;
37+
}
38+
3539
private:
3640
/**
3741
* @brief Serialize input / output information to string format.

src/plugins/intel_npu/src/compiler_adapter/include/plugin_compiler_adapter.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace intel_npu {
1717

1818
class PluginCompilerAdapter final : public ICompilerAdapter {
1919
public:
20-
PluginCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct, ov::intel_npu::CompilerType compilerType);
20+
PluginCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct);
2121

2222
std::shared_ptr<IGraph> compile(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;
2323

@@ -29,6 +29,10 @@ class PluginCompilerAdapter final : public ICompilerAdapter {
2929

3030
ov::SupportedOpsMap query(const std::shared_ptr<const ov::Model>& model, const Config& config) const override;
3131

32+
ov::intel_npu::CompilerType getCompilerType() const override {
33+
return ov::intel_npu::CompilerType::MLIR;
34+
}
35+
3236
private:
3337
std::shared_ptr<ZeroInitStructsHolder> _zeroInitStruct;
3438

src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,9 @@ std::string rankToLegacyLayoutString(const size_t rank) {
141141

142142
namespace intel_npu {
143143

144-
DriverCompilerAdapter::DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct, ov::intel_npu::CompilerType compilerType)
144+
DriverCompilerAdapter::DriverCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct)
145145
: _zeroInitStruct(zeroInitStruct),
146-
_logger("DriverCompilerAdapter", Logger::global().level()),
147-
ICompilerAdapter(compilerType) {
146+
_logger("DriverCompilerAdapter", Logger::global().level()) {
148147
_logger.debug("initialize DriverCompilerAdapter start");
149148

150149
uint32_t graphExtVersion = _zeroInitStruct->getGraphDdiTable().version();

src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ ov::SoPtr<intel_npu::ICompiler> loadCompiler(const std::string& libpath) {
5252

5353
namespace intel_npu {
5454

55-
PluginCompilerAdapter::PluginCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct, ov::intel_npu::CompilerType compilerType)
55+
PluginCompilerAdapter::PluginCompilerAdapter(const std::shared_ptr<ZeroInitStructsHolder>& zeroInitStruct)
5656
: _zeroInitStruct(zeroInitStruct),
57-
_logger("PluginCompilerAdapter", Logger::global().level()),
58-
ICompilerAdapter(compilerType) {
57+
_logger("PluginCompilerAdapter", Logger::global().level()) {
5958
_logger.debug("initialize PluginCompilerAdapter start");
6059

6160
_logger.info("MLIR compiler will be used.");

src/plugins/intel_npu/src/plugin/src/plugin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -847,15 +847,15 @@ std::unique_ptr<ICompilerAdapter> Plugin::getCompiler(const Config& config) cons
847847
switch (compilerType) {
848848
case ov::intel_npu::CompilerType::MLIR: {
849849
if (_backends->getBackendName() != "LEVEL0") {
850-
return std::make_unique<PluginCompilerAdapter>(nullptr, compilerType);
850+
return std::make_unique<PluginCompilerAdapter>(nullptr);
851851
}
852852

853853
auto zeroBackend = std::dynamic_pointer_cast<ZeroEngineBackend>(_backends->getIEngineBackend()._ptr);
854854
if (zeroBackend == nullptr) {
855-
return std::make_unique<PluginCompilerAdapter>(nullptr, compilerType);
855+
return std::make_unique<PluginCompilerAdapter>(nullptr);
856856
}
857857

858-
return std::make_unique<PluginCompilerAdapter>(zeroBackend->getInitStruct(), compilerType);
858+
return std::make_unique<PluginCompilerAdapter>(zeroBackend->getInitStruct());
859859
}
860860
case ov::intel_npu::CompilerType::DRIVER: {
861861
if (_backends->getBackendName() != "LEVEL0") {
@@ -867,7 +867,7 @@ std::unique_ptr<ICompilerAdapter> Plugin::getCompiler(const Config& config) cons
867867
OPENVINO_THROW("Failed to cast zeroBackend, zeroBackend is a nullptr");
868868
}
869869

870-
return std::make_unique<DriverCompilerAdapter>(zeroBackend->getInitStruct(), compilerType);
870+
return std::make_unique<DriverCompilerAdapter>(zeroBackend->getInitStruct());
871871
}
872872
default:
873873
OPENVINO_THROW("Invalid NPU_COMPILER_TYPE");

0 commit comments

Comments
 (0)