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

Use Py_ssize_t in python bindings #1678

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions python/src/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ std::string buffer_format(const array& a) {

struct buffer_info {
std::string format;
std::vector<ssize_t> shape;
std::vector<ssize_t> strides;
std::vector<Py_ssize_t> shape;
std::vector<Py_ssize_t> strides;

buffer_info(
std::string format,
std::vector<ssize_t> shape_in,
std::vector<ssize_t> strides_in)
std::vector<Py_ssize_t> shape_in,
std::vector<Py_ssize_t> strides_in)
: format(std::move(format)),
shape(std::move(shape_in)),
strides(std::move(strides_in)) {}
Expand Down Expand Up @@ -91,8 +91,8 @@ extern "C" inline int getbuffer(PyObject* obj, Py_buffer* view, int flags) {
a.eval();
}

std::vector<ssize_t> shape(a.shape().begin(), a.shape().end());
std::vector<ssize_t> strides(a.strides().begin(), a.strides().end());
std::vector<Py_ssize_t> shape(a.shape().begin(), a.shape().end());
std::vector<Py_ssize_t> strides(a.strides().begin(), a.strides().end());
for (auto& s : strides) {
s *= a.itemsize();
}
Expand Down
2 changes: 1 addition & 1 deletion python/src/indexing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ std::tuple<std::vector<array>, array, std::vector<int>> mlx_scatter_args_nd(
}

// Analyse the types of the indices
unsigned long max_dim = 0;
size_t max_dim = 0;
bool arrays_first = false;
int num_none = 0;
int num_slices = 0;
Expand Down