#include <sstream>#include <string>#include "OptimizerConfig.pb.h"#include "paddle/utils/Logging.h"#include "tensor.h"namespacepaddle{namespaceoptimizer{staticvoidTensorToProto(constTensor&tensor,TensorProto*proto){proto->set_data_type(TensorProto::PADDLE_ELEMENT_TYPE_FLOAT32);proto->set_size(tensor.size());std::stringstreamos;for(size_ti=0;i<tensor.size();++i){os<<tensor[i];proto->add_content(os.str());os.clear();}}staticvoidProtoToTensor(constTensorProto&proto,Tensor*tensor){CHECK(proto.size()==tensor->size())<<"unmatch shape of proto and tensor";std::stringstreamsin;for(autoi=0;i<proto.content_size();++i){sin<<proto.content(i);sin>>(*tensor)[i];sin.clear();}}}// namespace optimizer}// namespace paddle