Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlx/backend/metal/kernels/gemv_masked.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ struct GEMVTKernel {
const int n_block_idx = blockM > blockN ? out_col / blockM : int(tid.x);

const int out_mask_offset =
!has_output_mask ? 0 : n_block_idx; // * out_mask_strides[0];
!has_output_mask ? 0 : n_block_idx * out_mask_strides[0];

int mat_mask_offset =
!has_operand_mask ? 0 : n_block_idx * mat_mask_strides[0];
Expand Down
9 changes: 9 additions & 0 deletions python/tests/test_blas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,15 @@ def test_shape(
self.assertTrue(np.allclose(c_mx, c_np, atol=1e-5))
self.assertTrue(np.allclose(e_mx, e_np, atol=1e-5))

# Strided output mask with a vector lhs
a = mx.random.normal((1, 64))
b = mx.random.normal((64, 128))
mask = mx.array([[True, False, False, True, True, False, False, True]])
out_mask = mask[:, ::2]
out = mx.block_masked_mm(a, b, 32, out_mask)
expected = ref_block_masked_mm(a, b, 32, out_mask)
self.assertTrue(mx.allclose(out, expected, atol=1e-5))

def test_gather_matmul(self):
def np_gather_mm(a, b, lhs_indices=None, rhs_indices=None):
a = a.reshape((-1, a.shape[-2], a.shape[-1]))
Expand Down
Loading