MCPcopy Create free account
hub / github.com/OpenPPL/ppl.nn / SaveInputsAllInOne

Function SaveInputsAllInOne

samples/cpp/others/pplnn_multi_numa_node.cc:562–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

560}
561
562static 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
589static bool SaveOutputsOneByOne(const Runtime* runtime) {
590 for (uint32_t c = 0; c < runtime->GetOutputCount(); ++c) {

Callers 1

RunOnNumaNodeFunction · 0.70

Calls 4

GetInputTensorMethod · 0.80
GetInputCountMethod · 0.45
GetShapeMethod · 0.45
ConvertToHostMethod · 0.45

Tested by

no test coverage detected