Skip to content

Commit f9847fa

Browse files
author
Ryan Lai
authored
Output more useful performance metrics from WinMLRunner's perf console output (#154)
* Separated performance metrics between first iteration and iterations after first iteration * Added checking to make sure iterations > 1 for printing performance results to csv * Changed readme * Changed -perf flag, description * Made change so that it doesn't process 'all' * Moved i++ to the correct location for commandline args
1 parent 9611084 commit f9847fa

File tree

6 files changed

+342
-83
lines changed

6 files changed

+342
-83
lines changed

Tools/WinMLRunner/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Required command-Line arguments:
2222
-folder <path> : Fully qualifed path to a folder with .onnx and/or .pb models, will run all of the models in the folder.
2323
2424
#Optional command-line arguments:
25-
-Perf : Captures GPU, CPU, and wall-clock time measurements.
25+
-Perf : optional:<all>: capture performance measurements such as timing and memory usage. Specifying "all" will output all measurements
2626
-Iterations <int> : Number of times to evaluate the model when capturing performance measurements.
2727
-CPU : Will create a session on the CPU.
2828
-GPU : Will create a session on the GPU.
@@ -38,7 +38,6 @@ Required command-Line arguments:
3838
-Tensor : Will load the input as a tensor.
3939
-Input <image/CSV path> : Will bind image/data from CSV to model.
4040
-PerfOutput <CSV path> : Path to the CSV where the perf results will be written.
41-
-IgnoreFirstRun : Will ignore the first run in the perf results when calculating the average
4241
-SavePerIterationPerf : Save per iteration performance results to csv file.
4342
-Debug : Will start a trace logging session.
4443
-Terse : Will suppress repetitive console output (initial iteration and summary info will be output).

Tools/WinMLRunner/src/CommandLineArgs.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ void CommandLineArgs::PrintUsage() {
2424
std::cout << " -RGB : load the input as an RGB image" << std::endl;
2525
std::cout << " -BGR : load the input as a BGR image" << std::endl;
2626
std::cout << " -Tensor : load the input as a tensor" << std::endl;
27-
std::cout << " -Perf : capture timing measurements" << std::endl;
27+
std::cout << " -Perf optional:<all>: capture performance measurements such as timing and memory usage. Specifying \"all\" will output all measurements" << std::endl;
2828
std::cout << " -Iterations : # times perf measurements will be run/averaged" << std::endl;
2929
std::cout << " -Input <fully qualified path>: binds image or CSV to model" << std::endl;
3030
std::cout << " -PerfOutput optional:<fully qualified path>: csv file to write the perf results to" << std::endl;
31-
std::cout << " -IgnoreFirstRun : ignore the first run in the perf results when calculating the average" << std::endl;
3231
std::cout << " -SavePerIterationPerf : save per iteration performance results to csv file" << std::endl;
3332
std::cout << " -SaveTensorData <saveMode>: save first iteration or all iteration output tensor results to csv file [First, All]" << std::endl;
3433
std::cout << " -Debug: print trace logs" << std::endl;
@@ -119,12 +118,13 @@ CommandLineArgs::CommandLineArgs(const std::vector<std::wstring>& args)
119118
{
120119
m_useGPUBoundInput = true;
121120
}
122-
else if ((_wcsicmp(args[i].c_str(), L"-IgnoreFirstRun") == 0))
123-
{
124-
m_ignoreFirstRun = true;
125-
}
126121
else if ((_wcsicmp(args[i].c_str(), L"-Perf") == 0))
127122
{
123+
if (i + 1 < args.size() && args[i + 1][0] != L'-' && (_wcsicmp(args[i+1].c_str(), L"all") == 0))
124+
{
125+
m_perfConsoleOutputAll = true;
126+
i++;
127+
}
128128
m_perfCapture = true;
129129
}
130130
else if ((_wcsicmp(args[i].c_str(), L"-Debug") == 0))

Tools/WinMLRunner/src/CommandLineArgs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class CommandLineArgs
1111
bool IsUsingGPUMinPower() const { return m_useGPUMinPower; }
1212
bool UseBGR() const { return m_useBGR; }
1313
bool IsUsingGPUBoundInput() const { return m_useGPUBoundInput; }
14-
bool IsIgnoreFirstRun() const { return m_ignoreFirstRun; }
1514
bool IsPerformanceCapture() const { return m_perfCapture; }
15+
bool IsPerformanceConsoleOutputVerbose() const { return m_perfConsoleOutputAll; }
1616
bool IsDebugOutputEnabled() const { return m_debug; }
1717
bool TerseOutput() const { return m_terseOutput; }
1818
bool IsPerIterationCapture() const { return m_perIterCapture; }
@@ -107,6 +107,7 @@ class CommandLineArgs
107107

108108
private:
109109
bool m_perfCapture = false;
110+
bool m_perfConsoleOutputAll = false;
110111
bool m_useCPU = false;
111112
bool m_useGPU = false;
112113
bool m_useGPUHighPerformance = false;

Tools/WinMLRunner/src/Common.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,11 @@ enum WINML_MODEL_TEST_PERF
3535
CREATE_SESSION,
3636
BIND_VALUE,
3737
EVAL_MODEL,
38+
BIND_VALUE_FIRST_RUN,
3839
EVAL_MODEL_FIRST_RUN,
3940
COUNT
4041
};
4142

42-
static std::vector<std::wstring> WINML_MODEL_TEST_PERF_NAMES =
43-
{
44-
L"ENTIRE TEST ",
45-
L" LOAD MODEL ",
46-
L" CREATE SESSION ",
47-
L" BIND VALUE ",
48-
L" EVAL MODEL ",
49-
};
50-
5143
#define MAX_PROFILING_LOOP 100
5244

5345
using namespace winrt;

0 commit comments

Comments
 (0)