MKLDNN dims2str & dim2str Code Clean
Created by: luotao1
There are similar dims2str
and dim2str
functions in each xxx_mkldnn_op.cc
:
$ grep -rn "dims2str" *
paddle/fluid/operators/mkldnn/batch_norm_mkldnn_op.cc:117: auto dims2str = [](const memory::dims &operand_dims) {
paddle/fluid/operators/mkldnn/batch_norm_mkldnn_op.cc:124: return dims2str(input_dims) + std::to_string(epsilon) +
paddle/fluid/platform/mkldnn_reuse.h:212: return dims2str(operand_dims) + suffix;
paddle/fluid/platform/mkldnn_reuse.h:259: static std::string dims2str(const mkldnn::memory::dims& operand_dims) {
paddle/fluid/platform/mkldnn_reuse.h:883: return dims2str(shape) + dims2str(axis) + suffix;
paddle/fluid/platform/mkldnn_reuse.h:989: return dims2str(shape) + std::to_string(in_fmt) + "->" +
paddle/fluid/platform/mkldnn_reuse.h:1336: return dims2str(input_dims) + dims2str(weights_dims) +
paddle/fluid/platform/mkldnn_reuse.h:1338: dims2str(strides) + dims2str(paddings) + dims2str(dilations) +
paddle/fluid/platform/mkldnn_reuse.h:1350: return dims2str(input_dims) + dims2str(weights_dims) + dims2str(strides) +
paddle/fluid/platform/mkldnn_reuse.h:1351: dims2str(paddings) + dims2str(dilations) + std::to_string(groups) +
$ grep -rn "dim2str" *
paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc:337: auto dim2str = [](const DDim &operand_dims) {
paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc:347: dim2str(input_x->dims()) +
paddle/fluid/operators/mkldnn/mul_mkldnn_op.cc:350: dim2str(input_y->dims()) + suffix;
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc:33: auto dim2str = [](const mkldnn::memory::dims &operand_dims) {
paddle/fluid/operators/mkldnn/activation_mkldnn_op.cc:40: return dim2str(operand_dims) + std::to_string(algorithm);
paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc:226: auto dim2str = [](const DDim& operand_dims) {
paddle/fluid/operators/mkldnn/fc_mkldnn_op.cc:233: return std::to_string((unsigned)input->format()) + dim2str(weights->dims()) +
Could you unify them? @jczaja @bingyanghuang