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

Should array-api-compat torch from_dlpack accept copy? #204

Open
mdhaber opened this issue Nov 21, 2024 · 1 comment
Open

Should array-api-compat torch from_dlpack accept copy? #204

mdhaber opened this issue Nov 21, 2024 · 1 comment

Comments

@mdhaber
Copy link

mdhaber commented Nov 21, 2024

Currently, neither vanilla torch nor array-api-compat torch seem to accept the copy keyword. (Or the device keyword, of course, but that is probably harder to deal with.)

import numpy as np
import torch
from array_api_compat import array_namespace
xp = array_namespace(torch.asarray([1, 2, 3]))
x = np.asarray([1, 2, 3])
y = xp.from_dlpack(x, copy=False)  # TypeError: from_dlpack() got an unexpected keyword argument 'copy'
y = torch.from_dlpack(x, copy=False)  # TypeError: from_dlpack() got an unexpected keyword argument 'copy'

Should the array-api-compat version accept it, or does it need to wait for PyTorch itself?

Crossref scipy/scipy#21890

@rgommers
Copy link
Member

Needs to wait I think, that's also DLPack 1.0. from_dlpack only passes the copy keyword on to dlpack, and the copying is expected to be done by the producer.

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