Skip to content
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

Slice LazyTensor of shape (M,N) but with ndim=1 #292

Open
tiangexiang opened this issue Feb 1, 2023 · 2 comments
Open

Slice LazyTensor of shape (M,N) but with ndim=1 #292

tiangexiang opened this issue Feb 1, 2023 · 2 comments

Comments

@tiangexiang
Copy link

Hi, I am trying to slice a lazy tensor in this way:

N, M, C = 5000, 2000, 10  
a = LazyTensor(torch.randn(1, N, C))  
b =  LazyTensor(torch.randn(M, 1, C))
c = (a-b).norm2() 
print(c.shape) # this gives [M, N]
d = c[10:20]
print(d.shape) # this gives an error, but I hope to get the shape [M, 10]

However, I encountered an error saying "Starting index is out of bounds" with ndim is actually 1.
How can I correctly slice the tensor as the way I expect?

Thank you!

@JonasDeSchouwer
Copy link

Just as a comment to this question, ndim currently doesn't work properly in PyKeops (see #376). So you should assume c.shape is correct.

@JonasDeSchouwer
Copy link

To actually solve your question (pbb a lot too late), can you try:
d = c[:, 10:20]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants