-
Notifications
You must be signed in to change notification settings - Fork 590
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
Parsing error / mapping issue #223
Comments
Ah, yes, it's a limitation of the Parser when types like that get defined before the rest, but we can work around that with an Info like this: .put(new Info("onnx::OpSchema::Attribute").pointerTypes("OpSchema.Attribute")) |
Ok, now I have an error due to use of an (implicitly?) deleted function:
|
Also from the same run :
|
That would be a bug in ONNX. You'll need to patch it to correct that, or skip that declaration if you don't care about it.
|
hmm . but it compiles / links fine by itself, without javacpp, and also works with pybind11 (in the onnx repo). Also, are you saying the resolution to this should solve the original parsing error? |
It won't compile if you try to use that std::map. If you don't use it, it
builds fine.
|
Since we can't use it anyway, it's probably not important to map it, so just use a |
Still, could you point me to where the Python bindings for |
I don't think the bindings themselves are checked in to the repo, but you can generate them using https://github.com/onnx/onnx/blob/master/setup.py like so:
You can also install using
You can see an example usage of Skipping this is not an option for me, I'm specifically trying to get the operator schemas, including their attributes. Thanks |
Ok, thanks. So, let's see, would you also have code for JavaCPP somewhere
that I could run right away here?
|
Sure, just checked it in to my fork here: https://github.com/EmergentOrder/javacpp-presets |
Ok, so like I said, it's a bug in ONNX. The following doesn't compile: #include <map>
#include "schema.h"
int main() {
onnx::OpSchema s;
const std::map<std::string, onnx::OpSchema::Attribute>& m = s.attributes();
m["foo"];
} How are we supposed to access the map? |
Ok, I got OpSchema working, for my current needs. It looks like there are issues on both sides here. On the ONNX side, as reported in the two errors above, we need to add a default constructor for Attribute, and a function was getting implicitly deleted( due to having const strings in a struct). Having fixed those two issues, the example you just gave compiles without a problem. But, I still get the same parsing error from JavaCPP that I initially reported. I was able to fix this by changing
to
in schema.h. I've updated my fork so that it should work out of the box (without the parsing error), but you can edit /javacpp-presets/onnx/schema.h to reintroduce the curly brackets shown above to induce the parsing error. |
Yes, that's a problem with JavaCPP. Fixed in the commit above. |
Awesome, thanks! |
@saudet @EmergentOrder Attributes in a schema are read-only, that's why |
…` instead of `operator[]` (issue #223)
I see, thanks for the explanation @bddppq! It seems to work fine on pretty much all C++ compilers that one would care about. It also looks like a good idea to use |
thanks @saudet @bddppq !
which is because of implicit function deletion due to having const strings in a struct. |
@saudet agree you should make the change for
|
How does ONNX itself copy Attribute then? |
In any case, I thought about something, and with the commit above, we can now prevent defining the .put(new Info("const std::map<std::string,onnx::OpSchema::Attribute>").pointerTypes("StringAttributeMap").define()) |
Nice, your last commit fixes the issue with the const strings / Attribute map. Now I just have the TypeConstraintParam error. |
For which declaration does that one happen? |
https://github.com/onnx/onnx/blob/v1.0.1/onnx/defs/schema.h#L455 |
Strange, it's working just fine for me with these .put(new Info("std::vector<std::string>").pointerTypes("StringVector").define())
.put(new Info("onnx::OpSchema::TypeConstraintParam").pointerTypes("OpSchema.TypeConstraintParam"))
.put(new Info("const std::vector<onnx::OpSchema::TypeConstraintParam>").pointerTypes("TypeConstraintParamVector").define()) Could you provide more details about the error you're getting? |
@saudet ahh, I see. this time it was my mistake, I missed adding |
I'm trying to create a preset for ONNX. I've made pretty good progress and resolved a number of errors through using InfoMap. However, short of commenting out some lines in the header, I am still getting an error on parsing this header: https://github.com/onnx/onnx/blob/master/onnx/defs/schema.h
[note: line numbers below don't match those in the link above, there seems to be some reformatting happening along the way]
The offending line is:
std::map<std::string, Attribute> attributes_{};
Which I attempted to map like this:
When I comment out the offending line (and a few more referencing it), so I can get generated Java code, I see that StringAttributeMap is declared in the generated Java code. The class for Attribute also appears in the generated code, whether I explicitly map it or not. But I then get :
The text was updated successfully, but these errors were encountered: