Correct the exception to avoid adapting matrix shape when both has the same shape.