If you use torch.ByteTensor as a constructor and pass it a numpy array with dtype np.bool, the returned array contains the value of the underlying byte, not 0 and 1’s (as expected right?). Am I missing part of the picture?
I understand that this is a solution, but do we really want to keep such a behavior? It can never be intended, and it is unclear from the documentation that torch.ByteTensor should not be used this way. Instead of doing unsafe casting, should we just raise an error when passing a boolean array to torch.ByteTensor?
The problem is that numpy array behave like a sequence. So if your function supports things like torch.ByteTensor([0, 1, 2]), then the numpy array will be converted to look like a sequence and a Tensor will be created from it. Unfortunately, during this conversion, types can change as it’s going through python objects.
I’m not sure we can easily change this behavior.