Skip to content

Commit

Permalink
Deprecate RuntimeAttribute versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
t-jankowski committed Sep 27, 2024
1 parent 44866a7 commit 5a2be41
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ class TRANSFORMATIONS_API Attributes {
public:
Attributes();

Any create_by_type_info(const ov::DiscreteTypeInfo& type_info_name);
Any create_by_type_info(const ov::DiscreteTypeInfo& type_info_name) const;

private:
template <class T>
void register_factory() {
m_factory_registry.emplace(T::get_type_info_static(), []() -> Any {
// TODO add versioning deprecation notice - newer versions are not allowed
assert(T::get_type_info_static().get_version() == "0");
return T{};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ov::pass::Attributes::Attributes() {
register_factory<PreprocessingAttribute>();
}

ov::Any ov::pass::Attributes::create_by_type_info(const ov::DiscreteTypeInfo& type_info) {
ov::Any ov::pass::Attributes::create_by_type_info(const ov::DiscreteTypeInfo& type_info) const {
auto it_type = m_factory_registry.find(type_info);
if (it_type != m_factory_registry.end()) {
return it_type->second();
Expand Down
5 changes: 4 additions & 1 deletion src/core/src/pass/serialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,10 @@ void ngfunction_2_ir(pugi::xml_node& netXml,
auto& rt_attribute = item.second.as<ov::RuntimeAttribute>();
const auto& type_info = rt_attribute.get_type_info();
attribute_node.append_attribute("name").set_value(type_info.name);
attribute_node.append_attribute("version").set_value(type_info.get_version().c_str());
// TODO add deprecation notice with explanation (RuntimeAttribute should not be versioned, 0 remains
// as legacy for backword compatibity)
assert(type_info.get_version() == "0");
attribute_node.append_attribute("version").set_value("0");
rt_info::RTInfoSerializer serializer(attribute_node);
if (!rt_attribute.visit_attributes(serializer)) {
rt_node.remove_child(attribute_node);
Expand Down
10 changes: 3 additions & 7 deletions src/frontends/ir/src/ir_deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,20 +957,16 @@ std::shared_ptr<ov::Node> ov::XmlDeserializer::create_node(const std::vector<ov:
if (!rt_attrs)
return;
for (const auto& item : rt_attrs) {
std::string attribute_name, attribute_version;
std::string attribute_name;
// For view:
// <attribute name="old_api_map_order" version="0" value="0,3,1,2"/>
if (!getStrAttribute(item, "name", attribute_name)) {
std::stringstream ss;
item.print(ss);
OPENVINO_THROW("rt_info attribute has no \"name\" field: ", ss.str());
}
if (!getStrAttribute(item, "version", attribute_version)) {
std::stringstream ss;
item.print(ss);
OPENVINO_THROW("rt_info attribute: ", attribute_name, " has no \"version\" field: ", ss.str());
}
const auto& type_info = ov::DiscreteTypeInfo(attribute_name.c_str(), attribute_version.c_str());
// TODO add notice why fixed to "0"
const auto& type_info = ov::DiscreteTypeInfo(attribute_name.c_str(), "0");
auto attr = attrs_factory.create_by_type_info(type_info);
if (!attr.empty()) {
if (attr.is<ov::RuntimeAttribute>()) {
Expand Down
3 changes: 2 additions & 1 deletion tools/mo/openvino/tools/mo/utils/ir_engine/ir_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ def __read_old_api_map_element_type(attr, layer_type):
@staticmethod
def __read_rt_info_common(attr):
attr_name = attr.attrib['name']
version = int(attr.attrib['version'])
# TODO add notice why fixed to 0
version = 0
rt_info = OrderedDict()
for key in attr.attrib:
if key not in ('name', 'version'):
Expand Down

0 comments on commit 5a2be41

Please sign in to comment.