Skip to content

Add simple example of running with different frameworks in the README #88

Open
@djl11

Description

@djl11

While the NumPy tests need to be run like so

import numpy.array_api as array_module

array_api is not an attribute of other modules such as torch or tensorflow. Presumable these should be run like so:

import torch as array_module

import tensorflow as array_module

A couple of sentences stating this in the README might be helpful? Otherwise if they are not officially supported yet (I noticed there is only a github workflow for numpy), then maybe stating this in the README would be helpful? It isn't immediately obvious to me how I should run these tests for different backend frameworks. Any help appreciated!

Activity

asmeurer

asmeurer commented on Jan 25, 2022

@asmeurer
Member

It should work to use ARRAY_API_TESTS_MODULE=torch, or import torch as array_module if you are inserting the code in _array_module.py.

Note that for torch and some other libraries that don't yet have very good compliance, you may have to write some simple wrappers to implement basic functions that are required for the test suite to work (e.g., no tests can run if asarray isn't implemented).

honno

honno commented on Jan 25, 2022

@honno
Member

Also worth noting there is still uncertainty for some libraries in what namespace they'll publicly adopt the spec with (e.g. top-level like pytorch vs submodule like numpy.array_api). Think an example for all adopters is a good idea though—sometime after a spec release and more stability regarding namespaces.

(Ideally entry points mitigates having to hard-document things, but for now that's opt-in. I imagine I'll add support for entry points for the test suite once a library other than NumPy adopts it.)

djl11

djl11 commented on Jan 26, 2022

@djl11
Author

Thanks both for these very helpful comments. This all makes sense. Yes I agree this maybe becomes more important once more frameworks have better compliance. I'll leave this open for now but feel free to close.

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Add simple example of running with different frameworks in the README · Issue #88 · data-apis/array-api-tests