-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Calling realize() within an AOT Generator is problematic #7847
Comments
Calling Does the threadsafe Callable mechanism make things better by requiring all the arguments get passed in at the call site? |
I also think we want to allow realize within AOT generators. It might be that we never track if a scalar param has been set, and are just defaulting to zero. We should probably add a flag for that so that we can throw an error, like we do for buffers. |
Fixing this for However, this does not fix it for the Generator/AOT case (which is how we discovered it in the first place); the failure mode we saw was basically something like this:
Obviously, At this point it's tricky to figure out we are referencing a bogus Not sure the right approach to fix this. A few thoughts:
|
We shouldn't be making a raw Variable when we use scalar_input as an Expr. Variables are supposed to either be bound by an enclosing Let or For, or have a Parameter associated with them. We should probably validate this in the IR at some point. I'm a bit confused about how more things aren't breaking if we have free Variables just floating around. I guess most lowering passes are coded defensively. |
Wait, I think I'm not understanding. The only Variable::make I see in Generator.cpp attaches a Parameter object. |
Let me take another look, maybe I'm confused |
FYI, it was in fact a Variable-with-Parameter-associated (not a 'raw' Variable), I misread the code |
…, partial) (halide#7853) * Prevent use of uninitialized scalar Parameters in JIT code (halide#7847, partial) * Fix broken tests * Update Parameter.h * Update func_clone.cpp * Fix Generators too * Fixes * Update InferArguments.cpp * Fixes * pacify clang-tidy * fixes
A user inside Google recently had some confusion about unexpected results from a Generator they wrote; the issue turned out to be that some Halide-helper-library code that they were indirectly referencing called
realize()
to produce a LUT, and while this call referenced anInput<int>
to the Generator, the LUT was (apparently) quietly produced with the value of zero.This was an easy workaround (ie, use
compute_root()
instead ofrealize()
), but there are at least two issues here worth investigating:.realize()
(or any similar JIT-invocation) during AOT Generator evaluation? While I can envision not-reasonable use cases (such as LUT creation, as in this case), they all seem like corner cases that have better solutions in the first plce (such as using compute_root()).ImageParam
I suspect we don't allow this, but perhapsParam<>
is just quietly defaulting to a value of zero?) I'd argue that the answer should be "no" in all cases.The text was updated successfully, but these errors were encountered: