mirror of
https://github.com/ml-explore/mlx.git
synced 2025-07-05 00:31:15 +08:00
Fix Metal API validation for empty concat (#1183)
This commit is contained in:
parent
375a8bbdcc
commit
83b11bc58d
@ -33,9 +33,6 @@ void copy_gpu(const array& in, array& out, CopyType ctype, const Stream& s) {
|
|||||||
} else {
|
} else {
|
||||||
out.set_data(allocator::malloc_or_wait(out.nbytes()));
|
out.set_data(allocator::malloc_or_wait(out.nbytes()));
|
||||||
}
|
}
|
||||||
if (out.size() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (ctype == CopyType::GeneralGeneral) {
|
if (ctype == CopyType::GeneralGeneral) {
|
||||||
ctype = CopyType::General;
|
ctype = CopyType::General;
|
||||||
}
|
}
|
||||||
@ -57,6 +54,10 @@ void copy_gpu_inplace(
|
|||||||
int64_t out_offset,
|
int64_t out_offset,
|
||||||
CopyType ctype,
|
CopyType ctype,
|
||||||
const Stream& s) {
|
const Stream& s) {
|
||||||
|
if (out.size() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Try to collapse contiguous dims
|
// Try to collapse contiguous dims
|
||||||
auto [shape, strides] = collapse_contiguous_dims(
|
auto [shape, strides] = collapse_contiguous_dims(
|
||||||
data_shape, std::vector{strides_in_pre, strides_out_pre});
|
data_shape, std::vector{strides_in_pre, strides_out_pre});
|
||||||
|
@ -1533,6 +1533,12 @@ class TestOps(mlx_tests.MLXTestCase):
|
|||||||
b = mx.array([1, 2])
|
b = mx.array([1, 2])
|
||||||
mx.concatenate([a, b], axis=0)
|
mx.concatenate([a, b], axis=0)
|
||||||
|
|
||||||
|
# Cocnatenate with 0-sized array
|
||||||
|
a = mx.zeros((2, 0, 2))
|
||||||
|
b = mx.zeros((2, 2, 2))
|
||||||
|
out = mx.concatenate([a, b], axis=1)
|
||||||
|
self.assertTrue(mx.array_equal(out, b))
|
||||||
|
|
||||||
def test_meshgrid(self):
|
def test_meshgrid(self):
|
||||||
x = mx.array([1, 2, 3], dtype=mx.int32)
|
x = mx.array([1, 2, 3], dtype=mx.int32)
|
||||||
y = np.array([1, 2, 3], dtype=np.int32)
|
y = np.array([1, 2, 3], dtype=np.int32)
|
||||||
|
Loading…
Reference in New Issue
Block a user