forked from mindspore-Ecosystem/mindspore
writeresult coredump fix 20210706
This commit is contained in:
parent
45d3f32f9d
commit
b4573cba1c
|
@ -120,7 +120,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i], outputs);
|
||||
int rst = WriteResult(input0_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto input0_files = GetAllInputData(FLAGS_input0_path);
|
||||
|
@ -155,9 +159,13 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i][j], outputs);
|
||||
int rst = WriteResult(input0_files[i][j], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
using mindspore::MSTensor;
|
||||
using mindspore::DataType;
|
||||
|
||||
|
||||
std::vector<std::vector<std::string>> GetAllInputData(std::string dir_name) {
|
||||
std::vector<std::vector<std::string>> ret;
|
||||
|
||||
|
@ -102,6 +101,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -112,7 +113,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE *outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -180,7 +180,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -46,6 +46,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -56,7 +58,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,11 @@ int main(int argc, char **argv) {
|
|||
startTime_ms = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTime_ms = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTime_ms, endTime_ms));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int infer_cnt = 0;
|
||||
|
|
|
@ -63,6 +63,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -73,7 +75,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,6 @@ int main(int argc, char **argv) {
|
|||
std::cout << "ERROR: Build failed." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto all_files = GetAllFiles(FLAGS_dataset_path);
|
||||
std::map<double, double> costTime_map;
|
||||
size_t size = all_files.size();
|
||||
|
@ -149,16 +148,13 @@ int main(int argc, char **argv) {
|
|||
int n = NewWidth;
|
||||
netOutput++;
|
||||
while (n < FLAGS_image_width) {
|
||||
*netOutput = temp;
|
||||
netOutput++;
|
||||
n++;
|
||||
*netOutput = temp; netOutput++; n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<MSTensor> model_inputs = model.GetInputs();
|
||||
inputs.emplace_back(model_inputs[0].Name(), model_inputs[0].DataType(), model_inputs[0].Shape(),
|
||||
img.Data().get(), img.DataSize());
|
||||
img.Data().get(), img.DataSize());
|
||||
gettimeofday(&start, nullptr);
|
||||
ret = model.Predict(inputs, &outputs);
|
||||
gettimeofday(&end, nullptr);
|
||||
|
@ -169,11 +165,14 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
||||
for (auto iter = costTime_map.begin(); iter != costTime_map.end(); iter++) {
|
||||
double diff = 0.0;
|
||||
diff = iter->second - iter->first;
|
||||
|
|
|
@ -46,6 +46,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -56,7 +58,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,11 @@ int main(int argc, char **argv) {
|
|||
startTime_ms = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTime_ms = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTime_ms, endTime_ms));
|
||||
WriteResult(allFiles[i], outputs);
|
||||
int rst = WriteResult(allFiles[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int infer_cnt = 0;
|
||||
|
|
|
@ -46,6 +46,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -56,10 +58,21 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,11 @@ int main(int argc, char **argv) {
|
|||
startTime_ms = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTime_ms = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTime_ms, endTime_ms));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int infer_cnt = 0;
|
||||
|
|
|
@ -46,6 +46,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput = outputs[i].Data();
|
||||
|
@ -55,7 +57,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE *outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -195,7 +195,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -64,6 +64,8 @@ std::vector<std::string> GetImagesById(const std::string &idFile, const std::str
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -74,7 +76,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -130,7 +130,11 @@ int main(int argc, char **argv) {
|
|||
startTime_ms = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTime_ms = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTime_ms, endTime_ms));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int infer_cnt = 0;
|
||||
|
|
|
@ -46,6 +46,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput = outputs[i].Data();
|
||||
|
@ -55,7 +57,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE *outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,11 @@ int main(int argc, char **argv) {
|
|||
startTime_ms = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTime_ms = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTime_ms, endTime_ms));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int infer_cnt = 0;
|
||||
|
|
|
@ -63,6 +63,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -73,7 +75,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -120,7 +120,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i], outputs);
|
||||
int rst = WriteResult(input0_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto input0_files = GetAllInputData(FLAGS_input0_path);
|
||||
|
@ -155,9 +159,13 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i][j], outputs);
|
||||
int rst = WriteResult(input0_files[i][j], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
using mindspore::MSTensor;
|
||||
using mindspore::DataType;
|
||||
|
||||
|
||||
std::vector<std::vector<std::string>> GetAllInputData(std::string dir_name) {
|
||||
std::vector<std::vector<std::string>> ret;
|
||||
|
||||
|
@ -102,6 +101,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -112,7 +113,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE *outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -136,7 +136,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i], outputs);
|
||||
int rst = WriteResult(input0_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -45,6 +45,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -55,7 +57,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i], outputs);
|
||||
int rst = WriteResult(input0_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -45,6 +45,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -55,7 +57,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i], outputs);
|
||||
int rst = WriteResult(input0_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -45,6 +45,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -55,7 +57,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -120,7 +120,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(all_files[i], outputs);
|
||||
int rst = WriteResult(all_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
using mindspore::MSTensor;
|
||||
using mindspore::DataType;
|
||||
|
||||
|
||||
std::vector<std::vector<std::string>> GetAllInputData(std::string dir_name) {
|
||||
std::vector<std::vector<std::string>> ret;
|
||||
|
||||
|
@ -102,6 +101,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -112,7 +113,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName = fileName + '_' + std::to_string(i) + ".bin";
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE *outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,11 @@ int main(int argc, char **argv) {
|
|||
startTimeMs = (1.0 * start.tv_sec * 1000000 + start.tv_usec) / 1000;
|
||||
endTimeMs = (1.0 * end.tv_sec * 1000000 + end.tv_usec) / 1000;
|
||||
costTime_map.insert(std::pair<double, double>(startTimeMs, endTimeMs));
|
||||
WriteResult(input0_files[i], outputs);
|
||||
int rst = WriteResult(input0_files[i], outputs);
|
||||
if (rst != 0) {
|
||||
std::cout << "write result failed." << std::endl;
|
||||
return rst;
|
||||
}
|
||||
}
|
||||
double average = 0.0;
|
||||
int inferCount = 0;
|
||||
|
|
|
@ -45,6 +45,8 @@ std::vector<std::string> GetAllFiles(std::string_view dirName) {
|
|||
|
||||
int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outputs) {
|
||||
std::string homePath = "./result_Files";
|
||||
int INVALID_POINTER = -1;
|
||||
int ERROR = -2;
|
||||
for (size_t i = 0; i < outputs.size(); ++i) {
|
||||
size_t outputSize;
|
||||
std::shared_ptr<const void> netOutput;
|
||||
|
@ -55,7 +57,18 @@ int WriteResult(const std::string& imageFile, const std::vector<MSTensor> &outpu
|
|||
fileName.replace(fileName.find('.'), fileName.size() - fileName.find('.'), '_' + std::to_string(i) + ".bin");
|
||||
std::string outFileName = homePath + "/" + fileName;
|
||||
FILE * outputFile = fopen(outFileName.c_str(), "wb");
|
||||
fwrite(netOutput.get(), outputSize, sizeof(char), outputFile);
|
||||
if (outputFile == nullptr) {
|
||||
std::cout << "open result file " << outFileName << " failed" << std::endl;
|
||||
return INVALID_POINTER;
|
||||
}
|
||||
size_t size = fwrite(netOutput.get(), sizeof(char), outputSize, outputFile);
|
||||
if (size != outputSize) {
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
std::cout << "write result file " << outFileName << " failed, write size[" << size <<
|
||||
"] is smaller than output size[" << outputSize << "], maybe the disk is full." << std::endl;
|
||||
return ERROR;
|
||||
}
|
||||
fclose(outputFile);
|
||||
outputFile = nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue