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

[Wait for #2951][application] add onnx example #2958

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

baek2sm
Copy link
Contributor

@baek2sm baek2sm commented Feb 20, 2025

added basic onnx application example.

It loads add_example.onnx file and create nntrainer network graph.
(network structure is "input + bias = output")

Output of this example is as below:

================================================================================
          Layer name          Layer type    Output dimension         Input layer
================================================================================
               input               input             1:1:1:2
--------------------------------------------------------------------------------
                bias              weight             1:1:1:2
--------------------------------------------------------------------------------
                 add                 add             1:1:1:2               input
                                                                            bias
================================================================================

Self evaluation:
Build test: [x]Passed [ ]Failed [ ]Skipped
Run test: [x]Passed [ ]Failed [ ]Skipped

Signed-off-by: Seungbaek Hong [email protected]

@baek2sm baek2sm changed the title [application] add onnx example [Wait for #2951][application] add onnx example Feb 20, 2025
@baek2sm baek2sm changed the title [Wait for #2951][application] add onnx example [Wait for #2951, #2954][application] add onnx example Feb 21, 2025
@baek2sm baek2sm force-pushed the onnx_example branch 4 times, most recently from 97d6e12 to 538c8dc Compare February 26, 2025 10:17
Copy link
Collaborator

@dkjung dkjung left a comment

Choose a reason for hiding this comment

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

LGTM

@baek2sm baek2sm force-pushed the onnx_example branch 2 times, most recently from aa8b992 to 53c58a6 Compare March 7, 2025 06:40
@baek2sm baek2sm changed the title [Wait for #2951, #2954][application] add onnx example [Wait for #2951][application] add onnx example Mar 7, 2025
baek2sm added 2 commits March 7, 2025 17:07
A simplest basic structure of onnx_interpreter has been added.
In this implementation, only input layer, weight layer, add layer are supported.

Basically, it is implemented by reading and parsing the onnx file using protobuf, and then creating an NNTrainer graph by sequentially checking the nodes. Users can simply specify the path to the ONNX model file through the "loadONNX" NNTrainer API function.

The types of tensors handled during the process of creating a graph can be classified into input tensor, constant tensor, weight tensor.
Among these, the current implementation only supports input tensor and weight tensor.
In ONNX, weight tensors have initializers unlike other tensors, so it can be distinguished as weight tensors through initializers. In the current implementation, initializer list are managed separately as a vector, but this vector will be removed as the implementation is completed in the future.

This commit uploads a minimal working implementation, and the onnx interpreter needs to be continuously updated.
An example application of reading an onnx file to create an NNTrainer model using this interpreter, and a document setting up the execution environment by installing protobuf will be uploaded as separate commits.

**Self evaluation:**
Build test: [x]Passed [ ]Failed [ ]Skipped
Run test: [x]Passed [ ]Failed [ ]Skipped

Signed-off-by: Seungbaek Hong <[email protected]>
added basic onnx application example.

It loads `add_example.onnx` file and create nntrainer network graph.
(network structure is "input + bias = output")

Output of this example is as below:

================================================================================
          Layer name          Layer type    Output dimension         Input layer
================================================================================
               input               input             1:1:1:2
--------------------------------------------------------------------------------
                bias              weight             1:1:1:2
--------------------------------------------------------------------------------
                 add                 add             1:1:1:2               input
                                                                            bias
================================================================================

**Self evaluation:**
Build test: [x]Passed [ ]Failed [ ]Skipped
Run test: [x]Passed [ ]Failed [ ]Skipped

Signed-off-by: Seungbaek Hong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants