mlx icon indicating copy to clipboard operation
mlx copied to clipboard

'mlx.core.matmul/tensordot' do not support integer type matrix operations

Open Redempt1onzzZZ opened this issue 1 year ago • 3 comments

Describe the bug I found that mlx.core.matmul/tensordot do not support integer type matrix operations, but numpy does, and it is not stated in the mlx documentation that these two APIs do not support integer type operations

To Reproduce

Include code snippet

import mlx.core as mx
import numpy as np

a1 = np.array([[1, 2], [3, 4]])
b1 = np.array([[5, 6], [7, 8]])
npresult = np.tensordot(a1, b1)
print('numpy', npresult)

a = mx.array([[1, 2], [3, 4]])
b = mx.array([[5, 6], [7, 8]])
mlxresult = mx.tensordot(a, b)
print('mlx', mlxresult)

image

import mlx.core as mx
import numpy as np

a1 = np.array([[1, 2], [3, 4]])
b1 = np.array([[5, 6], [7, 8]])
npresult = np.matmul(a1, b1)
print('numpy', npresult)

a = mx.array([[1, 2], [3, 4]])
b = mx.array([[5, 6], [7, 8]])
mlxresult = mx.matmul(a, b)
print('mlx', mlxresult)

image

Desktop (please complete the following information):

  • OS Version: MacOS 14.2.1
  • Version 0.10.0
  • numpy 1.26.2

Additional context According to my inspection, only these two APIs were found to have this issue. I am not sure if there are other APIs that also have this issue. If it is the design of mlx itself, I think it can be explained in the documentation.

Redempt1onzzZZ avatar Jan 21 '24 08:01 Redempt1onzzZZ

This is not a huge priority for us since it's a decent amount of work for something which is not super useful. We can update the docs for now until someone has bandwidth to add it or makes a contribution.

awni avatar Jan 21 '24 14:01 awni