Skip to content

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

Merged
seanshpark merged 4 commits intoSamsung: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 intoSamsung: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 [email protected]

add onnx proto wrapper for graph parsing

ONE-DCO-1.0-Signed-off-by: Youxin Chen <[email protected]>
@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 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 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?

Copy link
Copy Markdown
Contributor Author

@chenyx113 chenyx113 Mar 31, 2025

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...

*/
#include <iostream>
#include <string>
#include "graph.h"
Copy link
Copy Markdown
Contributor

@seanshpark seanshpark Mar 30, 2025

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>

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?


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})


} // 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

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

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

Copy link
Copy Markdown
Contributor

@seanshpark seanshpark left a comment

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
5 checks passed
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