On Wed, Nov 12, 2025 at 05:31:46PM -0800, Man Xavier wrote:
> Thanks for your instant reply!
> The code I'm trying to transform is part of safe softmax.
> (Actually, I'm doing optimizations targeting NPU, but the it can
> be simplified to this problem.)
> I'm trying to optimize the time locality of access A1. In other words,
> A1[0,j] should be used as soon as A1[0,j] is computed completely.
If you want to use the scheduler to compute a schedule for you
based on this locality, then you should set the proximity constraints
accordingly.
Your proximity constaints are
{ S0[i, j] -> S1[i', j' = j] : 0 <= i <= 9 and 0 <= j <= 9 and 0 <= i' <= 9; S0[i, j] -> S0[i', j' = j] : i >= 0 and 0 <= j <= 9 and i < i' <= 9 }
but, AFAICT, based on your description you should use something more like
{ S0[9, j] -> S1[i, j] : 0 <= j <= 9 and 0 <= i <= 9; S0[i, j] -> S0[i', j] : i >= 0 and 0 <= j <= 9 and i < i' <= 9 }
Like so:
$ ./isl_schedule | ./isl_codegen
{
domain: "{ S0[i, j] : 0 <= i <= 9 and 0 <= j <= 9; S1[i, j] : 0 <= i <= 9 and 0 <= j <= 9 }",
validity: "{ S0[i, j] -> S1[i', j' = j] : 0 <= i <= 9 and 0 <= j <= 9 and 0 <= i' <= 9; S0[i, j] -> S0[i', j' = j] : i >= 0 and 0 <= j <= 9 and i < i' <= 9 }",
proximity: "{ S0[9, j] -> S1[i, j] : 0 <= i <= 9 and 0 <= j <= 9; S0[i, j] -> S0[i', j] : i >= 0 and 0 <= j <= 9 and i < i' <= 9 }"
}
for (int c0 = 0; c0 <= 9; c0 += 1) {
for (int c1 = 0; c1 <= 9; c1 += 1)
S0(c1, c0);
for (int c1 = 9; c1 <= 18; c1 += 1)
S1(c1 - 9, c0);
}
You can compute these flow dependencies using the functions described
in section "Dependence Analysis" (use reads as sinks and (must-)writes
as must-sources).
If, on the other hand, you want to construct a schedule manually,
you can do that using the functions in "Schedule Trees".
skimo