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 commit243eeccff3
. * Revert "Translate all operation attributes values to lower case." This reverts commitd4c24175b3
. * 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:
parent
37f6c0caf9
commit
55dd8b0a2d
@ -220,7 +220,9 @@ std::string get_opset_name(
|
||||
// discrepancies discoverd, translations needs to be added here.
|
||||
std::string translate_type_name(std::string name) {
|
||||
const std::unordered_map<std::string, std::string> translator = {
|
||||
{"Constant", "Const"}};
|
||||
{"Constant", "Const"},
|
||||
{"Relu", "ReLU"},
|
||||
{"Softmax", "SoftMax"}};
|
||||
if (translator.count(name) > 0) {
|
||||
name = translator.at(name);
|
||||
}
|
||||
@ -342,6 +344,12 @@ void ngfunction_2_irv10(
|
||||
layer_type_attribute.set_value(
|
||||
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)
|
||||
if (auto constant = dynamic_cast<ngraph::op::Constant*>(node)) {
|
||||
ConstantAtributes attr = dump_constant_data(bin, *constant);
|
||||
|
@ -10,7 +10,7 @@
|
||||
std::vector<std::string> disabledTestPatterns() {
|
||||
return {
|
||||
// TODO: Issue 26264
|
||||
R"(.*(MaxPool|AvgPool).*S\(1\.2\).*Rounding=CEIL.*)",
|
||||
R"(.*(MaxPool|AvgPool).*S\(1\.2\).*Rounding=ceil.*)",
|
||||
// TODO: Issue 31841
|
||||
R"(.*(QuantGroupConvBackpropData3D).*)",
|
||||
// TODO: Issue 31843
|
||||
|
@ -41,16 +41,12 @@ namespace ngraph
|
||||
///
|
||||
/// \param element_type The element type 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,
|
||||
const bool cacheable = false);
|
||||
Parameter(const ngraph::element::Type& element_type, const PartialShape& pshape);
|
||||
|
||||
bool visit_attributes(AttributeVisitor& visitor) override;
|
||||
|
||||
void validate_and_infer_types() override;
|
||||
|
||||
bool get_cacheable() const { return m_cacheable; }
|
||||
virtual std::shared_ptr<Node>
|
||||
clone_with_new_inputs(const OutputVector& new_args) const override;
|
||||
|
||||
@ -70,7 +66,6 @@ namespace ngraph
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_cacheable;
|
||||
PartialShape m_partial_shape;
|
||||
element::Type m_element_type;
|
||||
bool m_is_relevant_to_shapes;
|
||||
|
@ -24,11 +24,8 @@ using namespace ngraph;
|
||||
|
||||
constexpr NodeTypeInfo op::Parameter::type_info;
|
||||
|
||||
op::Parameter::Parameter(const element::Type& element_type,
|
||||
const PartialShape& pshape,
|
||||
const bool cacheable)
|
||||
: m_cacheable(cacheable)
|
||||
, m_partial_shape(pshape)
|
||||
op::Parameter::Parameter(const element::Type& element_type, const PartialShape& pshape)
|
||||
: m_partial_shape(pshape)
|
||||
, m_element_type(element_type)
|
||||
, 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)
|
||||
{
|
||||
visitor.on_attribute("cacheable", m_cacheable);
|
||||
visitor.on_attribute("shape", m_partial_shape);
|
||||
visitor.on_attribute("element_type", m_element_type);
|
||||
return true;
|
||||
|
@ -48,10 +48,10 @@ namespace ngraph
|
||||
NGRAPH_API EnumNames<op::PadType>& EnumNames<op::PadType>::get()
|
||||
{
|
||||
static auto enum_names = EnumNames<op::PadType>("op::PadType",
|
||||
{{"EXPLICIT", op::PadType::EXPLICIT},
|
||||
{"SAME_LOWER", op::PadType::SAME_LOWER},
|
||||
{"SAME_UPPER", op::PadType::SAME_UPPER},
|
||||
{"VALID", op::PadType::VALID}});
|
||||
{{"explicit", op::PadType::EXPLICIT},
|
||||
{"same_lower", op::PadType::SAME_LOWER},
|
||||
{"same_upper", op::PadType::SAME_UPPER},
|
||||
{"valid", op::PadType::VALID}});
|
||||
return enum_names;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ namespace ngraph
|
||||
{
|
||||
static auto enum_names = EnumNames<op::RoundingType>(
|
||||
"op::RoundingType",
|
||||
{{"FLOOR", op::RoundingType::FLOOR}, {"CEIL", op::RoundingType::CEIL}});
|
||||
{{"floor", op::RoundingType::FLOOR}, {"ceil", op::RoundingType::CEIL}});
|
||||
return enum_names;
|
||||
}
|
||||
|
||||
@ -82,10 +82,10 @@ namespace ngraph
|
||||
{
|
||||
static auto enum_names =
|
||||
EnumNames<op::AutoBroadcastType>("op::AutoBroadcastType",
|
||||
{{"NONE", op::AutoBroadcastType::NONE},
|
||||
{"EXPLICIT", op::AutoBroadcastType::EXPLICIT},
|
||||
{"NUMPY", op::AutoBroadcastType::NUMPY},
|
||||
{"PDPD", op::AutoBroadcastType::PDPD}});
|
||||
{{"none", op::AutoBroadcastType::NONE},
|
||||
{"explicit", op::AutoBroadcastType::EXPLICIT},
|
||||
{"numpy", op::AutoBroadcastType::NUMPY},
|
||||
{"pdpd", op::AutoBroadcastType::PDPD}});
|
||||
return enum_names;
|
||||
}
|
||||
constexpr DiscreteTypeInfo AttributeAdapter<op::AutoBroadcastType>::type_info;
|
||||
|
Loading…
Reference in New Issue
Block a user