Hetero 2.0 leftovers (#18559)

* Enable `LoadedTensor.*HETERO` test

* Fix use of `ICompiledModel::outputs()`

* Remove extra `loaded_from_cache` argument

* Misprint

* Small refactoring

* Remove extra `model` from `CompiledModelDesc`
Use `get_runtime_model()` instead

* ClangFormat
This commit is contained in:
Vitaliy Urusovskij
2023-07-17 11:58:44 +04:00
committed by GitHub
parent 2c73916093
commit aeff5056f5
5 changed files with 15 additions and 30 deletions

View File

@@ -45,12 +45,11 @@ static bool intersects(const Set& lhs, const Set& rhs) {
ov::hetero::CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model,
const std::shared_ptr<const ov::IPlugin>& plugin,
const Configuration& cfg,
bool loaded_from_cache)
const Configuration& cfg)
: ov::ICompiledModel(model, plugin),
m_cfg(cfg),
m_name(model->get_friendly_name()),
m_loaded_from_cache(loaded_from_cache) {
m_loaded_from_cache(false) {
bool dumpDotFile = m_cfg.dump_graph;
if (std::getenv("OPENVINO_HETERO_VISUALIZE"))
dumpDotFile = true;
@@ -362,7 +361,7 @@ ov::hetero::CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model
m_inputs_to_submodels_inputs[j] = {id, i};
}
for (size_t i = 0; i < orderedSubgraphs[id]._results.size(); i++) {
for (size_t j = 0; j < ICompiledModel::outputs().size(); j++)
for (size_t j = 0; j < orig_results.size(); j++)
if (orderedSubgraphs[id]._results[i] == orig_results[j])
m_outputs_to_submodels_outputs[j] = {id, i};
}
@@ -402,7 +401,6 @@ ov::hetero::CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model
subgraph._sinks,
subgraph._parameters,
m_name + '_' + std::to_string(id));
m_compiled_submodels[id].model = subFunctions[id]->clone();
auto metaDevices = get_hetero_plugin()->get_properties_per_device(m_compiled_submodels[id].device,
m_cfg.get_device_properties());
@@ -411,7 +409,7 @@ ov::hetero::CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model
auto device_config = metaDevices[m_compiled_submodels[id].device];
device_config[ov::cache_dir.name()] = "";
m_compiled_submodels[id].compiled_model = plugin->get_core()->compile_model(m_compiled_submodels[id].model,
m_compiled_submodels[id].compiled_model = plugin->get_core()->compile_model(subFunctions[id]->clone(),
m_compiled_submodels[id].device,
device_config);
++id;
@@ -422,12 +420,11 @@ ov::hetero::CompiledModel::CompiledModel(const std::shared_ptr<ov::Model>& model
ov::hetero::CompiledModel::CompiledModel(std::istream& model,
const std::shared_ptr<const ov::IPlugin>& plugin,
const Configuration& cfg,
bool loaded_from_cache)
const Configuration& cfg)
: ov::ICompiledModel(nullptr, plugin),
m_cfg(cfg),
m_name(),
m_loaded_from_cache(loaded_from_cache) {
m_loaded_from_cache(true) {
std::string heteroXmlStr;
std::getline(model, heteroXmlStr);
@@ -459,7 +456,6 @@ ov::hetero::CompiledModel::CompiledModel(std::istream& model,
auto& loadConfig = metaDevices[device];
ov::SoPtr<ov::ICompiledModel> compiled_model;
std::shared_ptr<ov::Model> ov_model;
if (get_plugin()->get_core()->device_supports_model_caching(device)) {
compiled_model = plugin->get_core()->import_model(model, device, loadConfig);
@@ -479,13 +475,12 @@ ov::hetero::CompiledModel::CompiledModel(std::istream& model,
model.read(weights.data<char>(), dataSize);
}
ov_model = plugin->get_core()->read_model(xmlString, weights);
auto ov_model = plugin->get_core()->read_model(xmlString, weights);
compiled_model = plugin->get_core()->compile_model(ov_model, device, loadConfig);
}
m_compiled_submodels.emplace_back(ov::hetero::CompiledModel::CompiledModelDesc{
device,
ov_model,
compiled_model,
});
}
@@ -692,7 +687,7 @@ void ov::hetero::CompiledModel::export_model(std::ostream& model_stream) const {
if (get_plugin()->get_core()->device_supports_model_caching(comp_model_desc.device)) {
comp_model_desc.compiled_model->export_model(model_stream);
} else {
auto model = comp_model_desc.model;
auto model = std::const_pointer_cast<ov::Model>(comp_model_desc.compiled_model->get_runtime_model());
if (!model)
OPENVINO_THROW("OpenVINO Model is empty");

View File

@@ -18,13 +18,9 @@ class CompiledModel : public ov::ICompiledModel {
public:
CompiledModel(const std::shared_ptr<ov::Model>& model,
const std::shared_ptr<const ov::IPlugin>& plugin,
const Configuration& cfg,
bool loaded_from_cache = false);
const Configuration& cfg);
CompiledModel(std::istream& model,
const std::shared_ptr<const ov::IPlugin>& plugin,
const Configuration& cfg,
bool loaded_from_cache = false);
CompiledModel(std::istream& model, const std::shared_ptr<const ov::IPlugin>& plugin, const Configuration& cfg);
void export_model(std::ostream& model) const override;
@@ -62,7 +58,6 @@ private:
struct CompiledModelDesc {
std::string device;
std::shared_ptr<ov::Model> model;
ov::SoPtr<ov::ICompiledModel> compiled_model;
};
std::vector<CompiledModelDesc> m_compiled_submodels;

View File

@@ -29,7 +29,7 @@ Configuration::Configuration(const ov::AnyMap& config, const Configuration& defa
device_priorities = value.as<std::string>();
} else if (ov::internal::exclusive_async_requests == key) {
exclusive_async_requests = value.as<bool>();
// property should be passed to underlying devices as part of `GetDeviceProperties()`
// property should be passed to underlying devices as part of `get_device_properties()`
device_properties.emplace(key, value);
} else {
if (throwOnUnsupported)

View File

@@ -52,7 +52,7 @@ std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(std::istrea
OV_ITT_SCOPED_TASK(itt::domains::Hetero, "Plugin::import_model");
auto config = Configuration{properties, m_cfg};
auto compiled_model = std::make_shared<CompiledModel>(model, shared_from_this(), config, true);
auto compiled_model = std::make_shared<CompiledModel>(model, shared_from_this(), config);
return compiled_model;
}
@@ -62,9 +62,8 @@ ov::hetero::Plugin::DeviceProperties ov::hetero::Plugin::get_properties_per_devi
DeviceProperties device_properties;
for (const auto& device_name : device_names) {
auto properties_it = device_properties.find(device_name);
if (device_properties.end() == properties_it) {
if (device_properties.end() == properties_it)
device_properties[device_name] = get_core()->get_supported_property(device_name, properties);
}
}
return device_properties;
}
@@ -90,11 +89,9 @@ ov::SupportedOpsMap ov::hetero::Plugin::query_model(const std::shared_ptr<const
auto device_names = ov::DeviceIDParser::get_hetero_devices(full_config.device_priorities);
ov::SupportedOpsMap res;
for (const auto& device_name : device_names) {
for (auto&& layer_query_result : query_results[device_name]) {
for (const auto& device_name : device_names)
for (const auto& layer_query_result : query_results[device_name])
res.emplace(layer_query_result);
}
}
return res;
}

View File

@@ -142,8 +142,6 @@ std::vector<std::string> disabledTestPatterns() {
#ifdef PROXY_PLUGIN_ENABLED
// Plugin version was changed to ov::Version
R"(.*VersionTest.*pluginCurrentVersionIsCorrect.*)",
// Issue because meta plugins use OLD API and wrap proxy which work with new API
R"(.*OVHoldersTest.*LoadedTensor.*HETERO.*)",
#endif
};
}