Align nGraph serialization to specification & MO behaviour (#2990)

* Align MaxPool op attribute 'rounding_type' to spec.

Attribute name should be in lower case.

* Remove obsolete "cacheable" attribute from Parameter.

* Translate ReLU & SoftMax ops type names from ngraph to IR convention.

* Remove <data> node when op has no attributes.

* Translate all operation attributes values to lower case.

* Revert "Align MaxPool op attribute 'rounding_type' to spec."

This reverts commit 243eeccff3.

* Revert "Translate all operation attributes values to lower case."

This reverts commit d4c24175b3.

* Align MaxPool op attribute 'rounding_type' to spec.

Attribute name should be in lower case.

* Align auto_pad & auto_broadcast operation attributes to spec.

They should be written in lowercase.

* Rename op:PadType 'none' to 'explicit'.
This commit is contained in:
Jozef Daniecki 2020-11-23 04:43:39 +01:00 committed by GitHub
parent 37f6c0caf9
commit 55dd8b0a2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 23 deletions

View File

@ -220,7 +220,9 @@ std::string get_opset_name(
// discrepancies discoverd, translations needs to be added here. // discrepancies discoverd, translations needs to be added here.
std::string translate_type_name(std::string name) { std::string translate_type_name(std::string name) {
const std::unordered_map<std::string, std::string> translator = { const std::unordered_map<std::string, std::string> translator = {
{"Constant", "Const"}}; {"Constant", "Const"},
{"Relu", "ReLU"},
{"Softmax", "SoftMax"}};
if (translator.count(name) > 0) { if (translator.count(name) > 0) {
name = translator.at(name); name = translator.at(name);
} }
@ -342,6 +344,12 @@ void ngfunction_2_irv10(
layer_type_attribute.set_value( layer_type_attribute.set_value(
translate_type_name(node_type_name).c_str()); translate_type_name(node_type_name).c_str());
const auto data_attr_size =
std::distance(data.attributes().begin(), data.attributes().end());
if (data_attr_size == 0) {
layer.remove_child(data);
}
// <layers/data> constant atributes (special case) // <layers/data> constant atributes (special case)
if (auto constant = dynamic_cast<ngraph::op::Constant*>(node)) { if (auto constant = dynamic_cast<ngraph::op::Constant*>(node)) {
ConstantAtributes attr = dump_constant_data(bin, *constant); ConstantAtributes attr = dump_constant_data(bin, *constant);

View File

@ -10,7 +10,7 @@
std::vector<std::string> disabledTestPatterns() { std::vector<std::string> disabledTestPatterns() {
return { return {
// TODO: Issue 26264 // TODO: Issue 26264
R"(.*(MaxPool|AvgPool).*S\(1\.2\).*Rounding=CEIL.*)", R"(.*(MaxPool|AvgPool).*S\(1\.2\).*Rounding=ceil.*)",
// TODO: Issue 31841 // TODO: Issue 31841
R"(.*(QuantGroupConvBackpropData3D).*)", R"(.*(QuantGroupConvBackpropData3D).*)",
// TODO: Issue 31843 // TODO: Issue 31843

View File

@ -41,16 +41,12 @@ namespace ngraph
/// ///
/// \param element_type The element type of the parameter. /// \param element_type The element type of the parameter.
/// \param pshape The partial shape of the parameter. /// \param pshape The partial shape of the parameter.
/// \param cacheable True if the parameter is not expected to be frequently updated. Parameter(const ngraph::element::Type& element_type, const PartialShape& pshape);
Parameter(const ngraph::element::Type& element_type,
const PartialShape& pshape,
const bool cacheable = false);
bool visit_attributes(AttributeVisitor& visitor) override; bool visit_attributes(AttributeVisitor& visitor) override;
void validate_and_infer_types() override; void validate_and_infer_types() override;
bool get_cacheable() const { return m_cacheable; }
virtual std::shared_ptr<Node> virtual std::shared_ptr<Node>
clone_with_new_inputs(const OutputVector& new_args) const override; clone_with_new_inputs(const OutputVector& new_args) const override;
@ -70,7 +66,6 @@ namespace ngraph
} }
protected: protected:
bool m_cacheable;
PartialShape m_partial_shape; PartialShape m_partial_shape;
element::Type m_element_type; element::Type m_element_type;
bool m_is_relevant_to_shapes; bool m_is_relevant_to_shapes;

View File

@ -24,11 +24,8 @@ using namespace ngraph;
constexpr NodeTypeInfo op::Parameter::type_info; constexpr NodeTypeInfo op::Parameter::type_info;
op::Parameter::Parameter(const element::Type& element_type, op::Parameter::Parameter(const element::Type& element_type, const PartialShape& pshape)
const PartialShape& pshape, : m_partial_shape(pshape)
const bool cacheable)
: m_cacheable(cacheable)
, m_partial_shape(pshape)
, m_element_type(element_type) , m_element_type(element_type)
, m_is_relevant_to_shapes(false) , m_is_relevant_to_shapes(false)
{ {
@ -37,7 +34,6 @@ op::Parameter::Parameter(const element::Type& element_type,
bool op::Parameter::visit_attributes(AttributeVisitor& visitor) bool op::Parameter::visit_attributes(AttributeVisitor& visitor)
{ {
visitor.on_attribute("cacheable", m_cacheable);
visitor.on_attribute("shape", m_partial_shape); visitor.on_attribute("shape", m_partial_shape);
visitor.on_attribute("element_type", m_element_type); visitor.on_attribute("element_type", m_element_type);
return true; return true;

View File

@ -48,10 +48,10 @@ namespace ngraph
NGRAPH_API EnumNames<op::PadType>& EnumNames<op::PadType>::get() NGRAPH_API EnumNames<op::PadType>& EnumNames<op::PadType>::get()
{ {
static auto enum_names = EnumNames<op::PadType>("op::PadType", static auto enum_names = EnumNames<op::PadType>("op::PadType",
{{"EXPLICIT", op::PadType::EXPLICIT}, {{"explicit", op::PadType::EXPLICIT},
{"SAME_LOWER", op::PadType::SAME_LOWER}, {"same_lower", op::PadType::SAME_LOWER},
{"SAME_UPPER", op::PadType::SAME_UPPER}, {"same_upper", op::PadType::SAME_UPPER},
{"VALID", op::PadType::VALID}}); {"valid", op::PadType::VALID}});
return enum_names; return enum_names;
} }
@ -66,7 +66,7 @@ namespace ngraph
{ {
static auto enum_names = EnumNames<op::RoundingType>( static auto enum_names = EnumNames<op::RoundingType>(
"op::RoundingType", "op::RoundingType",
{{"FLOOR", op::RoundingType::FLOOR}, {"CEIL", op::RoundingType::CEIL}}); {{"floor", op::RoundingType::FLOOR}, {"ceil", op::RoundingType::CEIL}});
return enum_names; return enum_names;
} }
@ -82,10 +82,10 @@ namespace ngraph
{ {
static auto enum_names = static auto enum_names =
EnumNames<op::AutoBroadcastType>("op::AutoBroadcastType", EnumNames<op::AutoBroadcastType>("op::AutoBroadcastType",
{{"NONE", op::AutoBroadcastType::NONE}, {{"none", op::AutoBroadcastType::NONE},
{"EXPLICIT", op::AutoBroadcastType::EXPLICIT}, {"explicit", op::AutoBroadcastType::EXPLICIT},
{"NUMPY", op::AutoBroadcastType::NUMPY}, {"numpy", op::AutoBroadcastType::NUMPY},
{"PDPD", op::AutoBroadcastType::PDPD}}); {"pdpd", op::AutoBroadcastType::PDPD}});
return enum_names; return enum_names;
} }
constexpr DiscreteTypeInfo AttributeAdapter<op::AutoBroadcastType>::type_info; constexpr DiscreteTypeInfo AttributeAdapter<op::AutoBroadcastType>::type_info;