mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 01:50:16 +08:00
Fix view scalar bug segfault (#1603)
* fix view scalar bug * fix view scalar bug * one more fix
This commit is contained in:
@@ -606,7 +606,7 @@ void View::eval_cpu(const std::vector<array>& inputs, array& out) {
|
||||
if (ibytes == obytes || obytes < ibytes && in.strides().back() == 1 ||
|
||||
in.flags().row_contiguous) {
|
||||
auto strides = in.strides();
|
||||
for (int i = 0; i < strides.size() - 1; ++i) {
|
||||
for (int i = 0; i < static_cast<int>(strides.size()) - 1; ++i) {
|
||||
strides[i] *= ibytes;
|
||||
strides[i] /= obytes;
|
||||
}
|
||||
|
@@ -417,7 +417,7 @@ void View::eval_gpu(const std::vector<array>& inputs, array& out) {
|
||||
if (ibytes == obytes || obytes < ibytes && in.strides().back() == 1 ||
|
||||
in.flags().row_contiguous) {
|
||||
auto strides = in.strides();
|
||||
for (int i = 0; i < strides.size() - 1; ++i) {
|
||||
for (int i = 0; i < static_cast<int>(strides.size()) - 1; ++i) {
|
||||
strides[i] *= ibytes;
|
||||
strides[i] /= obytes;
|
||||
}
|
||||
|
@@ -4587,7 +4587,7 @@ array view(const array& a, const Dtype& dtype, StreamOrDevice s /* = {} */) {
|
||||
" axis must be a multiple of the requested type size.");
|
||||
}
|
||||
out_shape.back() /= (obytes / ibytes);
|
||||
} else {
|
||||
} else if (ibytes > obytes) {
|
||||
// Type size ratios are always integers
|
||||
out_shape.back() *= (ibytes / obytes);
|
||||
}
|
||||
|
Reference in New Issue
Block a user