From a9f80d60f6ade25efd20fd9fa715ecb33ffeed38 Mon Sep 17 00:00:00 2001 From: Awni Hannun Date: Fri, 10 May 2024 10:04:07 -0700 Subject: [PATCH] improve error messaging in eval (#1101) --- mlx/transforms.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mlx/transforms.cpp b/mlx/transforms.cpp index 005402a98..5798dfffa 100644 --- a/mlx/transforms.cpp +++ b/mlx/transforms.cpp @@ -82,8 +82,15 @@ array eval_impl(std::vector outputs, bool async) { "[async_eval] Not allowed inside a graph transformation."); } if (!in.has_primitive()) { - throw std::invalid_argument( - "[eval] Attempting to eval an array without a primitive."); + if (in.is_tracer()) { + throw std::invalid_argument( + "[eval] Attempting to eval an array during function" + " transformations like compile or vmap is not allowed."); + } + throw std::runtime_error( + "[eval] Attempting to eval an array without a primitive. " + "This may be a bug, please file an issue here: " + " https://github.com/ml-explore/mlx/issues."); } if (a.primitive().stream() != in.primitive().stream()) { needs_signal.insert(in.id());