Created by: luotao1
fix #8378 (closed) and https://github.com/PaddlePaddle/Paddle/pull/7977#pullrequestreview-94668927