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

Adding ( [ONNX] Extend ONNX Frontend with Function Mish-18 ) #22833

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
25 changes: 25 additions & 0 deletions src/frontends/onnx/frontend/src/op/mish.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "op/mish.hpp"

#include "openvino/op/mish.hpp"

using namespace ov::op;

namespace ov {
namespace frontend {
namespace onnx {
namespace op {
namespace set_1 {
ov::OutputVector mish(const ov::frontend::onnx::Node& node) {
const auto data = node.get_ov_inputs().at(0);

return std::make_shared<v4::Mish>(data)->outputs();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit of usage ->outputs() here?
If no specific reason, I would suggest to align the return statement with the rest of the onnx fe ops:

Suggested change
return std::make_shared<v4::Mish>(data)->outputs();
return {std::make_shared<v4::Mish>(data)};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No there is no specific reason for that, I have commited all the changes that you have suggested in the new commit.Thank you for your guidance and support .

}
} // namespace set_1
} // namespace op
} // namespace onnx
} // namespace frontend
} // namespace ov
23 changes: 23 additions & 0 deletions src/frontends/onnx/frontend/src/op/mish.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (C) 2018-2024 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include "core/node.hpp"

namespace ov {
namespace frontend {
namespace onnx {
namespace op {
namespace set_1 {
ov::OutputVector mish(const ov::frontend::onnx::Node& node);
} // namespace set_1

} // namespace op

} // namespace onnx

} // namespace frontend

} // namespace ov
2 changes: 2 additions & 0 deletions src/frontends/onnx/frontend/src/ops_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
#include "op/min.hpp"
#include "op/mod.hpp"
#include "op/mul.hpp"
#include "op/mish.hpp"
#include "op/neg.hpp"
#include "op/nms_rotated.hpp"
#include "op/non_max_suppression.hpp"
Expand Down Expand Up @@ -455,6 +456,7 @@ OperatorsBridge::OperatorsBridge() {
REGISTER_OPERATOR("Mod", 1, mod);
REGISTER_OPERATOR("Mul", 1, mul);
REGISTER_OPERATOR("Mul", 7, mul);
REGISTER_OPERATOR("Mish", 1, mish);
REGISTER_OPERATOR("Neg", 1, neg);
REGISTER_OPERATOR("NonMaxSuppression", 1, non_max_suppression);
REGISTER_OPERATOR("NonZero", 1, non_zero);
Expand Down
1 change: 0 additions & 1 deletion src/frontends/onnx/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True):
xfail_issue_99955 = xfail_test(reason="GroupNorm is not supported")
xfail_issue_99957 = xfail_test(reason="LayerNorm - RuntimeError: While validating node '<Node(Reshape): Mean>'")
xfail_issue_99958 = xfail_test(reason="LogSoftmax - Results mismatch")
xfail_issue_99959 = xfail_test(reason="Mish function is not supported")
xfail_issue_99960 = xfail_test(reason="MVN - Results mismatch")
xfail_issue_99961 = xfail_test(reason="Optional has/get element operators are not supported)'")
xfail_issue_99962 = pytest.mark.skip(reason="ReduceL1/L2 - Unrecognized attribute: axes for operator ReduceL1/L2")
Expand Down
50 changes: 50 additions & 0 deletions src/frontends/onnx/tests/models/mish.prototxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
ir_version: 7
graph {
node {
input: "x"
output: "y"
op_type: "Mish"
}
name: "test_mish"
input {
name: "x"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 2
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
version: 1
}
15 changes: 15 additions & 0 deletions src/frontends/onnx/tests/onnx_import.in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6245,3 +6245,18 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_gelu_float_tanh) {
test_case.add_input<float>(Shape{2}, {-0.5f, 24.33f});
test_case.add_expected_output<float>(Shape{2}, {-0.15428598f, 24.f});
}

OPENVINO_TEST(${BACKEND_NAME}, onnx_model_mish_activation) {
auto model = convert_model("mish.onnx");

auto test_case = ov::test::TestCase(model, s_device);
test_case.add_input<float>({ 1.8079f, -0.2892f, 2.0915f, 12.5101f, -1.8837f, 0.2586f, 2.9528f, 0.001f,
6.0296f, -1.0745f, -0.2703f, 1.319f, -3.3607f, 0.1434f, -8.4590f, 0.0f,
2.7608f, 0.3126f, 0.3f, 3.0f, 7.6919f, 0.5859f, -11.992f, -37.8f });

test_case.add_expected_output<float>({1.737521f, -0.146684f, 2.041557f, 12.5101f, -0.264820f, 0.176079f, 2.938304f, 0.0006f,
6.029531f, -0.306873f, -0.138725f, 1.206575f, -0.114629f, 0.092553f, -0.001792f, 0.0f,
2.741334f, 0.217909f, 0.208001f, 2.986535f, 7.691896f, 0.453058f, -0.000074f, 0.0f });

test_case.run_with_tolerance_as_fp(0.000001f);
}
5 changes: 0 additions & 5 deletions src/frontends/onnx/tests/tests_python/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
xfail_issue_99955,
xfail_issue_99957,
xfail_issue_99958,
xfail_issue_99959,
xfail_issue_99960,
xfail_issue_99961,
xfail_issue_99968,
Expand Down Expand Up @@ -446,10 +445,6 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None
xfail_issue_99958,
"OnnxBackendNodeModelTest.test_logsoftmax_large_number_expanded_ver18_cpu",
),
(
xfail_issue_99959,
"OnnxBackendNodeModelTest.test_mish_cpu",
),
(
xfail_issue_99960,
"OnnxBackendNodeModelTest.test_mvn_expanded_ver18_cpu",
Expand Down
Loading