Fixes output donation for IO ops on the GPU (#1857)

This commit is contained in:
Angelos Katharopoulos
2025-02-12 10:52:30 -08:00
committed by GitHub
parent 0a5215693e
commit 0145911bea
7 changed files with 92 additions and 16 deletions

View File

@@ -69,4 +69,19 @@ void concatenate(std::string& acc, T first, Args... args) {
concatenate(acc, args...);
}
/**
* Get a new array that refers to the same data but has a non-owning pointer to
* them.
*/
inline array unsafe_weak_copy(const array& x) {
return array(
x.buffer(),
x.shape(),
x.dtype(),
x.strides(),
x.data_size(),
x.flags(),
[](auto b) {});
}
} // namespace mlx::core