-
I seem to be stuck between a rock and a hard place. I have a generator that depends on quite a few parameters which leads to combinatorial explosion, thousands of combinations which results in hundreds of megabytes of code. Adding one more bool parameter means doubling the size of generated code, this is not going to work. One way I can think of working around this would be to split my generator into separate stages, so instead of having The other alternative would be to use select and do everything at runtime. But because select evaluates all arguments it would be executing very costly code for I'd really like to have a runtime branch in the generated code. It would be branching on a constant so branch taken is going to be the same across all pixels! I'm imagining a Would something like this be theoretically possible, does it break some underlying constraint Halide has? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Check out Func::specialize. You can pass it a boolean Expr and it will inject a branch around the evaluation of that specific Func. |
Beta Was this translation helpful? Give feedback.
Check out Func::specialize. You can pass it a boolean Expr and it will inject a branch around the evaluation of that specific Func.