Description
This came up in data-apis/array-api-compat#40.
My particular use case is something like this:
x.to_device("cpu")
to allow downstream library test suites to guarantee that an array is returned to host (or no-op if already there) for usage in i.e., assert_allclose(x, expected)
where expected
is a NumPy array (always on host) but x
could be on some other device depending on the array lib/backend.
I think specification to that level of detail is left to the libs at the moment. CuPy doesn't even have to_device()
at the moment let alone cpu
, instead requiring usage of i.e., arr.get()
to return to host, but even if they did, I'm not so sure the current array API spec would mandate that they need to allow cpu
as a valid argument.
Maybe the decision is that we can't really require that level of detail, in which case I can at least point to this issue when justifying shims to get around it when testing. If it were possible to mandate a common call signature for returning to host someday, hopefully the benefit of that would be fairly obvious re: testing multiple backends.