Skip to content

Commit

Permalink
[ONNX] Refactoring tests on API 2.0 (openvinotoolkit#21748)
Browse files Browse the repository at this point in the history
* Test in onnx_import_dyn_shapes.in.cpp moved to API 2.0

* Test in onnx_import_exception.cpp moved to API 2.0

* Tests in onnx_import_org_openvino.in.cpp moved to API 2.0

* Tests in onnx_import_org_pytorch.in.cpp moved to API 2.0

* Fixed code style
  • Loading branch information
gkrivor authored Dec 19, 2023
1 parent e6ab01c commit 2779df5
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 499 deletions.
20 changes: 11 additions & 9 deletions src/frontends/onnx/frontend/src/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

#include "openvino/core/deprecated.hpp"

namespace ngraph {
namespace onnx_import {
namespace error {
namespace detail {
OPENVINO_SUPPRESS_DEPRECATED_START
std::string get_error_msg_prefix(const Node& node) {

namespace ov {
namespace frontend {
namespace onnx_error {
namespace detail {
std::string get_error_msg_prefix(const ngraph::onnx_import::Node& node) {
std::stringstream ss;
ss << "While validating ONNX node '" << node << "'";
return ss.str();
Expand All @@ -23,12 +24,13 @@ std::string get_error_msg_prefix(const Node& node) {
void OnnxNodeValidationFailure::create(const char* file,
int line,
const char* check_string,
const Node& node,
const ngraph::onnx_import::Node& node,
const std::string& explanation) {
throw OnnxNodeValidationFailure(
make_what(file, line, check_string, detail::get_error_msg_prefix(node), explanation));
}
} // namespace onnx_error
} // namespace frontend
} // namespace ov

OPENVINO_SUPPRESS_DEPRECATED_END
} // namespace error
} // namespace onnx_import
} // namespace ngraph
37 changes: 21 additions & 16 deletions src/frontends/onnx/frontend/src/exceptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@

#include <string>

#include "ngraph/check.hpp"
#include "ngraph/except.hpp"
#include "onnx_import/core/node.hpp"
#include "openvino/core/deprecated.hpp"
#include "openvino/core/except.hpp"
#include "utils/tensor_external_data.hpp"

namespace ngraph {
namespace onnx_import {
namespace error {
namespace ov {
namespace frontend {
namespace onnx_error {

namespace detail {
OPENVINO_SUPPRESS_DEPRECATED_START
std::string get_error_msg_prefix(const Node& node);
std::string get_error_msg_prefix(const ngraph::onnx_import::Node& node);
OPENVINO_SUPPRESS_DEPRECATED_END
} // namespace detail

Expand All @@ -27,7 +26,7 @@ class OnnxNodeValidationFailure : public ov::AssertFailure {
OPENVINO_SUPPRESS_DEPRECATED_START [[noreturn]] static void create(const char* file,
int line,
const char* check_string,
const Node& node,
const ngraph::onnx_import::Node& node,
const std::string& explanation);
OPENVINO_SUPPRESS_DEPRECATED_END

Expand All @@ -36,18 +35,24 @@ class OnnxNodeValidationFailure : public ov::AssertFailure {
};

OPENVINO_SUPPRESS_DEPRECATED_START
struct invalid_external_data : ngraph_error {
invalid_external_data(const onnx_import::detail::TensorExternalData& external_data)
: ngraph_error{std::string{"invalid external data: "} + external_data.to_string()} {}
invalid_external_data(const std::string& what_arg) : ngraph_error{what_arg} {}
struct invalid_external_data : ov::Exception {
invalid_external_data(const ngraph::onnx_import::detail::TensorExternalData& external_data)
: ov::Exception{std::string{"invalid external data: "} + external_data.to_string()} {}
invalid_external_data(const std::string& what_arg) : ov::Exception{what_arg} {}
};
OPENVINO_SUPPRESS_DEPRECATED_END

} // namespace error
} // namespace onnx_error
} // namespace frontend
} // namespace ov

} // namespace onnx_import

} // namespace ngraph
namespace ngraph {
namespace onnx_import {
namespace error {
using namespace ov::frontend::onnx_error;
} // namespace error
} // namespace onnx_import
} // namespace ngraph

#define CHECK_VALID_NODE(node_, cond_, ...) \
OPENVINO_ASSERT_HELPER(::ngraph::onnx_import::error::OnnxNodeValidationFailure, (node_), (cond_), ##__VA_ARGS__)
OPENVINO_ASSERT_HELPER(ov::frontend::onnx_error::OnnxNodeValidationFailure, (node_), (cond_), ##__VA_ARGS__)
Loading

0 comments on commit 2779df5

Please sign in to comment.