Fix test failure if no device parameter - #459
Conversation
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
|
I tried testing this PR with MLX since that's the only library which supports DLPack but does not have the |
Co-authored-by: Tim Head <betatim@gmail.com>
|
@ev-br Care for another look? |
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
| try: | ||
| has_device = "device" in inspect.signature(xp.empty).parameters | ||
| except (TypeError, ValueError): | ||
| has_device = False |
There was a problem hiding this comment.
Ugh, this is getting messy. IIUC this whole pattern is meant to account for
- MLX not reacting to
inspect.signature(an exception or a non-informative*args, **kwargssignature, depending on thenanobindversion) - CuPy genuinely missing the
deviceargument - PyTorch raising a ValueError in
inspect.signature(xp.empty)
However, I don't think this works correctly with e.g. pytorch: inspect.signature raises but the device argument is accepted:
In [10]: torch.empty(3, device="meta")
Out[10]: tensor(..., device='meta', size=(3,))
There was a problem hiding this comment.
This problem is still there, is it?
There was a problem hiding this comment.
Meta-comment: I see now that you updated the PR a while ago. Note however that github does not send any notifications on a push, so to even know that you updated it, somebody needs to have been proactively monitoring open PRs across repositories, and taht's not a realistic expectation, for better or worse. So when updating a PR, it makes sense to ping to notify others.
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Signed-off-by: Pradyot Ranjan <99216956+pradyotRanjan@users.noreply.github.com>
Co-authored-by: Evgeni Burovski <evgeny.burovskiy@gmail.com>
Fixes #458