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
[BUG] Bool Tensor does not match with BOOL SIMD from load #2492
Comments
|
That is possible I suppose, but the issue still occurs if I call store and load from the pointer under the tensor. # Add to the bottom of the original snippet
for i in range(32):
booltens._ptr.store[width=1](i,True)
print(booltens._ptr.load[width=32](0))
"""[False, False, False, False, False, False, True, False, False, False, False, False, False, True, False, True, True, False, False, True, False, False, False, False, False, False, True, False, True, False, True, True]""" I feel like I have heard that Mojo's Bool is an i1 and I feel like if that is the case what is happening is a misalignment between how different parts of the codebase handle that fact. |
If you print the values one by one, it does work. |
That is interesting, but the issue still breaks vectorization. What is even more interesting is what happens if you grab 2 at a time from tensor import Tensor
import math
def main():
var booltens = Tensor[DType.bool](32)
booltens.data().store[width=32](0,SIMD[DType.bool,1](True))
print(booltens._ptr.load[width=32](0))
for i in range(0,32,2):
print(booltens._ptr.load[width=2](i))
"""
[True, True]
[True, True]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
[True, False]
""" The first 2 grabs get the first 4 values correctly then after that it alternates with each load grabbing only one correct value. |
Also this from tensor import Tensor
import math
def main():
var booltens = Tensor[DType.bool](32)
booltens.data().store[width=32](0,SIMD[DType.bool,1](True))
print(booltens)
for i in range(32):
print(booltens[i]) Shows that when you set the values in the pointer from a simd store it (from the perspective of Tensor's |
Bug description
The set_item and store methods of Tensor do not correctly assign values to the pointer to be retrieved by the load method as a SIMD when using DType.bool. It works for every other type I have tested. It only stores the true value every 8 index spots in the SIMD(perhaps corresponding to bits in a byte as I think SIMD bool is technically a one bit implementation).
Steps to reproduce
If you run the following code you should get the values in the triple quotes under the prints
The text was updated successfully, but these errors were encountered: