Does Halide support bounds inference for RVars? #6862
-
I want to use RDom to deal with non-rectangular domains. But, I am confused about bound-inference when scheduling RVars. For example (it is just for discussion, may not be much meaningful), the generated ir of Func f("f");
Var x("x");
f(x) = input(x);
RDom r {0, input.width()};
f(r) = f(r) + 1;
output(x) = f(x);
f.compute_at(output, x); is produce output {
for (output.s0.x.rebased, 0, output.extent.0) {
let f.x.extent_realized.s.s.s = max(output.min.0 + output.s0.x.rebased, input.extent.0 + -1) - min(output.min.0 + output.s0.x.rebased, 0)
allocate f[uint8 * (max(f.x.extent_realized.s.s.s, 0) + 1)]
produce f {
let t16 = max(f.x.extent_realized.s.s.s, 0)
let t17 = min(output.min.0 + output.s0.x.rebased, 0) - input.min.0
for (f.s0.x.rebased, 0, t16 + 1) {
f[f.s0.x.rebased] = input[f.s0.x.rebased + t17]
}
let t18 = min(output.min.0 + output.s0.x.rebased, 0)
for (f.s1.r6$x, 0, input.extent.0) { // redundant computations
let t12 = f.s1.r6$x - t18
f[t12] = f[t12] + (uint8)1
}
}
consume f {
output[output.s0.x.rebased] = f[max(output.min.0 + output.s0.x.rebased, 0)]
}
free f
}
} Function produce output {
let t5 = output.min.0 - input.min.0
for (output.s0.x.rebased, 0, output.extent.0) {
allocate f[uint8 * 1]
produce f {
f[0] = input[output.s0.x.rebased + t5]
f[0] = f[0] + (uint8)1
}
consume f {
output[output.s0.x.rebased] = f[0]
}
free f
}
}
} Does Halide support bounds inference for RVars ? Are there any good ideas for scheduling rvars without redundant computations? I also see scheduling rvars in todo list. Is there any plan for it ? Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Generally speaking a function that uses an RDom changes its meaning if you don't compute the full domain, so the answer is no. But in the specific example you give you can just use a pure Var instead of r:
Update definitions don't have to use RDoms |
Beta Was this translation helpful? Give feedback.
Generally speaking a function that uses an RDom changes its meaning if you don't compute the full domain, so the answer is no. But in the specific example you give you can just use a pure Var instead of r:
Update definitions don't have to use RDoms