mirror of
https://github.com/ml-explore/mlx.git
synced 2025-11-02 01:08:10 +08:00
interruptable eval
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
// Copyright © 2023 Apple Inc.
|
||||
|
||||
#include "doctest/doctest.h"
|
||||
|
||||
#include "mlx/mlx.h"
|
||||
@@ -91,3 +90,16 @@ TEST_CASE("test eval graph retention when not tracing") {
|
||||
CHECK(!a.has_primitive());
|
||||
CHECK(a.is_available());
|
||||
}
|
||||
|
||||
TEST_CASE("test interrupt eval") {
|
||||
auto x = zeros({1024}, int32);
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
x = x + 1;
|
||||
}
|
||||
std::thread t([x]() { eval(x); });
|
||||
interrupt_eval();
|
||||
t.join();
|
||||
// Check that x is not evaluated
|
||||
CHECK(!x.is_available());
|
||||
CHECK(array_equal(x, full({1024}, 1000, int32)).item<bool>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user