Replies: 2 comments
-
Maybe this is a non-issue for swift developers if there's no expectation that swift developers would ever have to index/slice arrays. And maybe C++ developers who are implementing NN layers are accustomed to not having nice things such as python's array indexing/slicing functionality. |
Beta Was this translation helpful? Give feedback.
0 replies
-
https://github.com/python/cpython/blob/main/Objects/sliceobject.c |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
It's not clear to me how we can provide to C++ or Swift developers the same convenience which is provided to python developers.
For example, in this code from positional_encoding.py, there are several uses of array indexing/slicing which can be conveniently expressed in python but probably not so conveniently in C++ or Swift:
It seems that the python compiler provides special help in generating indexing/slicing objects from indexing/slicing expressions so that the MLX python/C++ stubs can have signatures such as:
array mlx_get_item(const array& src, const py::object& obj) { ... }
and
void mlx_set_item(array& src, const py::object& obj, const ScalarOrArray& v) { ... }
Absent similar help from the C++ compiler and the Swift compiler, it seems that developers will end up having to author calls to functions such as
scatter
rather than enjoy the convenience of indexing/slicing and the pile of supporting logic which is contained in indexing.cpp. That is what I'm struggling with while attempting to implement a C++ version of that python _compute_rope function.Has anybody already figured this out? If so, I hope that they will share C++ or Swift equivalents of the _compute_rope logic above.
Beta Was this translation helpful? Give feedback.
All reactions