Skip to content

Improve parsing of non-nn.Sequential PyTorch models #840

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

Closed
wants to merge 2 commits into from

Conversation

vloncar
Copy link
Contributor

@vloncar vloncar commented Jul 23, 2023

Description

In case of skipped layers, like Flatten or Dropout, PyTorch converter will incorrectly parse the model inputs, we need to create an input map similar to how Keras handles it. This was the case in #839. Additionally, as observed in #838, parsing of BN weights was broken. These fixes are cherrypicked from my development branch for parsing GNNs, not fully tested standalone, so I'm making this a draft PR for now before I add proper tests.

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Tests

Currently lacking. Will add something along the lines of code shared in #838 and #839

Checklist

  • I have read the guidelines for contributing.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have installed and run pre-commit on the files I edited or added.
  • I have added tests that prove my fix is effective or that my feature works. <-- Will do in a follow-up commit

@jmitrevs
Copy link
Contributor

jmitrevs commented Jul 26, 2023

Note, Flatten is not a skip layer for Keras, but gets turned into a reshape. We should check why we made that decision there and a different decision here.

@jmitrevs
Copy link
Contributor

Concerning Flatten always disappearing, whether io_stream or io_parallel, I think effectively the optimizers do that now, but I think we were worried that this isn't guaranteed to always be the case. More qualifications can be added in the streaming case if this isn't true, or if we have a different backend. I am not sure what's best but in general I think we should handle Keras and Pytorch the same way, unless there's a good reason for this to not be the case.

@vloncar
Copy link
Contributor Author

vloncar commented Aug 25, 2023

Continued in #848. Closing.

@vloncar vloncar closed this Aug 25, 2023
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