jel158
(Jeongmin Lee)
October 14, 2017, 3:20am
1
For tensor types of Long, Byte, and Integer, torch.dot function does not work when they are in GPU.
On CPU, there is no problem at all.
As I couldn’t find any written restriction of running torch.dot function in GPU, I am asking here.
I found that for Float tensors, torch.dot works in GPU.
>>> a = b =torch.LongTensor([1,2,3])
>>> a.dot(b)
14
>>> a=a.cuda();b=b.cuda()
>>> a.dot(b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'torch.cuda.LongTensor' object has no attribute 'dot'
smth
October 14, 2017, 7:25am
2
torch.dot hasn’t been implemented for CUDA Integer tensor types. this and kthvalue
are the only missing functions on the GPU at the moment.
1 Like
hantek
(Zhouhan Lin)
November 13, 2017, 5:58pm
3
I am getting a similar missing feature as well, seems that pow
is also not in torch.LongTensor
yet:
*** AttributeError: 'torch.cuda.LongTensor' object has no attribute 'pow'
SimonW
(Simon Wang)
November 13, 2017, 6:48pm
4
Which version are you using? This works for me:
>>> torch.cuda.FloatTensor(3).pow(2)
1.00000e-02 *
0.0003
0.1568
1.0655
[torch.cuda.FloatTensor of size 3 (GPU 0)]
>>> torch.FloatTensor(3).pow(2)
8.7180
0.0000
8.7180
[torch.FloatTensor of size 3]
hantek
(Zhouhan Lin)
November 13, 2017, 6:59pm
5
I am using the 0.2.0_1 version:
$ python -c "import torch; print torch.__version__"
0.2.0_1
torch.cuda.FloatTensor
works for me as well; but torch.cuda.LongTensor
doesn’t.
$ python -c "import torch; torch.cuda.LongTensor(3).pow(2)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'torch.cuda.LongTensor' object has no attribute 'pow'
SimonW
(Simon Wang)
November 13, 2017, 7:27pm
6
Sorry I missed the type :). This is because pow()
might give results not representable as long. You can do t * t
manually.
hantek
(Zhouhan Lin)
November 14, 2017, 1:54am
7
Thanks for the reply!
Yah that was what I did instead. By the way, reciprocal seems not working for Long as well…
SimonW
(Simon Wang)
November 14, 2017, 2:03am
8
This is expected, for same reason. You can cast to Double/Float.