Created by: wangkuiyi
This PR depends on https://github.com/PaddlePaddle/Paddle/pull/1253.
Fixes https://github.com/PaddlePaddle/Paddle/issues/1264.