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

Parser rewrite #1296

Merged
merged 24 commits into from
Feb 24, 2024
Merged

Parser rewrite #1296

merged 24 commits into from
Feb 24, 2024

Conversation

skewballfox
Copy link
Contributor

@skewballfox skewballfox commented Feb 12, 2024

Pull Request Template

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

If there are any others I should link, please let me know.

Changes

Rewrote the parser to handle everything but node removal in a single pass. Node inputs and arguments are updated on node construction, and node.passed is used to keep track of whether an IO argument is used. This parser only works if the nodes are topologically sorted, so I think instead of checking (which is $\Theta(N^2))$, we should call the function in the event of a panic, testing the model validity only after something else failed.

There is still some housecleaning to be done, I need to either make it an actual builder which returns an OnnxGraph, or change the functions to take the necessary state as arguments. oh, and there is enough dead code here to fill a mortuary.

There is still quite a bit that could be done to make this faster or use less memory, such as altering BurnGraph to use OnnxGraphIO, but that's a PR for another time.

Testing

I ran all Onnx Test to ensure that building the existing models still works the same.

If you would like me to add more test somewhere, let me know.

I noticed that certain situations with initializers isn't tested in the onnx-tests, but are captured by running the examples. For example there were a couple of problems that would arise when an node input was both in the initializers and graph inputs that only showed up on the squeezenet1.onnx example.

It might be a good idea to either make building those examples part of the onnx test or create a few small models for testing that situation

@skewballfox skewballfox mentioned this pull request Feb 13, 2024
2 tasks
@skewballfox skewballfox marked this pull request as ready for review February 19, 2024 17:45
Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: 439 lines in your changes are missing coverage. Please review.

Comparison is base (4427768) 78.77% compared to head (3e921d6) 78.83%.
Report is 1 commits behind head on main.

Files Patch % Lines
crates/burn-import/src/onnx/from_onnx.rs 0.00% 322 Missing ⚠️
crates/burn-import/src/onnx/dim_inference.rs 0.00% 48 Missing ⚠️
crates/burn-import/src/onnx/ir.rs 0.00% 32 Missing ⚠️
crates/burn-import/src/onnx/coalesce.rs 0.00% 21 Missing ⚠️
crates/burn-import/src/burn/ty.rs 40.00% 9 Missing ⚠️
crates/burn-import/src/onnx/proto_conversion.rs 0.00% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1296      +/-   ##
==========================================
+ Coverage   78.77%   78.83%   +0.06%     
==========================================
  Files         551      555       +4     
  Lines       61836    62212     +376     
==========================================
+ Hits        48712    49046     +334     
- Misses      13124    13166      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@antimora antimora left a comment

Choose a reason for hiding this comment

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

It's my first pass and I have minor comments. I dive in more to understand your changes better because there are a lot of it.

burn-import/src/onnx/coalesce.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/coalesce.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/coalesce.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/dim_inference.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/from_onnx.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/from_onnx.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/from_onnx.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/from_onnx.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/from_onnx.rs Outdated Show resolved Hide resolved
burn-import/src/onnx/ir.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@antimora antimora left a comment

Choose a reason for hiding this comment

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

LGTM. I am relying on tests to verify the correctness and @skewballfox's ability for large refactors. Let push it through.

@skewballfox , let me know if it's ready to be merged.

@antimora antimora merged commit 706e0eb into tracel-ai:main Feb 24, 2024
13 of 14 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