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

[AUTO Batch Plugin] clean 1.0 related def #22300

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
14 changes: 1 addition & 13 deletions src/plugins/auto_batch/src/compiled_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,27 +195,16 @@ ov::Any CompiledModel::get_property(const std::string& name) const {
return num_request;
} else if (name == ov::model_name.name()) {
return m_compiled_model_without_batch->get_property(name);
OPENVINO_SUPPRESS_DEPRECATED_START
} else if (name == METRIC_KEY(SUPPORTED_METRICS)) {
return std::vector<std::string>{ov::optimal_number_of_infer_requests.name(),
METRIC_KEY(SUPPORTED_METRICS),
ov::model_name.name(),
METRIC_KEY(SUPPORTED_CONFIG_KEYS),
ov::execution_devices.name()};
} else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) {
return std::vector<std::string>{ov::auto_batch_timeout.name()};
} else if (name == ov::execution_devices) {
return m_compiled_model_without_batch->get_property(name);
} else if (name == ov::loaded_from_cache) {
return m_compiled_model_without_batch->get_property(ov::loaded_from_cache.name());
} else if (name == ov::supported_properties) {
return std::vector<ov::PropertyName>{
ov::PropertyName{ov::optimal_number_of_infer_requests.name(), ov::PropertyMutability::RO},
ov::PropertyName{METRIC_KEY(SUPPORTED_METRICS), ov::PropertyMutability::RO},
ov::PropertyName{ov::model_name.name(), ov::PropertyMutability::RO},
ov::PropertyName{METRIC_KEY(SUPPORTED_CONFIG_KEYS), ov::PropertyMutability::RO},
ov::PropertyName{ov::execution_devices.name(), ov::PropertyMutability::RO},
ov::PropertyName{ov::auto_batch_timeout.name(), ov::PropertyMutability::RO}};
ov::PropertyName{ov::auto_batch_timeout.name(), ov::PropertyMutability::RW}};
} else if (name == ov::auto_batch_timeout) {
uint32_t time_out = m_time_out;
return time_out;
Expand All @@ -239,7 +228,6 @@ ov::Any CompiledModel::get_property(const std::string& name) const {
OPENVINO_THROW("Unsupported Compiled Model Property: ", name);
}
}
OPENVINO_SUPPRESS_DEPRECATED_END
}

const std::vector<ov::Output<const ov::Node>>& CompiledModel::outputs() const {
Expand Down
70 changes: 6 additions & 64 deletions src/plugins/auto_batch/src/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@
#include "transformations/common_optimizations/dimension_tracking.hpp"
#include "transformations/init_node_info.hpp"
#include "transformations/utils/utils.hpp"
OPENVINO_SUPPRESS_DEPRECATED_START
#include "ie_layouts.h"
OPENVINO_SUPPRESS_DEPRECATED_END

namespace ov {
namespace autobatch_plugin {

OPENVINO_SUPPRESS_DEPRECATED_START
std::vector<std::string> supported_configKeys = {CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG),
ov::device::priorities.name(),
ov::auto_batch_timeout.name(),
ov::cache_dir.name()};
OPENVINO_SUPPRESS_DEPRECATED_END
std::vector<std::string> supported_configKeys = {ov::device::priorities.name(), ov::auto_batch_timeout.name()};

inline ov::AnyMap merge_properties(ov::AnyMap config, const ov::AnyMap& user_config) {
for (auto&& kvp : user_config) {
Expand Down Expand Up @@ -69,11 +61,7 @@ DeviceInformation Plugin::parse_meta_device(const std::string& devices_batch_con

ov::SoPtr<ov::IRemoteContext> Plugin::create_context(const ov::AnyMap& remote_properties) const {
auto full_properties = remote_properties;
OPENVINO_SUPPRESS_DEPRECATED_START
auto it = full_properties.find(CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG));
OPENVINO_SUPPRESS_DEPRECATED_END
if (it == full_properties.end())
it = full_properties.find(ov::device::priorities.name());
auto it = full_properties.find(ov::device::priorities.name());
if (it == full_properties.end())
OPENVINO_THROW("Value for ov::device::priorities is not set");

Expand All @@ -84,18 +72,13 @@ ov::SoPtr<ov::IRemoteContext> Plugin::create_context(const ov::AnyMap& remote_pr
}

ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& arguments) const {
OPENVINO_SUPPRESS_DEPRECATED_START
if (supported_configKeys.end() != std::find(supported_configKeys.begin(), supported_configKeys.end(), name)) {
auto it = m_plugin_config.find(name);
if (it == m_plugin_config.end()) {
OPENVINO_THROW("The Value is not set for ", name);
} else {
return {it->second};
}
} else if (name == METRIC_KEY(SUPPORTED_METRICS)) {
return std::vector<std::string>{METRIC_KEY(SUPPORTED_METRICS),
ov::device::full_name.name(),
METRIC_KEY(SUPPORTED_CONFIG_KEYS)};
} else if (name == ov::supported_properties.name()) {
return std::vector<ov::PropertyName>{
ov::PropertyName{ov::supported_properties.name(), ov::PropertyMutability::RO},
Expand All @@ -104,12 +87,9 @@ ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& argument
return decltype(ov::internal::supported_properties)::value_type{};
} else if (name == ov::device::full_name.name()) {
return get_device_name();
} else if (name == METRIC_KEY(SUPPORTED_CONFIG_KEYS)) {
return supported_configKeys;
} else {
OPENVINO_THROW("Unsupported property: ", name);
}
OPENVINO_SUPPRESS_DEPRECATED_END
}

void Plugin::set_property(const ov::AnyMap& properties) {
Expand All @@ -118,11 +98,9 @@ void Plugin::set_property(const ov::AnyMap& properties) {
const auto& val = c.second;
if (supported_configKeys.end() == std::find(supported_configKeys.begin(), supported_configKeys.end(), name))
OPENVINO_THROW("Unsupported config key: ", name);
OPENVINO_SUPPRESS_DEPRECATED_START
if (name == CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG) || name == ov::device::priorities.name()) {
if (name == ov::device::priorities.name()) {
parse_batch_device(val.as<std::string>());
}
OPENVINO_SUPPRESS_DEPRECATED_END
m_plugin_config[name] = val;
}
}
Expand Down Expand Up @@ -150,14 +128,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<

// merge configs from func properties and m_plugin_config
auto full_properties = merge_properties(m_plugin_config, properties);
OPENVINO_SUPPRESS_DEPRECATED_START
auto device_batch = full_properties.find(CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG));
if (device_batch == full_properties.end())
device_batch = full_properties.find(ov::device::priorities.name());
auto device_batch = full_properties.find(ov::device::priorities.name());
if (device_batch == full_properties.end()) {
OPENVINO_THROW("ov::device::priorities key for AUTO NATCH is not set for BATCH device");
}
OPENVINO_SUPPRESS_DEPRECATED_END
auto meta_device = parse_meta_device(device_batch->second.as<std::string>(), properties);

const auto& device_name = meta_device.device_name;
Expand Down Expand Up @@ -302,29 +276,6 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
}

reshaped->reshape(partial_shapes);

OPENVINO_SUPPRESS_DEPRECATED_START
for (auto&& input : reshaped->inputs()) {
auto& rt_info = input.get_rt_info();
auto it = rt_info.find("ie_legacy_td");
if (it != rt_info.end()) {
auto& td = it->second.as<InferenceEngine::TensorDesc>();
rt_info["ie_legacy_td"] =
InferenceEngine::TensorDesc(td.getPrecision(), input.get_shape(), td.getLayout());
}
}
for (auto&& result : reshaped->get_results()) {
auto output = result->input_value(0);
auto& rt_info = output.get_rt_info();
auto it = rt_info.find("ie_legacy_td");
if (it != rt_info.end()) {
auto& td = it->second.as<InferenceEngine::TensorDesc>();
rt_info["ie_legacy_td"] =
InferenceEngine::TensorDesc(td.getPrecision(), output.get_shape(), td.getLayout());
}
}
OPENVINO_SUPPRESS_DEPRECATED_END

compiled_model_with_batch = context
? core->compile_model(reshaped, context, device_config_no_auto_batch)
: core->compile_model(reshaped, device_name, device_config_no_auto_batch);
Expand All @@ -335,15 +286,12 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<

ov::SoPtr<ov::IRemoteContext> device_context;
if (!context) {
OPENVINO_SUPPRESS_DEPRECATED_START
try {
device_context = compiled_model_without_batch->get_context();
if (!device_context._so)
device_context._so = compiled_model_without_batch._so;
} catch (const ov::NotImplemented&) {
} catch (const InferenceEngine::NotImplemented&) {
}
OPENVINO_SUPPRESS_DEPRECATED_END
} else {
device_context = context;
}
Expand All @@ -365,24 +313,18 @@ ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>&
OPENVINO_ASSERT(get_core(), "Core is missing!");
auto cfg = properties;
for (const auto& c : cfg) {
OPENVINO_SUPPRESS_DEPRECATED_START
if (c.first == CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG) || c.first == ov::device::priorities.name()) {
if (c.first == ov::device::priorities.name()) {
auto val = c.second;
cfg.erase(c.first);
auto metaDevice = parse_meta_device(val.as<std::string>(), cfg);
return get_core()->query_model(model, metaDevice.device_name, cfg);
}
OPENVINO_SUPPRESS_DEPRECATED_END
}
OPENVINO_THROW("Value for ov::device::priorities for AUTO BATCH PLUGIN is not set");
}

ov::SoPtr<ov::IRemoteContext> Plugin::get_default_context(const ov::AnyMap& remote_properties) const {
OPENVINO_SUPPRESS_DEPRECATED_START
auto it = remote_properties.find(CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG));
OPENVINO_SUPPRESS_DEPRECATED_END
if (it == remote_properties.end())
it = remote_properties.find(ov::device::priorities.name());
auto it = remote_properties.find(ov::device::priorities.name());
if (it == remote_properties.end())
OPENVINO_THROW("Value for ov::device::priorities is not set");

Expand Down
1 change: 0 additions & 1 deletion src/plugins/auto_batch/src/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <map>

#include "ie/ie_plugin_config.hpp"
#include "openvino/runtime/iplugin.hpp"
#include "openvino/runtime/properties.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ TEST_P(SetPropertyTest, SetPropertyTestCase) {
const std::vector<set_property_params> plugin_set_property_params_test = {
set_property_params{{{ov::auto_batch_timeout(static_cast<uint32_t>(200))}}, false},
set_property_params{{{ov::device::priorities("CPU(4)")}}, false},
set_property_params{{{"CACHE_DIR", "./xyz"}}, false},
set_property_params{{{ov::auto_batch_timeout(static_cast<uint32_t>(200))}, {ov::device::priorities("CPU(4)")}}, false},
set_property_params{{{ov::auto_batch_timeout(static_cast<uint32_t>(200))}, {ov::device::priorities("CPU(4)")}, {"CACHE_DIR", "./xyz"}},
false},
set_property_params{{{"XYZ", "200"}}, true},
set_property_params{{{"XYZ", "200"}, {ov::device::priorities("CPU(4)")}, {"CACHE_DIR", "./xyz"}}, true},
set_property_params{{{"XYZ", "200"}, {ov::device::priorities("CPU(4)")}}, true},
};

INSTANTIATE_TEST_SUITE_P(smoke_AutoBatch_BehaviorTests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ auto configs = []() {
auto autoBatchConfigs = []() {
return std::vector<ov::AnyMap>{
// explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU)
{{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"},
{{ov::device::priorities.name(), std::string(ov::test::utils::DEVICE_GPU) + "(4)"},
// no timeout to avoid increasing the test time
{CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}};
ov::auto_batch_timeout(0)}};
};

INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVCompiledModelBaseTest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ auto configs = []() {
auto AutoBatchConfigs = []() {
return std::vector<ov::AnyMap>{
// explicit batch size 4 to avoid fallback to no auto-batching (i.e. plain GPU)
{{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_GPU) + "(4)"},
{{ov::device::priorities.name(), std::string(ov::test::utils::DEVICE_GPU) + "(4)"},
// no timeout to avoid increasing the test time
{CONFIG_KEY(AUTO_BATCH_TIMEOUT), "0 "}}};
ov::auto_batch_timeout(0)}};
};

INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestIOTensorTest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ const std::vector<ov::AnyMap> multi_properties = {
};

const std::vector<ov::AnyMap> auto_batch_properties = {
{{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_TEMPLATE) + "(4)"}},
{{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_TEMPLATE) + "(4)"},
{CONFIG_KEY(AUTO_BATCH_TIMEOUT), "1"}},
{{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), std::string(ov::test::utils::DEVICE_TEMPLATE) + "(4)"},
{{ov::device::priorities.name(), std::string(ov::test::utils::DEVICE_TEMPLATE) + "(4)"}},
{{ov::device::priorities.name(), std::string(ov::test::utils::DEVICE_TEMPLATE) + "(4)"},
{ov::auto_batch_timeout(1)}},
{{ov::device::priorities.name(), std::string(ov::test::utils::DEVICE_TEMPLATE) + "(4)"},
{ov::auto_batch_timeout(10)}},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ const std::vector<ov::AnyMap> multi_properties = {
};

const std::vector<ov::AnyMap> auto_batch_properties = {
{{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), ov::test::utils::DEVICE_TEMPLATE}},
{{CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG), ov::test::utils::DEVICE_TEMPLATE}, {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "1"}},
{{ov::device::priorities.name(), ov::test::utils::DEVICE_TEMPLATE}},
{{ov::device::priorities.name(), ov::test::utils::DEVICE_TEMPLATE}, {CONFIG_KEY(AUTO_BATCH_TIMEOUT), "1"}},
};

INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ TEST_P(OVInferRequestIOTensorTest, canInferWithGetOut) {
}

TEST_P(OVInferRequestIOTensorTest, InferStaticNetworkSetChangedInputTensorThrow) {
const ov::Shape shape1 = {1, 2, 32, 32};
const ov::Shape shape2 = {1, 2, 40, 40};
const ov::Shape shape1 = {1, 2, 40, 40};
const ov::Shape shape2 = {1, 2, 32, 32};
std::map<std::string, ov::PartialShape> shapes;
shapes[function->inputs().back().get_any_name()] = shape1;
OV_ASSERT_NO_THROW(function->reshape(shapes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ void OVPropertiesTestsWithCompileModelProps::SetUp() {

if (target_device == std::string(ov::test::utils::DEVICE_MULTI) ||
target_device == std::string(ov::test::utils::DEVICE_AUTO) ||
target_device == std::string(ov::test::utils::DEVICE_HETERO)) {
compileModelProperties = { ov::device::priorities(hw_device) };
} else if (target_device == std::string(ov::test::utils::DEVICE_BATCH)) {
compileModelProperties = {{ CONFIG_KEY(AUTO_BATCH_DEVICE_CONFIG) , hw_device}};
target_device == std::string(ov::test::utils::DEVICE_HETERO) ||
target_device == std::string(ov::test::utils::DEVICE_BATCH)) {
compileModelProperties = {ov::device::priorities(hw_device)};
}

model = ov::test::utils::make_split_concat();
Expand Down
Loading