| 243 | } |
| 244 | |
| 245 | void 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 | |
| 274 | void DeviceWorker::InitRandomDumpConfig(const TrainerDesc& desc) { |
| 275 | bool is_dump_in_simple_mode = desc.is_dump_in_simple_mode(); |
nothing calls this directly
no test coverage detected