Skip to content

Commit

Permalink
Fixing codestyle and linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
gkrivor committed Oct 21, 2024
1 parent ec8e6cf commit db5ec58
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
5 changes: 3 additions & 2 deletions src/frontends/onnx/frontend/src/editor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "openvino/op/constant.hpp"
#include "utils/tensor_external_data.hpp"

using ::ONNX_NAMESPACE::ModelProto;

namespace ov {
namespace frontend {
namespace onnx {
Expand Down Expand Up @@ -59,8 +61,7 @@ class ONNXModelEditor final {
///
/// \param model_proto A shared pointer on ModelProto object.
/// \param extensions Holder for custom extensions (like custom ops).
ONNXModelEditor(std::shared_ptr<ONNX_NAMESPACE::ModelProto> model_proto,
frontend::ExtensionHolder extensions = {});
ONNXModelEditor(std::shared_ptr<ModelProto> model_proto, frontend::ExtensionHolder extensions = {});

/// \brief Modifies the in-memory representation of the model by setting
/// custom input types for all inputs specified in the provided map.
Expand Down
16 changes: 7 additions & 9 deletions src/frontends/onnx/frontend/src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@
using namespace ov;
using namespace ov::frontend::onnx;
using namespace ov::frontend::onnx::common;
using ::ONNX_NAMESPACE::ModelProto;

typedef std::shared_ptr<ONNX_NAMESPACE::ModelProto> ModelProtoPtr;
typedef std::shared_ptr<ModelProto> ModelProtoPtr;

ONNX_FRONTEND_C_API ov::frontend::FrontEndVersion get_api_version() {
return OV_FRONTEND_API_VERSION;
Expand Down Expand Up @@ -89,18 +90,15 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
std::cerr << "shared_ptr<ModelProto> has been received\n";
return std::make_shared<InputModel>(variants[0].as<ModelProtoPtr>(), m_extensions);
}
if (variants[0].is<ONNX_NAMESPACE::ModelProto*>()) {
if (variants[0].is<ModelProto*>()) {
std::cerr << "ModelProto* has been received\n";
return std::make_shared<InputModel>(
std::make_shared<ONNX_NAMESPACE::ModelProto>(*variants[0].as<ONNX_NAMESPACE::ModelProto*>()),
m_extensions);
return std::make_shared<InputModel>(std::make_shared<ModelProto>(*variants[0].as<ModelProto*>()), m_extensions);
}
if (variants[0].is<uint64_t>()) {
std::cerr << "uint64_t as a ModelProto* has been received\n";
void* model_proto_ptr = reinterpret_cast<void*>(variants[0].as<uint64_t>());
return std::make_shared<InputModel>(
std::make_shared<ONNX_NAMESPACE::ModelProto>(*static_cast<ONNX_NAMESPACE::ModelProto*>(model_proto_ptr)),
m_extensions);
return std::make_shared<InputModel>(std::make_shared<ModelProto>(*static_cast<ModelProto*>(model_proto_ptr)),
m_extensions);
}
return nullptr;
}
Expand Down Expand Up @@ -236,7 +234,7 @@ bool FrontEnd::supported_impl(const std::vector<ov::Any>& variants) const {
std::cerr << "shared_ptr<ModelProto> is supported\n";
return true;
}
if (variants[0].is<ONNX_NAMESPACE::ModelProto*>()) {
if (variants[0].is<ModelProto*>()) {
std::cerr << "ModelProto* is supported\n";
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/frontends/onnx/frontend/src/input_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ InputModel::InputModel(std::istream& model_stream,
: InputModel(model_stream, ov::util::wstring_to_string(path), enable_mmap, std::move(extensions)) {}
#endif

InputModel::InputModel(std::shared_ptr<ONNX_NAMESPACE::ModelProto> model_proto, frontend::ExtensionHolder extensions)
InputModel::InputModel(std::shared_ptr<ModelProto> model_proto, frontend::ExtensionHolder extensions)
: m_editor{std::make_shared<ONNXModelEditor>(model_proto, std::move(extensions))} {}

std::vector<ov::frontend::Place::Ptr> InputModel::get_inputs() const {
Expand Down
4 changes: 3 additions & 1 deletion src/frontends/onnx/frontend/src/input_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "openvino/frontend/extension/holder.hpp"

using ::ONNX_NAMESPACE::ModelProto;

namespace ov {
namespace frontend {
namespace onnx {
Expand All @@ -33,7 +35,7 @@ class InputModel : public ov::frontend::InputModel {
const bool enable_mmap = false,
ExtensionHolder extensions = {});
#endif
InputModel(std::shared_ptr<ONNX_NAMESPACE::ModelProto> model_proto, ExtensionHolder extensions = {});
InputModel(std::shared_ptr<ModelProto> model_proto, ExtensionHolder extensions = {});

std::vector<ov::frontend::Place::Ptr> get_inputs() const override;
std::vector<ov::frontend::Place::Ptr> get_outputs() const override;
Expand Down
8 changes: 5 additions & 3 deletions src/frontends/onnx/tests/load_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ INSTANTIATE_TEST_SUITE_P(ONNXLoadTest,
::testing::Values(getTestData()),
FrontEndLoadFromTest::getTestCaseName);

using ::ONNX_NAMESPACE::ModelProto;

TEST_P(FrontEndLoadFromTest, testLoadFromModelProtoSharedPtr) {
const auto path =
ov::util::path_join({ov::test::utils::getExecutableDirectory(), TEST_ONNX_MODELS_DIRNAME, "abs.onnx"});
Expand All @@ -72,7 +74,7 @@ TEST_P(FrontEndLoadFromTest, testLoadFromModelProtoSharedPtr) {
FrontEnd::Ptr fe;

{
auto model_proto = std::make_shared<ONNX_NAMESPACE::ModelProto>();
auto model_proto = std::make_shared<ModelProto>();
ASSERT_TRUE(model_proto->ParseFromIstream(&ifs)) << "Could not parse ModelProto from file: " << path;

ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_model(model_proto))
Expand All @@ -98,7 +100,7 @@ TEST_P(FrontEndLoadFromTest, testLoadFromModelProtoPtr) {
FrontEnd::Ptr fe;

{
auto model_proto = std::make_shared<ONNX_NAMESPACE::ModelProto>();
auto model_proto = std::make_shared<ModelProto>();
ASSERT_TRUE(model_proto->ParseFromIstream(&ifs)) << "Could not parse ModelProto from file: " << path;

ASSERT_NO_THROW(m_frontEnd = m_fem.load_by_model(model_proto.get()))
Expand All @@ -124,7 +126,7 @@ TEST_P(FrontEndLoadFromTest, testLoadFromModelProtoUint64) {
FrontEnd::Ptr fe;

{
auto model_proto = std::make_shared<ONNX_NAMESPACE::ModelProto>();
auto model_proto = std::make_shared<ModelProto>();
ASSERT_TRUE(model_proto->ParseFromIstream(&ifs)) << "Could not parse ModelProto from file: " << path;

uint64_t model_proto_ptr = reinterpret_cast<uint64_t>(model_proto.get());
Expand Down

0 comments on commit db5ec58

Please sign in to comment.