diff --git a/paddle/fluid/framework/device_worker.cc b/paddle/fluid/framework/device_worker.cc index 579a693503cda..181db5320d7fd 100644 --- a/paddle/fluid/framework/device_worker.cc +++ b/paddle/fluid/framework/device_worker.cc @@ -93,8 +93,7 @@ void PrintLodTensorType(phi::DenseTensor* tensor, char separator, bool need_leading_separator, int num_decimals) { - std::string buf; - buf.resize(MAX_FLOAT_BUFF_SIZE); + char buf[MAX_FLOAT_BUFF_SIZE]; // NOLINT auto count = tensor->numel(); if (start < 0 || end > count) { VLOG(3) << "access violation"; @@ -109,7 +108,7 @@ void PrintLodTensorType(phi::DenseTensor* tensor, out_val += "0"; } else { std::string format = "%." + std::to_string(num_decimals) + "f"; - sprintf(&buf[0], &format[0], tensor->data()[i]); // NOLINT + sprintf(buf, &format[0], tensor->data()[i]); // NOLINT out_val += buf; } }