You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, when I use inline reductions, I can't specify a schedule for the update definition since it adds an anonymous function to do the sum and I get an error:
g(x) = sum(in1(4 * x + r) * in2(4 * x + r));
g.update().atomic().vectorize(r);
// Error: Call to update with index larger than last defined update stage for Func "g".
This error makes sense since the update definition is not part of g itself. Now, looking into the simd_op_check test I found this piece of code that does the trick
classHasInlineReduction : publicInternal::IRVisitor {
using Internal::IRVisitor::visit;
voidvisit(const Internal::Call *op) override {
if (op->call_type == Internal::Call::Halide) {
Internal::Function f(op->func);
if (f.has_update_definition()) {
inline_reduction = f;
result = true;
}
}
IRVisitor::visit(op);
}
public:
Internal::Function inline_reduction;
bool result = false;
} has_inline_reduction;
e.accept(&has_inline_reduction);
// Define a vectorized Halide::Func that uses the pattern.
Halide::Func f(name);
f(x, y) = e;
f.bound(x, 0, W).vectorize(x, vector_width);
f.compute_root();
Now, I could use this, but I was wondering if there is a better way to access the update definitions when using the inline reductions.
This discussion was converted from issue #5792 on March 19, 2021 16:45.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is just a question on scheduling update definitions of a function, so if there is a better place to ask this just let me know, but here we go.
I was experimenting with different schedules for a simple dot product between two input functions, here is the code:
Now, when I use inline reductions, I can't specify a schedule for the update definition since it adds an anonymous function to do the
sum
and I get an error:This error makes sense since the update definition is not part of
g
itself. Now, looking into thesimd_op_check
test I found this piece of code that does the trickNow, I could use this, but I was wondering if there is a better way to access the update definitions when using the inline reductions.
Beta Was this translation helpful? Give feedback.
All reactions