when to get here? 1. gen_case_end when dump_data > 0
| 601 | // when to get here? |
| 602 | // 1. gen_case_end when dump_data > 0 |
| 603 | void PbNode::dumpOutputFile() { |
| 604 | int st = getOpNameMask(op_name_, op_name); |
| 605 | |
| 606 | // st <=0 means gen_case do not work on this op_name |
| 607 | if (st <= 0) return; |
| 608 | |
| 609 | for (int i = 0; i < tensors.size(); i++) { |
| 610 | if (!tensors[i].is_input) { |
| 611 | // sync queue to dump output if necessary |
| 612 | if (dump_data_output_) { |
| 613 | cnrtQueue_t queue; |
| 614 | mluOpGetQueue(handle, &queue); |
| 615 | if (cnrtSuccess != cnrtQueueSync(queue)) { |
| 616 | LOG(ERROR) << "[gen_case] syncQueue failed!"; |
| 617 | } else { |
| 618 | // TO DO : should consider malloc failure |
| 619 | std::string folder_name = getFolderName(); |
| 620 | std::string file_name = this->file_name; |
| 621 | uint64_t total_num = getTensorSize(i); |
| 622 | mluOpDataType_t dtype; |
| 623 | mluOpGetTensorDescriptor(tensors[i].desc, nullptr, &dtype, nullptr, |
| 624 | nullptr); |
| 625 | void *data = getDeviceData(i); |
| 626 | std::string dataState = "output"; |
| 627 | if (data != nullptr) { |
| 628 | std::string tensor_file_suffix = |
| 629 | file_name + "_data" + std::to_string(i) + "_" + dataState; |
| 630 | std::string tensor_file_name = |
| 631 | folder_name + "/" + tensor_file_suffix; |
| 632 | std::ofstream tensor_file; |
| 633 | tensor_file.open(tensor_file_name.c_str(), std::ios::binary); |
| 634 | tensor_file.write(reinterpret_cast<const char *>(data), |
| 635 | total_num * mluop::getSizeOfDataType(dtype)); |
| 636 | tensor_file.close(); |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | } |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | void PbNode::dumpToFile(bool valueDump) { |
| 645 | std::string folder_name = getFolderName(); |
no test coverage detected