| 560 | } |
| 561 | |
| 562 | static bool SaveInputsAllInOne(const Runtime* runtime) { |
| 563 | const string in_file_name = g_flag_save_data_dir + "/pplnn_input.dat"; |
| 564 | ofstream ofs(in_file_name, ios_base::out | ios_base::binary | ios_base::trunc); |
| 565 | if (!ofs.is_open()) { |
| 566 | LOG(ERROR) << "open file[" << in_file_name << "] failed."; |
| 567 | return false; |
| 568 | } |
| 569 | |
| 570 | for (uint32_t c = 0; c < runtime->GetInputCount(); ++c) { |
| 571 | auto t = runtime->GetInputTensor(c); |
| 572 | auto bytes = t->GetShape()->CalcBytesIncludingPadding(); |
| 573 | vector<char> buffer(bytes); |
| 574 | |
| 575 | TensorShape src_desc = *t->GetShape(); |
| 576 | src_desc.SetDataFormat(DATAFORMAT_NDARRAY); |
| 577 | auto status = t->ConvertToHost((void*)buffer.data(), src_desc); |
| 578 | if (status != RC_SUCCESS) { |
| 579 | LOG(ERROR) << "convert data failed: " << GetRetCodeStr(status); |
| 580 | return false; |
| 581 | } |
| 582 | |
| 583 | ofs.write(buffer.data(), bytes); |
| 584 | } |
| 585 | |
| 586 | return true; |
| 587 | } |
| 588 | |
| 589 | static bool SaveOutputsOneByOne(const Runtime* runtime) { |
| 590 | for (uint32_t c = 0; c < runtime->GetOutputCount(); ++c) { |
no test coverage detected