You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adding dtype parameter to creation methods like the zeroes_like and ones_like #4001
Hi, I have checked that the current implementation of like methods including zeros_like, ones_like and empty_like does not take dtype as parameter unlike non like methods zeros for example.
array zeros_like(const array &a, StreamOrDevice s = {})
I think adding dtype will make them array api compatible, I seemed like an simple addition, but I ran into issue that many internal methods that use them, use positional arguments which breaks the code and need much refactoring.
Similarly with the users there code can be broken too after this addition, a simple work around could be to add it after stream, which can avoid all that.
I just wanted to get your opinion on this before I made any changes.
changed the title [-]Adding dtype parameter to creation methods like the zeroes_like and one_like[/-][+]Adding dtype parameter to creation methods like the zeroes_like and ones_like[/+]on Aug 4, 2026
@aaishwarymishra there's already a full_like function which accepts dtype so just need to create some overloads with dtype argument for zeros_like and ones_like and forward them to full_like appropriately
There is still empty_like which does not have the dtype, Also I have noticed that empty and empty_like are implemented in the mlx but are not visible in the docs, it can be another area you can look at :)
Activity
[-]Adding dtype parameter to creation methods like the zeroes_like and one_like[/-][+]Adding dtype parameter to creation methods like the zeroes_like and ones_like[/+]zcbenz commentedon Aug 5, 2026
Sounds a good addition.
JasonHonKL commentedon Aug 6, 2026
@zcbenz @aaishwarymishra mind if i give this a try as my first issue in MLX ?
reckylurker commentedon Aug 6, 2026
@JasonHonKL I was already working on this :(
JasonHonKL commentedon Aug 6, 2026
Oh no. Then you take it. Is okay !
reckylurker commentedon Aug 6, 2026
@aaishwarymishra there's already a
full_likefunction which acceptsdtypeso just need to create some overloads withdtypeargument forzeros_likeandones_likeand forward them tofull_likeappropriatelyaaishwarymishra commentedon Aug 6, 2026
@JasonHonKL Hi, you can still help out :)
There is still
empty_likewhich does not have thedtype, Also I have noticed thatemptyandempty_likeare implemented in the mlx but are not visible in the docs, it can be another area you can look at :)JasonHonKL commentedon Aug 6, 2026
Sure I will do it later today !
zcbenz commentedon Aug 7, 2026
Closed by #4028.