I don’t think these are doing the same computation.
You can see this by changing the shape of you matrices so that they’re not all the same (but still match the mm) and you’ll see that your function does not return something on the shape of A.