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

Method write

python/src/load.cpp:378–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376 }
377
378 void write(const char* data, size_t n) override {
379 nb::gil_scoped_acquire gil;
380
381 nb::object memview = nb::steal<nb::object>(
382 PyMemoryView_FromMemory(const_cast<char*>(data), n, PyBUF_READ));
383 if (!memview.is_valid()) {
384 throw std::runtime_error("[load] Failed to create memoryview for write");
385 }
386 nb::object bytes_written = write_func_(memview);
387
388 if (bytes_written.is_none() || nb::cast<size_t>(bytes_written) < n) {
389 throw std::runtime_error("[load] Failed to write to python stream");
390 }
391 }
392
393 std::string label() const override {
394 return "python file object";

Callers 3

_thread_fnFunction · 0.45
_launch_with_ioFunction · 0.45
test_load_f8_e4m3Method · 0.45

Calls

no outgoing calls

Tested by 1

test_load_f8_e4m3Method · 0.36