1919#include < mlx/mlx.h>
2020
2121#include < cstring>
22- #include < iostream>
2322#include < limits>
2423#include < memory>
2524#include < mutex>
@@ -209,18 +208,14 @@ class MLXBackend final : public ::executorch::runtime::BackendInterface {
209208 }
210209
211210 try {
212- std::cerr << " MLX init: constructing handle" << std::endl;
213211 new (handle) MLXHandle ();
214- std::cerr << " MLX init: handle constructed" << std::endl;
215212
216213 if (!processed || !processed->data () || processed->size () == 0 ) {
217214 throw std::runtime_error (" init: null or empty delegate payload" );
218215 }
219216
220- std::cerr << " MLX init: parsing delegate payload" << std::endl;
221217 handle->program = loader::load_program (
222218 static_cast <const uint8_t *>(processed->data ()), processed->size ());
223- std::cerr << " MLX init: delegate payload parsed" << std::endl;
224219
225220 // Validate schema version
226221 int schema_version = 1 ;
@@ -248,34 +243,27 @@ class MLXBackend final : public ::executorch::runtime::BackendInterface {
248243 // runtime
249244 const runtime::NamedDataMap* named_data_map =
250245 context.get_named_data_map ();
251- std::cerr << " MLX init: loading constants" << std::endl;
252246 load_constants (
253247 handle->program ,
254248 named_data_map,
255249 handle->constants ,
256250 handle->constant_buffers );
257- std::cerr << " MLX init: constants loaded" << std::endl;
258251
259252 // Delegate payload no longer needed after constants are loaded
260253 processed->Free ();
261254 processed = nullptr ;
262255
263256 // Load mutable buffers (e.g., KV cache)
264- std::cerr << " MLX init: loading mutable buffers" << std::endl;
265257 load_mutable_buffers (handle->program , handle->mutable_buffers );
266- std::cerr << " MLX init: mutable buffers loaded" << std::endl;
267258
268259 // Bind execution state (reused across execute() calls)
269- std::cerr << " MLX init: binding execution state" << std::endl;
270260 handle->state .bind (
271261 handle->program , handle->constants , handle->mutable_buffers );
272- std::cerr << " MLX init: execution state bound" << std::endl;
273262
274263 // Run init chain if present.
275264 // SAFETY: The >= 0 check ensures init_chain_idx is non-negative, so the
276265 // static_cast<uint32_t> cannot produce UINT32_MAX from a -1 sentinel.
277266 if (handle->program .init_chain_idx >= 0 ) {
278- std::cerr << " MLX init: running init chain" << std::endl;
279267 handle->state .is_init_chain = true ;
280268 handle->interpreter .run_chain (
281269 handle->program ,
@@ -287,21 +275,17 @@ class MLXBackend final : public ::executorch::runtime::BackendInterface {
287275 // Evaluate any constants written by the init chain so the first
288276 // execute() doesn't pay the cost of materializing them.
289277 eval (handle->constants .tensors );
290- std::cerr << " MLX init: init chain complete" << std::endl;
291278 }
292279
293280 } catch (const std::exception& e) {
294281 ET_LOG (Error, " Failed to load MLX program: %s" , e.what ());
295- std::cerr << " Failed to load MLX program: " << e.what () << std::endl;
296282 handle->~MLXHandle ();
297283 if (processed != nullptr ) {
298284 processed->Free ();
299285 }
300286 return Error::InvalidProgram;
301287 } catch (...) {
302288 ET_LOG (Error, " Failed to load MLX program: unknown non-std exception" );
303- std::cerr << " Failed to load MLX program: unknown non-std exception"
304- << std::endl;
305289 handle->~MLXHandle ();
306290 if (processed != nullptr ) {
307291 processed->Free ();
@@ -437,12 +421,9 @@ class MLXBackend final : public ::executorch::runtime::BackendInterface {
437421 return Error::Ok;
438422 } catch (const std::exception& e) {
439423 ET_LOG (Error, " MLX execute failed: %s" , e.what ());
440- std::cerr << " MLX execute failed: " << e.what () << std::endl;
441424 return Error::Internal;
442425 } catch (...) {
443426 ET_LOG (Error, " MLX execute failed: unknown non-std exception" );
444- std::cerr << " MLX execute failed: unknown non-std exception"
445- << std::endl;
446427 return Error::Internal;
447428 }
448429 }
0 commit comments