Allow querying the allocator for the buffer size (#1404)

This commit is contained in:
Angelos Katharopoulos
2024-09-11 21:02:16 -07:00
committed by GitHub
parent 8b30acd7eb
commit 881f09b2e2
10 changed files with 42 additions and 13 deletions

View File

@@ -155,4 +155,11 @@ inline auto check_contiguity(
no_broadcast_data_size, is_row_contiguous, is_col_contiguous);
}
inline bool is_donatable(const array& in, const array& out) {
constexpr size_t donation_extra = 16384;
return in.is_donatable() && in.itemsize() == out.itemsize() &&
in.buffer_size() <= out.nbytes() + donation_extra;
}
} // namespace mlx::core