Created by: jczaja
This is fix to situation when we want to use FLUID inference API with PaddlePaddle build with MKL-DNN support. Currently there is a crash. The reason for crash (according to my poor understanding of this part) is that we Have Variable::holder_ which is casted into Tensor. It seems intension is to cast into Tensor->holder_ . Example of copying, followed by function that return Variable::holder_:
Casting into Tensor may work as long as Address of Tensor->holder_ and Tensor do match. For MKLDNN build they do not as there is additional (under ifdef) attribute: mkldnn::memory::format format_ = mkldnn::memory::format::format_undef; This additional attribute makes assumption Tensor == Tensor->holder_ false (Layout of Tensor class is different) so Tensor->holder_ is holding broken data after assignment like this: Tensor t = v->GetMutable();*
Some more information is here: https://github.com/luotao1/fluid_inference_example/issues/1