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

Unification/Replace bug isn't doing the correct stride checks #601

Open
skeqiqevian opened this issue Mar 25, 2024 · 4 comments
Open

Unification/Replace bug isn't doing the correct stride checks #601

skeqiqevian opened this issue Mar 25, 2024 · 4 comments
Labels
T: Bug Something isn't working

Comments

@skeqiqevian
Copy link
Collaborator

Consider the following test case:

def test_blah():
    @proc
    def foo():
        x: f32[8, 3] @ AVX2
        y: f32[8, 3] @ DRAM
        for c in seq(0, 3):
            for i in seq(0, 8):
                x[i, c] = y[i, c]

    foo = replace_all(foo, mm256_loadu_ps)
    print(foo)

We should not be able to replace the innermost loop with the vector instruction because the innermost dimension is the channels c, and the stride of i is 3. However, this operation does succeed.

I suspect that the issue is that Unification isn't considering which dimension it unified against (i), and is just directly checking if each of the buffer arguments (x and y) have a 0th-dimension stride of 1, which passes. However, it should really be checking if the dimension that i corresponds to has a stride of 1 (which it doesn't).

@skeqiqevian skeqiqevian added the T: Bug Something isn't working label Mar 25, 2024
@SamirDroubi
Copy link
Collaborator

Yeah, considering asserts during unification is marked as a Todo here:

# TODO: Asserts

@SamirDroubi
Copy link
Collaborator

I am curious. Can you include the output in this case?

@skeqiqevian
Copy link
Collaborator Author

def foo():
    x: f32[8, 3] @ AVX2
    y: f32[8, 3] @ DRAM
    for c in seq(0, 3):
        mm256_loadu_ps(x[0:8, c + 0], y[0:8, c + 0])

@SamirDroubi
Copy link
Collaborator

One option that can potentially have false-negatives is to check the asserts post-unification. I believe the front-end currently has checks for such things so those can be refactored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants