improve error messaging in eval (#1101)

This commit is contained in:
Awni Hannun 2024-05-10 10:04:07 -07:00 committed by GitHub
parent 2e158cf6d0
commit a9f80d60f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -82,8 +82,15 @@ array eval_impl(std::vector<array> 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());