add support for tile
Proposed changes
np.tile function in mlx as a op mlx.core.tile
Checklist
Put an x in the boxes that apply.
- [x] I have read the CONTRIBUTING document
- [x] I have run
pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes - [x] I have added tests that prove my fix is effective or that my feature works
- [x] I have updated the necessary documentation (if needed)
@angeloskath Hey, Happy new year 🎉. sorry if my first implementation is not up for the standards, tho I must say that it is almost the same implementation as numpy. tho, I went back and tried this implementation and hacked together this code using your idea, the below code is just a prototype, to take your approval to proceed.
def tile(arr, repeats):
d = len(repeats)
if d < arr.ndim:
repeats = [1] * (arr.ndim - d) + repeats
else:
arr = np.expand_dims(arr, axis=tuple(range(d - arr.ndim)))
for i, rep in enumerate(repeats):
if rep != 1:
arr = np.expand_dims(arr, axis=i)
arr = np.broadcast_to(arr, arr.shape[:i] + (rep,) + arr.shape[i+1:])
arr = np.reshape(arr, arr.shape[:i] + (-1,) + arr.shape[i+2:])
return arr
Note: I change the implementation code to match python code.
is this pr stale ?
Sorry, I haven't had the chance to get back to this, I think did what is required @dc-dc-dc . I will close this and look for more in the future.