Skip to content

feat!: apply type promotion rules according to the device context - #889

Merged
kgryte merged 2 commits into
data-apis:mainfrom
kgryte:feat/device-promotion-graphs
Feb 6, 2025
Merged

feat!: apply type promotion rules according to the device context#889
kgryte merged 2 commits into
data-apis:mainfrom
kgryte:feat/device-promotion-graphs

Conversation

@kgryte

Copy link
Copy Markdown
Contributor

This PR:

  • closesDevice-specific type promotion rules #672 by clarifying that device info must be taken into account when applying type promotion rules in result_type and can_cast. As not all devices can support all data types, both functions need to explicitly account for whether an array or dtype can be cast and/or promoted to a desired dtype on a given device.
  • when provided only dtypes, both functions are required to only consider the full type promotion graph.
  • when at least one argument is an array, both functions must account for device capabilities.
  • for result_type, if two or more array arguments belong to separate devices, behavior is left unspecified and thus implementation-dependent.

@kgrytekgryte added API change Changes to existing functions or objects in the API. topic: Type Promotion Type promotion. labels Jan 23, 2025
@kgrytekgryte added this to the v2024 milestone Jan 23, 2025
Comment threadsrc/array_api_stubs/_draft/data_type_functions.py Outdated
@kgryte

Copy link
Copy Markdown
ContributorAuthor

As this was previously discussed during workgroup meetings, I'll go ahead and merge. If any further changes and clarifications are necessary, we can address in follow-up PRs.

@kgrytekgryte changed the title feat: apply type promotion rules according to the device contextfeat!: apply type promotion rules according to the device contextFeb 6, 2025
@kgryte
kgryte merged commit 7adeae8 into data-apis:mainFeb 6, 2025
@kgryte
kgryte deleted the feat/device-promotion-graphs branch February 6, 2025 02:31
@ev-brev-br mentioned this pull request Feb 26, 2025
10 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API changeChanges to existing functions or objects in the API.topic: Type PromotionType promotion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Device-specific type promotion rules

1 participant

@kgryte