Skip to content

[tools/onnx-subgraph] add onnx proto wrapper for graph parsing#14992

Merged
seanshpark merged 4 commits into
Samsung:masterfrom
chenyx113:onnx-subgraph-0328-2
Apr 1, 2025
Merged

[tools/onnx-subgraph] add onnx proto wrapper for graph parsing#14992
seanshpark merged 4 commits into
Samsung:masterfrom
chenyx113:onnx-subgraph-0328-2

Conversation

@chenyx113

Copy link
Copy Markdown
Contributor

related issue: #14534
historical full changes: #14613

add onnx proto wrapper for graph parsing

ONE-DCO-1.0-Signed-off-by: Youxin Chen yx113.chen@samsung.com

add onnx proto wrapper for graph parsing

ONE-DCO-1.0-Signed-off-by: Youxin Chen <yx113.chen@samsung.com>
@chenyx113 chenyx113 force-pushed the onnx-subgraph-0328-2 branch from 9aef03b to a0825de Compare March 28, 2025 14:14
@chenyx113 chenyx113 marked this pull request as ready for review March 28, 2025 14:16
Comment thread tools/onnx_subgraph/include/graph.h
Comment thread tools/onnx_subgraph/include/graph.h
Comment on lines +51 to +53
{
template <> struct hash<NodeTensor>
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{
template <> struct hash<NodeTensor>
{
{
template <> struct hash<NodeTensor>
{

Comment thread tools/onnx_subgraph/include/graph.h
Comment thread tools/onnx_subgraph/include/graph.h Outdated
Comment thread tools/onnx_subgraph/include/graph.h Outdated
Comment on lines +91 to +92
};
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
};
#endif
};
#endif // GRAPH_H

Comment on lines +1 to +3
//
// WARNING: This file is automatically generated! Please edit onnx.in.proto.
//

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1/ it would be better to generate at configure or compile time instead from onnx.in.proto instead of adding this generated file in source tree.

2/ I don't see onnx.in.proto file in this PR. how are you going to mange change for this file?

@chenyx113 chenyx113 Mar 31, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I use the onnx.proto file from the official github directly, and I will add auto downloading file in future code, thanks for your suggestion.

https://github.com/onnx/onnx/blob/main/onnx/onnx.proto

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see...

Comment thread tools/onnx_subgraph/src/lib/graph.cpp Outdated
*/
#include <iostream>
#include <string>
#include "graph.h"

@seanshpark seanshpark Mar 30, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

plz move this addition above #include <iostream> line like

+ #include "graph.h"
+
#include <iostream>

Comment thread tools/onnx_subgraph/CMakeLists.txt Outdated
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${Python3_INCLUDE_DIRS})

file(GLOB SOURCES "src/lib/*.cpp" "src/lib/*.cpp" )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

src/lib/*.cpp is added twice. is there particular reason?

Comment thread tools/onnx_subgraph/CMakeLists.txt Outdated

add_executable(onnx-subgraph src/main.cpp)
target_link_libraries(onnx-subgraph ${Python3_LIBRARIES})
target_link_libraries(onnx-subgraph onnx-subgraph-parser ${Python3_LIBRARIES})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional)

Suggested change
target_link_libraries(onnx-subgraph onnx-subgraph-parser ${Python3_LIBRARIES})
target_link_libraries(onnx-subgraph onnx-subgraph-parser)
target_link_libraries(onnx-subgraph ${Python3_LIBRARIES})

Comment thread tools/onnx_subgraph/include/graph.h Outdated

} // namespace std

class Graph

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Q) is there particular reason to use class? only single member exist and it's public, so it can be used with struct. what do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, it indeed doesn't need a class, just an API is ok, I have changed, thank you

Comment thread tools/onnx_subgraph/include/graph.h Outdated
onnx::GraphProto GetGraphFromOnnx(std::string &path);
};

struct graph_adjacency_node

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Other struct uses pascal naming convention. is there particular reason to use snake case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I change naming convention for this struct, thank you

Comment thread tools/onnx_subgraph/include/graph.h Outdated
int index;
};

#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#endif
#endif // GRAPH_H

@seanshpark seanshpark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@seanshpark seanshpark merged commit 9299c64 into Samsung:master Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants