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

Adds ONNX Optimizer, Version Converter and IR. #622

Merged
merged 11 commits into from
Oct 31, 2018
Merged

Adds ONNX Optimizer, Version Converter and IR. #622

merged 11 commits into from
Oct 31, 2018

Conversation

EmergentOrder
Copy link
Member

The goal here is being able to "polish" a model, as well as convert it to the latest version, via the preset.
Some notes:

  • The patchfile for optimize.h illustrates that JavaCPP expects semicolons where none are strictly necessary.
  • The patchfile for optimize_pass.h illustrates an issue with the combination of virtual and inline for constructor declarations
  • I had to skip lots of things, some of which might be important, I have yet to test.

saudet added a commit to bytedeco/javacpp that referenced this pull request Oct 25, 2018
…xception` annotation

 * Fix `Parser` failures on variadic function template arguments `...` and destructor attributes (pull bytedeco/javacpp-presets#622)
@saudet
Copy link
Member

saudet commented Oct 25, 2018

Looks good! I've fixed this up in JavaCPP, so let me know if you encounter any other issues or when this is ready to merge, thanks!

@EmergentOrder
Copy link
Member Author

Thanks for the fixes!

I tested check_model and added it to the README.

When I try Optimize(...) I get :

java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.onnx.Optimize(Lorg/bytedeco/javacpp/onnx$ModelProto;Lorg/bytedeco/javacpp/onnx$StringVector;)Lorg/bytedeco/javacpp/onnx$ModelProto;
  at org.bytedeco.javacpp.onnx.Optimize(Native Method)

@EmergentOrder
Copy link
Member Author

EmergentOrder commented Oct 27, 2018

Similarly for InferShapes(...) :

java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.onnx.InferShapes(Lorg/bytedeco/javacpp/onnx$ModelProto;)V
  at org.bytedeco.javacpp.onnx.InferShapes(Native Method)

Although it required a few changes I haven't pushed yet to get there.

I still need to test version conversion.

@saudet
Copy link
Member

saudet commented Oct 28, 2018

That sounds like the build is missing some options that would include those symbols in the library.

@EmergentOrder
Copy link
Member Author

Yeah, that was my first thought too. The thing is, there don't seem to be any build options for this, it should already be there in the libonnx.so.

There's no mention of build options in the docs:
https://github.com/onnx/onnx/blob/v1.3.0/docs/Optimizer.md
https://github.com/onnx/onnx/blob/v1.3.0/docs/ShapeInference.md

And in fact the .so matches when I grep for the function names ( GetAvailablePasses from the optimizer for example).
Maybe the generated function signature doesn't match what's in the .so ?

@saudet
Copy link
Member

saudet commented Oct 28, 2018

Check with readelf -Ws, they probably show up as "undefined".

@EmergentOrder
Copy link
Member Author

EmergentOrder commented Oct 28, 2018

@Namespace("onnx::optimization") public static native @Const @ByVal StringVector GetAvailablePasses();

java.lang.UnsatisfiedLinkError: org.bytedeco.javacpp.onnx.GetAvailablePasses()Lorg/bytedeco/javacpp/onnx$StringVector;
  at org.bytedeco.javacpp.onnx.GetAvailablePasses(Native Method)
  ... 36 elided
   215: 00000000000efb70   188 FUNC    GLOBAL DEFAULT   12 _ZN4onnx12optimization18GetAvailablePassesB5cxx11Ev
   993: 00000000000efb70   188 FUNC    GLOBAL DEFAULT   12 _ZN4onnx12optimization18GetAvailablePassesB5cxx11Ev

@EmergentOrder
Copy link
Member Author

EmergentOrder commented Oct 28, 2018

Hmm, ok I'm thinking this related to what I reported in one of the previous PRs,
where mvn install --projects ../onnx/platform -Djavacpp.platform.host as per README pulls jars from sonatype instead of using the locally built ones.
So after wiping my local maven repo, and installing I now get
error: not found: value GetAvailablePasses instead of the link error.

@EmergentOrder
Copy link
Member Author

EmergentOrder commented Oct 28, 2018

Actually, that was installing from platform without installing the local build first.
When I install onnx preset then platform (immediately after, or using the maven option --no-snapshot-updates), I'm back to the link error and seeing that GetAvailablePasses IS in fact defined in the .so (I checked in my local maven repo after install).
So I'm stumped.

@EmergentOrder
Copy link
Member Author

EmergentOrder commented Oct 28, 2018

Damn.. It turns out that, yep, it was the same issue as a few months ago, my local was not being used.

@EmergentOrder
Copy link
Member Author

Ready to merge!

still haven't figured out how to maven install platform without getting the UnsatisfiedLinkError (offline mode and no snapshot updates don't seem to do it), but working around with manual jar copy to the lib dir works.

@saudet
Copy link
Member

saudet commented Oct 31, 2018

Yup, it's working fine here! Thanks. Good to merge?

@EmergentOrder
Copy link
Member Author

Yep, good to merge.

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