Expose from_dlpack on __array_namespace__()#3579
Closed
adityasingh2400 wants to merge 1 commit into
Closed
Conversation
PR ml-explore#3510 added asarray(copy=) to the array-api namespace but explicitly deferred from_dlpack until ml-explore#3495 reworked dlpack consumption. ml-explore#3495 has since merged, so wire from_dlpack into the namespace object so callers using the array-api standard can construct mx.array from a DLPack capsule via ns.from_dlpack(...). Fixes ml-explore#3484
Collaborator
|
Thanks for the PR! This is covered by #3531 which is being worked on. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
#3484 reports that
from_dlpackandasarray(copy=)are missing from the array-api namespace returned byarray.__array_namespace__(). PR #3510 wired inasarray(copy=)but explicitly deferredfrom_dlpackuntil #3495 reworked DLPack consumption. #3495 has since landed, so this PR finishes the job.Adds a top-level
mx.from_dlpack(x, *, device=None, copy=None)that delegates to the existing array-construction path. Because__array_namespace__()returns themlx.coremodule, no extra wiring is needed — the new function is picked up automatically byxp.from_dlpack(...).deviceandcopy=FalseraiseValueError, mirroring the array-api guarantees that MLX can honor today (MLX has no device targeting for DLPack imports and no zero-copy view).Repro from the issue now works:
Checklist
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changesFixes #3484.