(RuntimeError: MLIR etc) Difference between constants and cleartext

I tried to implement a quick function to check if a point is within a ball. The point is encrypted, the ball is clear.

https://dpaste.org/G2xf2

If I run the code without line 16, it succeeds as expected. If I uncomment line 16, I get told that “only single input table lookups are supported”

However, as that second argument is provided in the clear, it seems like something that should be (per-instantiation) functionally equivalent to using a fixed constant, and hence something that should be within reach.

Furthemore, I tried to follow the links in the relevant forum post, but they were dead at this point.

Hey @MartinStrand,

The issue is that comparison operators with constants are converted to table lookups during compilation not in runtime. Lookup table generation logic isn’t implemented in the runtime yet and that’s why it’s not compiling. It probably will be supported at one point.

For the time being, you can do return (acc - d_sq) <= 0 to achieve what you want. It should be the same in terms of behavior and performance.

Let me know if this helps!
Umut

1 Like

Thanks, that’s a brilliant (and should-be-obvious) workaround. Frankly, I’m a bit ashamed that I didn’t think about it myself.

2 Likes