( lazyvec1 - lazyvec1.t() ) @ lazyvec2 fails with: 'NoneType' object has no attribute 'replace' #210
-
Hi, Thanks for the nice work. I am not sure if I am using the library correctly as it is the first time I try it but the following behaviour looks counter-intuitive to me. Can someone tell me if it's a bug or a misunderstanding from my part? For two vectors
The workaround I found was to create a second lazy vector from the transposed concrete vector Let me know what I might be missing. Here is an example (also on colab): import torch
print(torch.__version__)
torchdevice = torch.device('cpu')
if torch.cuda.is_available():
torchdevice = torch.device('cuda')
print('Default GPU is ' + torch.cuda.get_device_name(torch.device('cuda')))
print('Running on ' + str(torchdevice))
!pip install pykeops[colab]
import pykeops
print('pykeops version:',pykeops.__version__)
from pykeops.torch import LazyTensor
# Generate 2 vector u and v
u = torch.normal(0, 1, size=(5,1), device=torchdevice)
v = torch.normal(0, 1, size=(5,), device=torchdevice)
# Compute (u - u.T) @ v in a dense fashion
P = u - u.t()
Pv = P @ v
print('Pv: ',Pv)
# Compute (u - u.T) @ v in a lazy fashion
u_l = LazyTensor(u,axis=0)
print('u_l: ', u_l)
# Using the transpose of the lazy tensor doesn't work here
#print('u_l.t(): ', u_l.t())
#P_l = u_l - u_l.t()
#print('P_l:', P_l)
# We thus go for transposing the concrete vector and creating a new lazy tensor
# However, it seems to fails when provided as a 2D matrix of size 1 x N
#ut_l = LazyTensor(u.t(),axis=1)
print('LazyTensor(u.t(),axis=1): ',LazyTensor(u.t(),axis=1))
ut_l = LazyTensor(u.t()[...,None])
print('ut_l: ', ut_l)
P_l = u_l - ut_l
print('P_l:', P_l)
Pv_froml = P_l @ v
print('Pv_froml: ',Pv_froml)
# Putting this at the end just to highlight that this fails
( u_l - u_l.t() ) @ v |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello @tvercaut , |
Beta Was this translation helpful? Give feedback.
Hello @tvercaut ,
I have made this an issue because it is clearly a bug, I will answer you in the issue section