Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

array-api-strict flags #30

Merged
merged 19 commits into from
Apr 19, 2024
Merged

array-api-strict flags #30

merged 19 commits into from
Apr 19, 2024

Conversation

asmeurer
Copy link
Member

@asmeurer asmeurer commented Apr 8, 2024

Flags are global variables that set array-api-strict in a specific mode. Currently support flags change the support array API standard version, enable or disable data-dependent shapes, and enable or disable optional extensions.

So far I have only set up the structure for setting and getting these flags. Let me know if this seems like a good API layout or not.

I plan to add functionality to the various functions to enable/disable behaviors depending on what flags are set.

Fixes #8
Fixes #7

asmeurer added 8 commits April 8, 2024 16:03
Flags are global variables that set array-api-strict in a specific mode.
Currently support flags change the support array API standard version, enable
or disable data-dependent shapes, and enable or disable optional extensions.

This commit only sets up the structure for setting and getting these flags.
This behavior still needs to be tested.

This required moving the linalg functions that are also in the main namespace
so that they can still work there even when the linalg extension is disabled.

The way I've decided to implement this is that the functions will not raise an
exception until they are called. It would probably be more convenient for
users if they raised an attribute error, or if the extension namespace itself
did, like it would in a real library without the given extension. But the
implementation for this would be a lot more complicated and didn't really feel
worth it to me.
shapes depend on the input data.

This flag is enabled by default. Array libraries that use computation graphs may not be able to support
functions whose output shapes depend on the input data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray sentence, duplicate with paragraph above

@rgommers
Copy link
Member

@asmeurer I think the get_/reset_/set_array_api_strict_flags API is easy to understand, seems perfectly fine to me.

@asmeurer asmeurer mentioned this pull request Apr 16, 2024
@asmeurer asmeurer marked this pull request as ready for review April 17, 2024 22:22
@asmeurer
Copy link
Member Author

This is ready to go. I'm not going to implement anything for 2021.12 unless someone requests it. But using this, I can add preliminary support for 2023.12.

One thing I'm not completely sure about is if someone sets a flag using an environment variable, like ARRAY_API_STRICT_DEPENDENT_SHAPES=False, and then calls reset_array_api_strict_flags(), should that reset the flags back to what was set by the environment variables, or back to the default values? Right now I have it so that they are reset back to the default values.

@asmeurer asmeurer merged commit 7aaeda2 into data-apis:main Apr 19, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for older versions of the standard Add a mode that disables data-dependent shapes
2 participants