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

Try to make pytensor compatible with the Python array API standard #1189

Open
ricardoV94 opened this issue Feb 4, 2025 · 1 comment
Open

Comments

@ricardoV94
Copy link
Member

ricardoV94 commented Feb 4, 2025

Description

https://data-apis.org/array-api/latest/index.html

The standard considers lazy graph libraries so we should be fine. The only large difference I saw was that the .shape attribute should return a tuple of integers or None, whereas our variable.shape attribute returns a symbolic vector variable.

https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.shape.html#shape

That would be equivalent to our variable.type.shape (static shape).

However they mention it is okay to return a custom type as long as it behaves like a tuple. Our shape does because you can iter/index/tuplify it just fine, so it may be fine?

It seems dangerous to change the behavior of .shape. Opened an issue: data-apis/array-api#891

@ricardoV94
Copy link
Member Author

Also I suspect the verification suite is not compatible with lazy backends right now, but it's worth checking and opening an issue with them if not: https://data-apis.org/array-api/latest/verification_test_suite.html

It shouldn't be too hard to monkey-patch it for testing as we can build graphs or constants just fine, and dispatch asarray to be x.eval()

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

No branches or pull requests

1 participant