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

add onnx-subgraph tool baseline code #14563

Closed
wants to merge 1 commit into from

Conversation

chenyx113
Copy link

related issue of: #14534
we have reported the progress status in internal discussion

  1. provide the onnx auto subgraph tool baseline code
  2. nncc configure, build, test has been done and run successfully
  3. because it is a baseline code, there are more files added, after baseline, we will submit future commits <=50 lines

please help review, any suggestions is appreciated.

Thanks & BR

@seanshpark
Copy link
Contributor

seanshpark commented Jan 19, 2025

As I know, this is your full changes as a Draft PR, so changed to DRAFT.
I'll take some rough review, that may take some time.
It is OK to post PRs with single context of changes, that builds with success.
If you don't get what single context of changes is, I'll leave some comments when you post PRs.

@seanshpark seanshpark marked this pull request as draft January 19, 2025 21:19
@seanshpark
Copy link
Contributor

some file names start with lower case and some with upper case. please use one convention.

Comment on lines +1 to +8
# cmake version dependency
cmake_minimum_required(VERSION 3.10)
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
SET(CMAKE_CXX_STANDARD 17)

project(onnx-subgraph-parser)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# cmake version dependency
cmake_minimum_required(VERSION 3.10)
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
SET(CMAKE_CXX_STANDARD 17)
project(onnx-subgraph-parser)

@@ -0,0 +1,48 @@
## onnx_autosubgraphs
Copy link
Contributor

Choose a reason for hiding this comment

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

plz take look look at other modules README file and follow the convention.

@@ -0,0 +1,48 @@
## onnx_autosubgraphs
in this project, we can support onnx AI model auto subgraph, the AI model can be splitted by model size, operators etc, it help much for on-device AI acceleration, and has been verified on Rose-P NPU and Qualcomm DSP.
Copy link
Contributor

Choose a reason for hiding this comment

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

plz split lines with width > 100

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO, you shouldn't use internal code name!

Comment on lines +1 to +6

# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved

#

# Licensed under the Apache License, Version 2.0 (the "License");
Copy link
Contributor

Choose a reason for hiding this comment

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

there are unnecessary empty lines.
please remove them like

Suggested change
# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");

@@ -0,0 +1,76 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

plz put source files into src folder.

@seanshpark
Copy link
Contributor

plz run nncc format and correct formatting

Comment on lines +23 to +24
2. mkdir build & cd build
3. cmake .. & make
Copy link
Contributor

Choose a reason for hiding this comment

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

we don't allow building separate building in compiler/* modules
all compiler modules are built from infra/nncc/CMakeLists.txt
have you not read docs/howto/how-to-build-compiler.md ?

Comment on lines +28 to +30
1. edit the config.json as your needs
-> NPU_supported_ops mean operators that can be supported by NPU
-> CPU_supported_ops mean operators that can be supported by CPU
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 examples files that I can check with?

@@ -0,0 +1,48 @@
## onnx_autosubgraphs
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we have similar tool already with circle model, not ONNX.
But I think you can refer compiler/circle-partitioner/README.md file for explaining what and how to use the tool.

@seanshpark
Copy link
Contributor

seanshpark commented Jan 20, 2025

thinking about this tool and maintenance,

  1. if we put inside as compiler/onnx-subgraph, this tool can be one of compiler tools, later can be distributed into Debian package, but needs to follow the existing rules.
    CI does build check.
  2. if we put inside as tools/onnx-subgraph, this is just tool share and can be somewhat independent from compiler or runtime, can have it's own build and execution environment.
    Current CI doesn't do build check and has to add if necessary.

I am gradually thinking 2) case looks better. @chenyx113 and others, what do you guys think?

Anyway, we haven't done it in the past, but in the future, we can relocate any tools/* to compiler/* if requirements are met.

@chenyx113
Copy link
Author

thinking about this tool and maintenance,

  1. if we put inside as compiler/onnx-subgraph, this tool can be one of compiler tools, later can be distributed into Debian package, but needs to follow the existing rules.
    CI does build check.
  2. if we put inside as tools/onnx-subgraph, this is just tool share and can be somewhat independent from compiler or runtime, can have it's own build and execution environment.
    Current CI doesn't do build check and has to add if necessary.

I am gradually thinking 2) case looks better. @chenyx113 and others, what do you guys think?

Anyway, we haven't done it in the past, but in the future, we can relocate any tools/* to compiler/* if requirements are met.

@seanshpark
Thanks for your review and suggestions, I will update my code according to the comments.
and as the suggestion of "tools/onnx-subgraph,", I think it is a good idea, because our code is more like a general tool for AI model pre-processing. I will move current code to 'tool' and create new PR again, after testing and code format checking.

BR
Chen

@chenyx113
Copy link
Author

update the code according to comments, and change path from 'compiler' to 'tool', thanks for the kindly review and suggestions

@chenyx113 chenyx113 closed this Jan 20, 2025
@chenyx113 chenyx113 deleted the onnx-subgraph branch January 23, 2025 13:51
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