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

BUG: full_like and full accept array fill_value #55

Open
lucascolley opened this issue Aug 8, 2024 · 8 comments
Open

BUG: full_like and full accept array fill_value #55

lucascolley opened this issue Aug 8, 2024 · 8 comments
Labels
blocked by upstream A feature that requires better upstream support Medium Priority

Comments

@lucascolley
Copy link
Member

lucascolley commented Aug 8, 2024

In [1]: import array_api_strict as xp

In [2]: xp.full_like(xp.asarray(0), xp.asarray(1))
Out[2]: Array(1, dtype=array_api_strict.int64)

Spec:

fill_value (Union[bool, int, float, complex]) – fill value.
@asmeurer
Copy link
Member

asmeurer commented Aug 8, 2024

This seems like it should be fixed in the standard. Getting a fill value from an array seems like it wouldn't be uncommon.

@kgryte
Copy link

kgryte commented Aug 8, 2024

Torch only accepts a scalar in full and full_like. To update the standard, I'd want to see upstream support added first.

@lucascolley
Copy link
Member Author

Dask also throws a FutureWarning since its implementation uses np.copyto, which it says may stop working with dask arrays in the future.

@ev-br ev-br added the blocked by upstream A feature that requires better upstream support label Feb 4, 2025
@crusaderky
Copy link
Contributor

xp.full has the same issue.

@lucascolley lucascolley changed the title BUG: full_like accepts array fill_value BUG: full_like and full accept array fill_value Mar 18, 2025
@lucascolley
Copy link
Member Author

@ev-br is this issue blocked by upstream? I know it sounds like we want to add this behaviour to the standard, but until it is added, can't we remove it from array-api-strict?

@ev-br
Copy link
Member

ev-br commented Mar 18, 2025

Yes, exactly. If it's going to be standardized soon, do we want the churn of removing it now and readding it back?
Re adding it to the standard: I think it makes total sense. Without it, one needs something like full(zeroD_array.item()), which causes a device synchronization for a GPU backend.

@lucascolley
Copy link
Member Author

If it's going to be standardized soon

Do you know if there is any progress on the PyTorch side?

@ev-br
Copy link
Member

ev-br commented Mar 18, 2025

Sadly, no, I don't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by upstream A feature that requires better upstream support Medium Priority
Projects
None yet
Development

No branches or pull requests

5 participants