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

onnx2c/src/nodes/cast.cc:36: virtual void toC::Cast::resolve(): Assertion `false' failed. #26

Closed
PasaOpasen opened this issue Dec 27, 2022 · 5 comments

Comments

@PasaOpasen
Copy link

Tried to compile this model https://dropmefiles.com/MkdyS

with structure
craft_fix_input onnx

what can be wrong?

@kraiskil
Copy link
Owner

What is happening here is, as you write in the title of this issue, you are hitting this error.

This is an unimplemented feature in onnx2c.
I don't see the full output of onnx2c, but if the error message linked to above is not printed out, then it is also an error in onnx2c.

The entire concept of a cast operation should be folded into the output of the predecessor node of the cast, as having a separate node just means a redundant copy of data. On the other hand, the C compiler should maybe have such an optimization pass?

@PasaOpasen
Copy link
Author

╭─ pasa  ~/Job/__tmp/onnx2c/build  📁 4 🗎 9 🔗 0   master 
╰> $ ./onnx2c ../../craft_fix_input.onnx > model.c
2022-12-29 21-07-35.866 [Fatal] (resolve) Unimplemented casting to requested type
onnx2c: /home/pasa/Job/__tmp/onnx2c/src/nodes/cast.cc:36: virtual void toC::Cast::resolve(): Assertion `false' failed.

its whole stack

@shubham0204
Copy link

@kraiskil is there any update to this error?

2024-02-09 09-56-10.197 [Info] (onnx_ir_version) Model has multiple opset versions.
2024-02-09 09-56-10.283 [Info] (resolve) 'Cast' node found.
2024-02-09 09-56-10.284 [Info] (resolve) 'Cast' node found.
2024-02-09 09-56-10.284 [Info] (resolve) 'Cast' node found.
2024-02-09 09-56-10.284 [Info] (resolve) 'Cast' node found.
2024-02-09 09-56-10.284 [Warn] (Elementwise) Round operand implementation is not strictly conformant
2024-02-09 09-56-10.285 [Info] (resolve) 'Cast' node found.
2024-02-09 09-56-10.285 [Fatal] (resolve) Unimplemented casting to requested type
onnx2c: ~/onnx2c/src/nodes/cast.cc:34: virtual void toC::Cast::resolve(): Assertion `false' failed.

@kraiskil
Copy link
Owner

@shubham0204 sorry, no.
I've been working in the background for the possibility for optimizing input onnx networks (folding Casts away being one of them), so I didn't pay much attention to improving Cast.

Looking at the code at src/nodes/cast.cc:34, it should be fairly straight-forward to extend to support other datatypes. Unfortunately onnx doesn't seem to have any backend test for integer casting, so I am reluctant to add such code "blindly". I guess it could be added even without a unittest as long as someone has tested the patch to be working...

kraiskil added a commit that referenced this issue May 19, 2024
Related to issue #26
@kraiskil
Copy link
Owner

Might be fixed now, please re-open new issue, if not.

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

No branches or pull requests

3 participants