Skip to content

Commit

Permalink
Fixes and visit_attributes method impl
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Paramuzov <[email protected]>
  • Loading branch information
vladimir-paramuzov committed Dec 24, 2024
1 parent 0e93db3 commit 456fd32
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/inference/dev_api/openvino/runtime/plugin_config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class OPENVINO_RUNTIME_API PluginConfig {

void finalize(std::shared_ptr<IRemoteContext> context, const ov::RTMap& rt_info);

bool visit_attributes(ov::AttributeVisitor& visitor) const;
bool visit_attributes(ov::AttributeVisitor& visitor);

protected:
virtual void apply_rt_info(std::shared_ptr<IRemoteContext> context, const ov::RTMap& rt_info) {}
Expand Down
38 changes: 20 additions & 18 deletions src/inference/src/dev/plugin_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ov::Any PluginConfig::get_property(const std::string& name, OptionVisibility all
}

auto option = get_option_ptr(name);
if ((allowed_visibility & option->get_visibility()) == option->get_visibility()) {
if ((allowed_visibility & option->get_visibility()) != option->get_visibility()) {
OPENVINO_THROW("Couldn't get unknown property: ", name);
}

Expand All @@ -70,7 +70,7 @@ void PluginConfig::set_property(const ov::AnyMap& config, OptionVisibility allow
auto& val = kv.second;

auto option = get_option_ptr(name);
if ((allowed_visibility & option->get_visibility()) == option->get_visibility()) {
if ((allowed_visibility & option->get_visibility()) != option->get_visibility()) {
if (throw_on_error)
OPENVINO_THROW("Couldn't set unknown property: ", name);
else
Expand Down Expand Up @@ -111,14 +111,16 @@ void PluginConfig::finalize(std::shared_ptr<IRemoteContext> context, const ov::R
m_is_finalized = true;
}

bool PluginConfig::visit_attributes(ov::AttributeVisitor& visitor) const {
// for (const auto& prop : m_user_properties) {
// visitor.on_attribute(prop.first + "__user", prop.second.as<std::string>());
// }
// for (const auto& prop : m_options_map) {
// visitor.on_attribute(prop.first + "__internal", prop.second->get_any().as<std::string>());
// }
// visitor.on_attribute("is_finalized", m_is_finalized);
bool PluginConfig::visit_attributes(ov::AttributeVisitor& visitor) {
for (const auto& prop : m_user_properties) {
auto val = prop.second.as<std::string>();
visitor.on_attribute(prop.first + "__user", val);
}
for (const auto& prop : m_options_map) {
auto val = prop.second->get_any().as<std::string>();
visitor.on_attribute(prop.first + "__internal", val);
}
visitor.on_attribute("is_finalized", m_is_finalized);

return true;
}
Expand Down Expand Up @@ -212,20 +214,20 @@ void PluginConfig::cleanup_unsupported(ov::AnyMap& config) const {
}

std::string PluginConfig::to_string() const {
std::stringstream s;
std::stringstream ss;

s << "-----------------------------------------\n";
s << "PROPERTIES:\n";
ss << "-----------------------------------------\n";
ss << "PROPERTIES:\n";

for (const auto& option : m_options_map) {
s << "\t" << option.first << ": " << option.second->get_any().as<std::string>() << std::endl;
ss << "\t" << option.first << ": " << option.second->get_any().as<std::string>() << std::endl;
}
s << "USER PROPERTIES:\n";
ss << "USER PROPERTIES:\n";
for (const auto& user_prop : m_user_properties) {
s << "\t" << user_prop.first << ": " << user_prop.second.as<std::string>() << std::endl;
ss << "\t" << user_prop.first << ": " << user_prop.second.as<std::string>() << std::endl;
}

return s.str();
return ss.str();
}

void PluginConfig::print_help() const {
Expand Down Expand Up @@ -276,7 +278,7 @@ void PluginConfig::print_help() const {

const size_t max_name_width = static_cast<int>(std::get<0>(*max_name_length_item).size() + std::get<1>(*max_name_length_item).size());
const size_t terminal_width = get_terminal_width();
ss << std::left << std::setw(max_name_width) << ("Option name") << " | " << " Description " << "\n";
ss << std::left << std::setw(max_name_width) << "Option name" << " | " << " Description " << "\n";
ss << std::left << std::setw(terminal_width) << std::setfill('-') << "" << "\n";
for (auto& kv : options_desc) {
ss << format_text(std::get<0>(kv), std::get<1>(kv), std::get<2>(kv), max_name_width, terminal_width) << "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, partial_build_program, false, "
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, allow_new_shape_infer, false, "Switch between new and old shape inference flow. Shall be removed soon")
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, buffers_preallocation_ratio, 1.1f, "Threshold for preallocation feature in case when it uses ratio policy")
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, use_onednn, false, "Enable/Disable onednn for usage for particular model/platform")
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, max_kernels_per_batch, 8, "Controls how many kernels we combine into batch for more efficient ocl compilation")

OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, verbose, 0, "Enable logging for debugging purposes. The higher value the more verbose output. 0 - Disabled, 4 - Maximum verbosity")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, log_to_file, "", "Save verbose log to specified file")
Expand All @@ -58,7 +59,6 @@ OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, dump_tensors, "", "Save intermediate in/ou
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, dump_memory_pool, "", "Save csv file with memory pool info to specified folder")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, dump_iterations, "", "Space separated list of iterations where other dump options should be enabled")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, host_time_profiling, false, "Measre and print host time spent from the beginning of the infer until all host work is done and plugin is ready to block thread on the final clFinish() call")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, max_kernels_per_batch, 8, "Controls how many kernels we combine into batch for more efficient ocl compilation")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, impls_cache_capacity, 300, "Controls capacity of LRU implementations cache that is created for each program object for dynamic models")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, disable_async_compilation, false, "Disable feature that allows to asyncrhonously prepare static-shaped implementations for the primitives with shape-agnostic kernels selected during compilation")
OV_CONFIG_DEBUG_OPTION(ov::intel_gpu, disable_runtime_buffer_fusing, false, "Disable runtime inplace optimizations for operations like concat and crop")
Expand Down
33 changes: 32 additions & 1 deletion src/plugins/intel_gpu/src/plugin/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "intel_gpu/graph/serialization/helpers.hpp"
#include "intel_gpu/runtime/layout.hpp"
#include "openvino/runtime/plugin_config.hpp"
#include "openvino/runtime/threading/executor_manager.hpp"
#include "openvino/runtime/exec_model_info.hpp"
#include "openvino/pass/serialize.hpp"
Expand Down Expand Up @@ -34,6 +36,34 @@

namespace ov {
namespace intel_gpu {
namespace {


class OstreamAttributeVisitor : public ov::AttributeVisitor {
cldnn::BinaryOutputBuffer& os;

template<typename T>
void append_attribute(const std::string& name, const T& value) {
os << name;
os << value;
}
public:
OstreamAttributeVisitor(cldnn::BinaryOutputBuffer& os) : os(os) {}

void on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) override {
OPENVINO_THROW("Attribute ", name, " can't be processed\n");
}

void on_adapter(const std::string& name, ov::ValueAccessor<bool>& adapter) override {
append_attribute(name, adapter.get());
}

void on_adapter(const std::string& name, ov::ValueAccessor<std::string>& adapter) override {
append_attribute(name, adapter.get());
}
};

} // namespace

Graph::Graph(std::shared_ptr<ov::Model> model, const RemoteContextImpl::Ptr& context, const ExecutionConfig& config, uint16_t stream_id)
: m_context(context)
Expand Down Expand Up @@ -513,7 +543,8 @@ void Graph::export_model(cldnn::BinaryOutputBuffer &ob) {
ob << perf_item.second.second.parentPrimitive;
}
}
// ob << m_config;
OstreamAttributeVisitor visitor(ob);
m_config.visit_attributes(visitor);

ob.set_stream(m_network->get_stream_ptr().get());
m_network->get_program()->save(ob);
Expand Down

0 comments on commit 456fd32

Please sign in to comment.