Skip to content

scheduling: reject reorder() of compressed dimension before its storage parent#578

Open
itsme-ranger wants to merge 1 commit into
tensor-compiler:masterfrom
itsme-ranger:fix/reorder-sparse-dependency-check
Open

scheduling: reject reorder() of compressed dimension before its storage parent#578
itsme-ranger wants to merge 1 commit into
tensor-compiler:masterfrom
itsme-ranger:fix/reorder-sparse-dependency-check

Conversation

@itsme-ranger

Copy link
Copy Markdown

Fixes #403.

Reorder::apply() accepted any loop reordering without checking whether the
requested order is valid for the tensor's storage format. For a tensor in CSF
or CSR format, the position array of level L is indexed by the level-(L-1)
iterator variable, so the level-L loop must be nested inside the level-(L-1)
loop. Requesting reorder(j, i, k) on a fully-compressed tensor A(i,j,k)
previously emitted code that read iA before it was declared:

// buggy output
for (int32_t jA = A2_pos[iA]; ...) {   // iA not yet defined
  for (int32_t iA = A1_pos[0]; ...) {

This PR adds a validation step in Reorder::apply() that walks all tensor
accesses and, for each pair of consecutive compressed modes (prev, cur),
checks that prev's index variable appears before cur's index variable in
the requested pattern. If not, it returns an empty IndexStmt and sets the
reason string.

A regression test is added: SpTV y(j) = A(i,j,k) * x(k) with
A = {Compressed, Compressed, Compressed}reorder({j, i, k}) must fail
with a non-empty reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpTV: index variable used before defined

1 participant