mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
Print exceptions in eval_cpu/eval_gpu and abort (#1754)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Copyright © 2023 Apple Inc.
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
@@ -62,6 +63,13 @@ PrintFormatter& get_global_formatter() {
|
||||
return formatter;
|
||||
}
|
||||
|
||||
void abort_with_exception(const std::exception& error) {
|
||||
std::ostringstream msg;
|
||||
msg << "Terminating due to uncaught exception: " << error.what();
|
||||
std::cerr << msg.str() << std::endl;
|
||||
std::abort();
|
||||
}
|
||||
|
||||
Dtype result_type(const std::vector<array>& arrays) {
|
||||
Dtype t = bool_;
|
||||
for (auto& arr : arrays) {
|
||||
|
||||
Reference in New Issue
Block a user