diff --git a/mlx/backend/metal/custom_kernel.cpp b/mlx/backend/metal/custom_kernel.cpp index 66f75a65f..e775f6798 100644 --- a/mlx/backend/metal/custom_kernel.cpp +++ b/mlx/backend/metal/custom_kernel.cpp @@ -15,10 +15,11 @@ void CustomKernel::eval_gpu( std::vector copies; for (auto& out : outputs) { - out.set_data(allocator::malloc_or_wait(out.nbytes())); if (init_value_) { copies.emplace_back(init_value_.value(), out.dtype()); fill_gpu(copies.back(), out, s); + } else { + out.set_data(allocator::malloc_or_wait(out.nbytes())); } }