mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
int() and float() for mx.array (#1360)
This commit is contained in:
@@ -160,6 +160,10 @@ nb::ndarray<> mlx_to_dlpack(const array& a) {
|
||||
}
|
||||
|
||||
nb::object to_scalar(array& a) {
|
||||
if (a.size() != 1) {
|
||||
throw std::invalid_argument(
|
||||
"[convert] Only length-1 arrays can be converted to Python scalars.");
|
||||
}
|
||||
{
|
||||
nb::gil_scoped_release nogil;
|
||||
a.eval();
|
||||
|
||||
Reference in New Issue
Block a user