diff --git a/mlx/compile.cpp b/mlx/compile.cpp index 6e0be94a8..34d122b06 100644 --- a/mlx/compile.cpp +++ b/mlx/compile.cpp @@ -1007,6 +1007,14 @@ std::function(const std::vector&)> compile( std::uintptr_t fun_id, bool shapeless /* = false */, std::vector constants /* = {} */) { + if (skip_compile()) { + return fun; + } + if (!fun) { + throw std::invalid_argument( + "[compile] Cannot compile a function without a target."); + } + ArrayFnWithExtra fun_with_extra = [fun = std::move(fun)](const std::vector& inputs) { return std::pair, std::shared_ptr>{