Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lower: fix a bug causing undefined variables when applying fuse #360

Merged
merged 1 commit into from
Jan 14, 2021

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Jan 13, 2021

Fixes #355.

This commit fixes a bug where the fuse transformation would not generate
necessary locator variables when applied to iteration over two dense
variables.

Fixes tensor-compiler#355.

This commit fixes a bug where the fuse transformation would not generate
necessary locator variables when applied to iteration over two dense
variables.
@stephenchouca stephenchouca merged commit 27aa700 into tensor-compiler:master Jan 14, 2021
@rohany
Copy link
Contributor Author

rohany commented Jan 14, 2021

@stephenchouca, just double checking, the fix looks reasonable right? I'm very new to this codebase / TACO overall.

@stephenchouca
Copy link
Contributor

Ah, actually I just noticed that your fix introduces a regression with expressions like A(i,j,k) = B(i,j,k) * C(k,j,i) that contain dense transposes. In particular, if you run taco "A(i,j,k)=B(i,j,k)*C(k,j,i)" -f=A:ddd:0,1,2 -f=B:ddd:0,1,2 -f=C:ddd:0,1,2, it generates the following:

// ...
for (int32_t i = 0; i < C3_dimension; i++) {
    int32_t jC = k * C2_dimension + j;
    for (int32_t j = 0; j < C2_dimension; j++) {
      int32_t jA = i * A2_dimension + j;
      int32_t jB = i * B2_dimension + j;
      int32_t jC = k * C2_dimension + j;
      for (int32_t k = 0; k < C1_dimension; k++) {
        int32_t kA = jA * A3_dimension + k;
        int32_t kB = jB * B3_dimension + k;
        int32_t jC = k * C2_dimension + j;
        int32_t iC = jC * C3_dimension + i;
        A_vals[kA] = B_vals[kB] * C_vals[iC];
      }
    }
  }
// ...

which contains incorrect assignments of jC. I believe the issue is caused by the removal of the doLocate check, which was supposed to ensure that indexing statements are only emitted when all the variables they depend on have also been emitted (e.g., jC can only be initialized within the k loop).

Sorry that I missed this bug earlier; thought we had test cases like the example above, but apparently we didn't.

@stephenchouca
Copy link
Contributor

I've reverted this pull request for now. Let me know when you'd like me to review it again.

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.

scheduling: bug in fuse transformation
2 participants