-
Notifications
You must be signed in to change notification settings - Fork 63
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
heir_translate: Dialect 'memref' not found for custom op 'memref.alloc'
#954
Comments
Hey! Thanks for such a detailed report. I think what you ran into is expected, as in, nothing wrong on your part, but let me add some comments about the approach. The memref / RLWE pipeline gap is actually something I was working on this week and I'll update you (and at the WG meeting tomorrow).
The gap:
If you'll be at the WG meeting tomorrow let's chat! I'll try to see what happens when I lower the TOSA code to the entry IR for |
So back to the original issue described (which honestly, thank you! this serves as good docs as well): memref was not a supported dialect for the openfhe emitter because we currently expected tensor + affine + arith IRs in the pipelines that emit to openfhe right now. Of course, we can always add support for memref alloc / loads / stores to the emitter for the sake of compatibility (even if we're not getting nice optimized versions of these programs that use tensor semantics and rotations). WDYT? |
This is what I got when I ran your TOSA model through my local linalg to affine with tensor semantics lowering:
Note: it didn't handle the You should be able now to pass this to |
Thank you so much for such a quick and thorough response! I was unable to attend the WG this morning unfortunately. Is it every other Wednesday at 5AM Pacific? I am able to run When I try to run the same for the IR you provided in your last comment, I get a core dump that I'm not sure how to parse. It could be an LLVM problem more than an HEIR one, I'm not sure. I get similar output if I replace
|
Ah, it's every other Thursday at 8 AM Pacific: https://heir.dev/community/!
Oh, no apology needed :) I was able to repro the issue, and I think it's an issue in the This is the IR before
and when I run in debug mode I'm seeing the secret RemoveUnusedGenericArgs causing the issue (omitted some lines in the stack trace):
|
CollapseSecretlessGeneric ensures that memref allocation ops are not collapsed - this also adds in empty tensor allocations for IRs that are not using pure buffer semantics (as is the case in the RLWE pipelines) Part of #954 PiperOrigin-RevId: 672544871
CollapseSecretlessGeneric ensures that memref allocation ops are not collapsed - this also adds in empty tensor allocations for IRs that are not using pure buffer semantics (as is the case in the RLWE pipelines) Part of #954 PiperOrigin-RevId: 672544871
Ohhh I see now that it says Pacific at the bottom of the calendar. I had assumed it showed localized timezones—oops! (I'm on the east coast.) I'll be at the next one |
CollapseSecretlessGeneric ensures that memref allocation ops are not collapsed - this also adds in empty tensor allocations for IRs that are not using pure buffer semantics (as is the case in the RLWE pipelines) Part of #954 PiperOrigin-RevId: 672544871
CollapseSecretlessGeneric ensures that memref allocation ops are not collapsed - this also adds in empty tensor allocations for IRs that are not using pure buffer semantics (as is the case in the RLWE pipelines) Part of #954 PiperOrigin-RevId: 672647075
Hi @asraa. Has your internal lining/affine code been merged yet? I have a simpler matmul example at https://github.com/johnmatter/simplemlir that I put together for the sake of reproducibility. It still starts with I don't necessarily need optimized SIMD operations, for what it's worth. For my purposes, I just need a fairly general end-to-end TOSA to C++ pipeline that compiles. I'm still at proof-of-concept :) |
Actually,
The openfhe step fails with: Is that because I need to flatten/pad the matrices to be 1xN where N is a power of two? |
I am trying to create a pipeline to get from StableHLO to OpenFHE by way of TOSA. It's possible I'm making a newbie mistake, so I'll write up my approach.
Environment
I'm on Ubuntu 24.04. My local build of HEIR is with commit 90bdae81f3ae7320bd00b1e7a2920e63ff0b2ff6. There's no particular reason for being on this commit—that's just the last time I
git pull
edLower StableHLO to TOSA with
stablehlo-opt
Here is a sample function that might be part of a CNN:
This mostly lowers to TOSA with
stablehlo-opt -stablehlo-prepare-for-tosa in.stablehlo
It misses the
stablehlo.reshape
but that's easy enough to replace by hand:Lower TOSA with
heir-opt
This output is 33k lines long. Lines that include
memref
include 17k of the formsThe other
memref
lines are:The remaining lines are arith.add, arith.mulf, arith.constant, etc.
Emit OpenFHE with
heir-translate
This is where things fail.
The text was updated successfully, but these errors were encountered: