Moved MatMult shape consistency check to compute_value to avoid unnecessary calls