in Tools/WinMLRunner/src/OutputHelper.cpp [568:677]
void OutputHelper::WritePerIterationPerformance(const CommandLineArgs& args, const std::wstring model,
const std::wstring imagePath)
{
if (m_csvFileNamePerIterationSummary.length() > 0)
{
bool bNewFile = false;
std::ifstream fin;
fin.open(m_csvFileNamePerIterationSummary);
std::filebuf* outbuf = fin.rdbuf();
if (EOF == outbuf->sbumpc())
{
bNewFile = true;
}
fin.close();
std::ofstream fout;
fout.open(m_csvFileNamePerIterationSummary, std::ios_base::app);
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
std::string modelName = converter.to_bytes(model);
std::string fileNameResultDevice = converter.to_bytes(m_fileNameResultDevice);
std::string inputName = args.IsCSVInput() ? converter.to_bytes(args.CsvPath())
: args.IsImageInput() ? converter.to_bytes(imagePath) : "";
if (bNewFile)
{
if (args.IsPerIterationCapture())
{
fout << "Model Name"
<< ","
<< "Input Name"
<< ","
<< "Iterations"
<< ","
<< "Iteration Number "
<< ","
<< "CPU Working Set Diff (MB)"
<< ","
<< "CPU Working Set Start (MB)"
<< ","
<< "GPU Shared Memory Diff (MB)"
<< ","
<< "GPU Shared Memory Start (MB)"
<< ","
<< "GPU Dedicated Memory Diff (MB)"
<< ","
<< "Load (ms)"
<< ","
<< "Bind (ms)"
<< ","
<< "Evaluate (ms)"
<< ",";
if (args.IsSaveTensor())
{
fout << "Result"
<< ","
<< "OutputTensorHash"
<< ","
<< "FileName";
}
}
else if (args.IsSaveTensor())
{
fout << "Iteration Number"
<< ","
<< "Result"
<< ","
<< "OutputTensorHash"
<< ","
<< "FileName";
}
fout << std::endl;
}
if (args.IsPerIterationCapture())
{
for (uint32_t i = 0; i < args.NumIterations(); i++)
{
fout << modelName << "," << inputName << "," << args.NumIterations() << "," << i + 1 << ","
<< m_CPUWorkingDiff[i] << "," << m_CPUWorkingStart[i] << "," << m_GPUSharedDiff[i] << ","
<< m_GPUSharedStart[i] << "," << m_GPUDedicatedDiff[i] << "," << m_clockLoadTimes[i] << ","
<< m_clockBindTimes[i] << "," << m_clockEvalTimes[i] << ",";
if (args.IsSaveTensor() &&
(args.SaveTensorMode() == L"All" || (args.SaveTensorMode() == L"First" && i == 0)))
{
fout << m_outputResult[i] << "," << m_outputTensorHash[i] << ","
<< fileNameResultDevice + std::to_string(i + 1) + ".csv"
<< ",";
}
fout << std::endl;
}
}
else if (args.IsSaveTensor())
{
for (uint32_t i = 0; i < args.NumIterations(); i++)
{
fout << i + 1 << "," << m_outputResult[i] << "," << m_outputTensorHash[i] << ","
<< fileNameResultDevice + std::to_string(i + 1) + ".csv" << std::endl;
if (args.SaveTensorMode() == L"First" && i == 0)
{
break;
}
}
}
fout.close();
}
}