MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / DumpParam

Method DumpParam

paddle/fluid/framework/device_worker.cc:245–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245void DeviceWorker::DumpParam(const Scope& scope, const int batch_id) {
246 std::ostringstream os;
247 int device_id =
248 static_cast<int>(static_cast<unsigned char>(place_.GetDeviceId()));
249 for (auto& param : *dump_param_) {
250 os.str("");
251 Variable* var = scope.FindVar(param);
252 if (var == nullptr || !var->IsInitialized()) {
253 continue;
254 }
255 if (!var->IsType<DenseTensor>()) {
256 continue;
257 }
258 phi::DenseTensor* tensor = var->GetMutable<DenseTensor>();
259 if (tensor == nullptr || !tensor->IsInitialized()) {
260 continue;
261 }
262 DenseTensor cpu_tensor;
263 if (phi::is_gpu_place(tensor->place())) {
264 TensorCopySync(*tensor, CPUPlace(), &cpu_tensor);
265 tensor = &cpu_tensor;
266 }
267 int64_t len = tensor->numel();
268 os << "(" << device_id << "," << batch_id << "," << param << ")"
269 << PrintDenseTensor(tensor, 0, len);
270 writer_ << os.str();
271 }
272}
273
274void DeviceWorker::InitRandomDumpConfig(const TrainerDesc& desc) {
275 bool is_dump_in_simple_mode = desc.is_dump_in_simple_mode();

Callers

nothing calls this directly

Calls 10

is_gpu_placeFunction · 0.85
PrintDenseTensorFunction · 0.85
TensorCopySyncFunction · 0.70
CPUPlaceClass · 0.50
GetDeviceIdMethod · 0.45
strMethod · 0.45
FindVarMethod · 0.45
IsInitializedMethod · 0.45
placeMethod · 0.45
numelMethod · 0.45

Tested by

no test coverage detected