Fix dimension mismatching for transpose.