-
Notifications
You must be signed in to change notification settings - Fork 54
RFC: add "mutable arrays" to capabilities #845
Copy link
Copy link
Open
Labels
API extensionAdds new functions or objects to the API.Adds new functions or objects to the API.Needs DiscussionNeeds further discussion.Needs further discussion.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.topic: InspectionArray API inspection.Array API inspection.
Milestone
Metadata
Metadata
Assignees
Labels
API extensionAdds new functions or objects to the API.Adds new functions or objects to the API.Needs DiscussionNeeds further discussion.Needs further discussion.RFCRequest for comments. Feature requests and proposed changes.Request for comments. Feature requests and proposed changes.topic: InspectionArray API inspection.Array API inspection.
Several parts of the Array API standard assume that array objects are mutable. Some array API implementations (notably JAX) do not support mutating array objects. This has led to array API implementations currently being developed in
scipyandsklearnto be entirely unusable in JAX.Given this, downstream implementations have a few choices:
jax.numpy.Array, changing the implementation logic for that case.(1) is a bad choice, because it means JAX will not be supported. (2) is a bad choice, because for libraries like NumPy, it leads to excessive copying of buffers, worsening performance. (3) is a bad choice because it hard-codes the presence of specific implementations in a context that is supposed to be implementation-agnostic.
One way the Array API standard could address this is by adding
"mutable arrays"or something similar to the existingcapabilitiesdict. Then downstream implementations could use strategy (3) without special-casing particular implementations.