MCPcopy Create free account
hub / github.com/ml-explore/mlx-data / PyBufferIterator

Class PyBufferIterator

python/src/wrap_buffer.cpp:14–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13namespace {
14class PyBufferIterator {
15 public:
16 PyBufferIterator(Buffer& buffer)
17 : buffer_(buffer), iter_(0), size_(buffer.size()) {};
18 py::dict next() {
19 if (iter_ >= size_) {
20 throw py::stop_iteration();
21 } else {
22 Sample res;
23 {
24 py::gil_scoped_release release;
25 res = buffer_.get(iter_++);
26 }
27 return mlx::pybind::to_py_sample(res);
28 }
29 };
30 Buffer buffer_;
31 int64_t iter_;
32 int64_t size_;
33};
34} // namespace
35namespace py = pybind11;
36using namespace mlx::data;

Callers 1

init_mlx_data_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected