Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HETERO] Fix some scan coverity issues #23788

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/plugins/hetero/src/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ ov::Any ov::hetero::CompiledModel::get_property(const std::string& name) const {
add_ro_properties(ov::supported_properties.name(), supported_properties);
add_ro_properties(ov::device::properties.name(), supported_properties);
add_ro_properties(ov::device::priorities.name(), supported_properties);
return decltype(ov::supported_properties)::value_type(supported_properties);
return decltype(ov::supported_properties)::value_type(std::move(supported_properties));
} else if (ov::device::properties == name) {
ov::AnyMap all_devices = {};
for (const auto& comp_model_desc : m_compiled_submodels) {
Expand Down Expand Up @@ -319,7 +319,7 @@ ov::Any ov::hetero::CompiledModel::get_property(const std::string& name) const {
s.insert(comp_model_desc.device);
device_names.push_back(comp_model_desc.device);
}
return decltype(ov::execution_devices)::value_type{device_names};
return decltype(ov::execution_devices)::value_type{std::move(device_names)};
} else if (ov::hetero::number_of_submodels == name) {
return decltype(ov::hetero::number_of_submodels)::value_type{m_compiled_submodels.size()};
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/hetero/src/graph_debug_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ static const std::vector<std::string> colors = {
void dump_affinities(const std::shared_ptr<ov::Model>& model,
const std::map<std::string, std::string>& supported_ops_map,
const std::unordered_set<std::string>& devices) {
auto name = model->get_friendly_name();
const auto& name = model->get_friendly_name();
// clang-format off
ov::pass::VisualizeTree{
"hetero_affinity_" + name + ".dot",
[&](const ov::Node& node, std::vector<std::string>& attributes) {
auto nodeDevice = supported_ops_map.at(node.get_friendly_name());
const auto& nodeDevice = supported_ops_map.at(node.get_friendly_name());
int colorIndex = 0;
for (auto&& device : devices) {
if (device == nodeDevice) {
Expand All @@ -60,7 +60,7 @@ void dump_affinities(const std::shared_ptr<ov::Model>& model,
void dump_subgraphs(const std::shared_ptr<ov::Model>& model,
const std::map<std::string, std::string>& supported_ops_map,
const std::map<std::string, int>& map_id) {
auto name = model->get_friendly_name();
const auto& name = model->get_friendly_name();
// clang-format off
ov::pass::VisualizeTree{
"hetero_subgraphs_" + name + ".dot",
Expand Down
12 changes: 8 additions & 4 deletions src/plugins/hetero/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,18 @@ std::pair<ov::SupportedOpsMap, ov::hetero::SubgraphsMappingInfo> ov::hetero::Plu
} else if (available_discrete_device_memory >= 1.2 * total_ops_size ||
available_device_mem_map.count("CPU")) {
float model_ratio =
static_cast<float>(available_device_mem_map[device_name] * 1.0 / (1.2 * total_ops_size));
total_ops_size > 0
? static_cast<float>(available_device_mem_map[device_name] * 1.0 / (1.2 * total_ops_size))
: 1.0f;
if (total_ops_size < available_device_mem_map[device_name]) {
model_ratio = 1.0f;
}
device_config[ov::internal::query_model_ratio.name()] = model_ratio;
} else {
float model_ratio = static_cast<float>(available_device_mem_map[device_name] * 1.0 /
available_discrete_device_memory);
float model_ratio = available_discrete_device_memory > 0
? static_cast<float>(available_device_mem_map[device_name] * 1.0 /
available_discrete_device_memory)
: 1.0f;
device_config[ov::internal::query_model_ratio.name()] = model_ratio;
}
// Remove the current device
Expand Down Expand Up @@ -275,7 +279,7 @@ ov::Any ov::hetero::Plugin::get_property(const std::string& name, const ov::AnyM
supported_properties.reserve(ro_properties.size() + rw_properties.size());
supported_properties.insert(supported_properties.end(), ro_properties.begin(), ro_properties.end());
supported_properties.insert(supported_properties.end(), rw_properties.begin(), rw_properties.end());
return decltype(ov::supported_properties)::value_type(supported_properties);
return decltype(ov::supported_properties)::value_type(std::move(supported_properties));
} else if (ov::internal::supported_properties == name) {
return decltype(ov::internal::supported_properties)::value_type{
ov::PropertyName{ov::internal::caching_properties.name(), ov::PropertyMutability::RO}};
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/hetero/src/subgraph_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ void ov::hetero::SubgraphCollector::split_subgraphs_by_parameter_results() {
_subgraph_ids.emplace(result, output_subgraph_id);
_intermediate_results.push_back(result);
for (const auto& input_subset : input_subsets) {
const auto input_subgraph_id = input_subset.first;
const auto inputs = input_subset.second;
const auto& input_subgraph_id = input_subset.first;
const auto& inputs = input_subset.second;
// Avoid duplicate parameters in the same subgraph
auto parameter =
std::make_shared<ov::op::v0::Parameter>(output.get_element_type(), output.get_partial_shape());
Expand Down Expand Up @@ -428,9 +428,9 @@ void ov::hetero::merge_submodels(std::vector<std::shared_ptr<ov::Model>>& submod
port_in_index++;
continue;
}
auto submodel_out_index = item->second.first;
auto submodel_out_result_name = item->second.second;
auto submodel_out = submodels.at(submodel_out_index);
const auto& submodel_out_index = item->second.first;
const auto& submodel_out_result_name = item->second.second;
const auto& submodel_out = submodels.at(submodel_out_index);

std::shared_ptr<ov::op::v0::Result> result_to_replace = nullptr;
for (auto& result : submodel_out->get_results()) {
Expand Down Expand Up @@ -600,7 +600,7 @@ ov::hetero::SubgraphsMappingInfo ov::hetero::mask_model_subgraphs_by_ops(std::sh
const std::string subgraph_id_rt_info_name = "HETERO_SUBGRAPH_ID";
const std::string input_id_rt_info_name = "HETERO_INPUT_ID";
const std::string output_id_rt_info_name = "HETERO_OUTPUT_ID";
const auto name = model->get_friendly_name();
const auto& name = model->get_friendly_name();

SubgraphsVector ordered_subgraphs;
SubgraphsMappingInfo mapping_info;
Expand Down
Loading