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
Func f("f"), g("g");
Var x("x"), y("y"), u("u");
RDom r(0, 10);
f(x) = x;
f.compute_root();
g(x) = 4;
g(r.x) = 17 * f(r.x) + 8;
g.update().rfactor(r.x, u).compute_root();
const int W = 20;
g.bound(x, 0, W);
Buffer<int> buf = g.realize({W});
for (int i = 0; i < W; i++) {
int correct = i < 10 ? (17 * i + 8) : 4;
if (buf(i) != correct) {
printf("buf(%d) = %d instead of %d\n",
i, buf(i), correct);
}
}
It outputs:
buf(0) = 0 instead of 8
buf(1) = 0 instead of 25
buf(2) = 0 instead of 42
buf(3) = 0 instead of 59
buf(4) = 0 instead of 76
buf(5) = 0 instead of 93
buf(6) = 0 instead of 110
buf(7) = 0 instead of 127
buf(8) = 0 instead of 144
buf(10) = 0 instead of 4
buf(11) = 0 instead of 4
buf(12) = 0 instead of 4
buf(13) = 0 instead of 4
buf(14) = 0 instead of 4
buf(15) = 0 instead of 4
buf(16) = 0 instead of 4
buf(17) = 0 instead of 4
buf(18) = 0 instead of 4
buf(19) = 0 instead of 4
(Note buf(9) is correct).
The failure is because rfactor can create loops that apply the associative op using the identity and expect it to have no effect, but for the assignment op we use zero as the identity, and clobbering something with zero most definitely has an effect. If we had some sentinel value we could use as the identity then we could use select(a == sentinel, b, a) as the associative op, but in general we can't deduce an unused value.
I think we're going to have to disallow rfactoring assignment ops. It doesn't make much sense anyway, because the intermediate Func is only populated along a diagonal, so it's a big waste of memory.
The text was updated successfully, but these errors were encountered:
Consider the following code:
It outputs:
(Note buf(9) is correct).
The failure is because rfactor can create loops that apply the associative op using the identity and expect it to have no effect, but for the assignment op we use zero as the identity, and clobbering something with zero most definitely has an effect. If we had some sentinel value we could use as the identity then we could use select(a == sentinel, b, a) as the associative op, but in general we can't deduce an unused value.
I think we're going to have to disallow rfactoring assignment ops. It doesn't make much sense anyway, because the intermediate Func is only populated along a diagonal, so it's a big waste of memory.
The text was updated successfully, but these errors were encountered: