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

B.eye doesn't support tensors on cuda #7

Open
InfProbSciX opened this issue Mar 16, 2023 · 1 comment
Open

B.eye doesn't support tensors on cuda #7

InfProbSciX opened this issue Mar 16, 2023 · 1 comment

Comments

@InfProbSciX
Copy link

eye doesn't keep tensors on the gpu:

In [1]: import lab as B

In [2]: import lab.torch

In [3]: import torch

In [4]: B.eye(torch.ones((2, 2)).cuda())
Out[4]: 
tensor([[1., 0.],
        [0., 1.]])  # isn't on cuda

I traced this issue back from pinv which fails due to this issue.

@wesselb
Copy link
Owner

wesselb commented Mar 20, 2023

Hey @InfProbSciX, this behaviour is as intended, although admittedly it might not be most convenient default behaviour.

What you're really after is likely the following:

with B.on_device(x):
    eye = B.eye(x)

If desired, we could change the behaviour of B.eye(x) for a tensor x so that the above in fact what happens if you just call B.eye(x).

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