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

array arguments in @cast indexing #70

Open
visva89 opened this issue Jul 31, 2023 · 1 comment
Open

array arguments in @cast indexing #70

visva89 opened this issue Jul 31, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@visva89
Copy link

visva89 commented Jul 31, 2023

Here is a short example (Julia 1.9.2)

bsz = (8, 8);

#this doesnt work:
@cast b[(b1,b2), t, h,w] := img[(b1, h), (b2, w), t] (b1 in 1:bsz[1], b2 in 1:bsz[2]);

#this works:
bsz1 = bsz[1];
bsz2 = bsz[2];
@cast b[(b1,b2), t, h,w] := img[(b1, h), (b2, w), t] (b1 in 1:bsz1, b2 in 1:bsz2);

Is it expected behavior? Just learning Julia, couldn't find why this doesn't work in docs or other issues.

@mcabbott
Copy link
Owner

That's a bug of some sort.

In an expression like @reduce a[i] := sum(j) b[i,j], and in one like @cast c[i] := d[i] (i in 1:3), the macro gets two expressions. It is, apparently, using the absence of any indexing in the second to distinguish them. Which goes wrong in your example. It should infer this some other way, and leave 1:bsz[1] alone.

(The error is slightly confusing, it talks about "how do I reduce over..." and comes from reduceparse. This is because @cast accepts things that like @cast _[i,j] := softmax(j) m[i,j], the syntax of @reduce without dropping dims.)

@mcabbott mcabbott added the bug Something isn't working label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants