Array indexing with non purely Int type #2904
Replies: 3 comments 5 replies
-
@always_inline
fn __getitem__(self,
x: SIMD[DType.uint16, 1], # not SIMD[DType.uint16]
...,
) -> Scalar[dtype]:
... |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lbartworks
-
Thanks so much. The fact is that the size parameter defaults to and that happens to be the max number of elements of such type that can be fit on a SIMD register (16 in my case). |
Beta Was this translation helpful? Give feedback.
1 reply
-
You can also use Intable trait to accept anything that can be turned into an Int |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
I have the following simple PoC of the issue.
The code creates a 2D struct and when accessing the indices with a SIMD int type (instead of the pure Int) the compiler throws the error at the bottom. It runs on the Playground.
Could you help me understand what is wrong? I assume is not a compiler bug
Thanks
luis
ERROR:
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:136:4: error: function instantiation failed
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:136:4: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:119:4: note: function instantiation failed
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:131:57: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:91:4: note: function instantiation failed
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:107:18: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:128:8: note: function instantiation failed
/__w/modular/modular/Kernels/mojo/stdlib/builtin/_startup.mojo:129:22: note: call expansion failed - no concrete specializations
/source/prog.mojo:25:5: note: function instantiation failed
def main():
^
/source/prog.mojo:34:19: note: call expansion failed - no concrete specializations
print(example1[index2,index2])
^
/source/prog.mojo:22:8: note: function instantiation failed
fn getitem(self, x: SIMD[DType.uint16], y: SIMD[DType.uint16]) -> SIMD[dtype,1]:
^
/__w/modular/modular/Kernels/mojo/stdlib/memory/unsafe.mojo:530:56: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/stdlib/builtin/int.mojo:133:4: note: function instantiation failed
/__w/modular/modular/Kernels/mojo/stdlib/builtin/int.mojo:145:25: note: call expansion failed - no concrete specializations
/__w/modular/modular/Kernels/mojo/stdlib/builtin/simd.mojo:115:8: note: function instantiation failed
/__w/modular/modular/Kernels/mojo/stdlib/builtin/constrained.mojo:34:6: note: constraint failed: expected a scalar type
mojo: error: failed to run the pass manager
Beta Was this translation helpful? Give feedback.
All reactions