Skip to content

Aligning with Array API #5

Open

Description

@nicola-bastianello

the Array API exposes both dtype and device arguments on many functions. let's discuss later if we want to add them or not

comment about dtype here

comments about device in reply to this comment

asarray currently only supports scalars, see discussion here

copy is another argument sometimes exposed by the Array API see here

Activity

  1. changed the title [-]Adding dtype and device[/-] [+]Aligning with Array API[/+] on May 25, 2026
  2. Simpag commented on May 25, 2026

    @Simpag
    Collaborator

    I cannot currently think of a situation where users would need to specify the specific device. If there’s a situation where it would make sense then I am not against adding it, but otherwise it will probably cause more confusion.

    Asarray now takes dtype. Currently only bool, signed/unsigned int8-64, float16-64 and complex64-128 are implemented. It is possible to add more but for now it seemed enough. Because of the new dtype enum, which serves to unify the different dtype representations, it is now possible to add dtype args to more methods without having to test every single dtype across all supported frameworks (np.in32, torch.int32, tf.int32 etc…).

    Regarding copy as an argument of some functions. This should be considered more thoroughly, some frameworks generally use views/inplace to make it much more efficient but some frameworks like tensorflow are immutable and are therefore always copies. This should in general be documented more thoroughly, users should not rely on (or forget) that the operation may modify the value in place. For the argument itself, I don’t mind adding it but it seems a bit extra in my opinion. From my experience you more often don’t want to copy the array, but I suppose its convenient when you’d want to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions