Fix per iteration perf output functionality that was deleted in refactoring work
This commit is contained in:
Родитель
31a0ec2c03
Коммит
9ccd65377b
|
@ -218,13 +218,7 @@ CommandLineArgs::CommandLineArgs(const std::vector<std::wstring>& args)
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
// set to default path
|
||||
auto time = std::time(nullptr);
|
||||
struct tm localTime;
|
||||
localtime_s(&localTime, &time);
|
||||
std::wostringstream oss;
|
||||
oss << std::put_time(&localTime, L"%Y-%m-%d_%H.%M.%S");
|
||||
SetTensorOutputPath(L"\\PerIterationRun[" + oss.str() + L"]");
|
||||
// Will Set Default Path after argument checks
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(args[i].c_str(), L"-version") == 0)
|
||||
|
@ -318,6 +312,17 @@ CommandLineArgs::CommandLineArgs(const std::vector<std::wstring>& args)
|
|||
throw hresult_invalid_argument(msg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// set default path for per iteration / tensor output
|
||||
if (this->TensorOutputPath().empty())
|
||||
{
|
||||
auto time = std::time(nullptr);
|
||||
struct tm localTime;
|
||||
localtime_s(&localTime, &time);
|
||||
std::wostringstream oss;
|
||||
oss << std::put_time(&localTime, L"%Y-%m-%d_%H.%M.%S");
|
||||
SetTensorOutputPath(L".\\PerIterationRun[" + oss.str() + L"]");
|
||||
}
|
||||
CheckForInvalidArguments();
|
||||
}
|
||||
|
||||
|
|
|
@ -596,7 +596,7 @@ public:
|
|||
|
||||
void SetCSVFileName(const std::wstring& fileName) { m_csvFileName = fileName; }
|
||||
|
||||
void WritePerIterationPerformance(const CommandLineArgs& args, std::wstring model, std::wstring img)
|
||||
void WritePerIterationPerformance(const CommandLineArgs& args, const std::wstring& model, const std::wstring& img)
|
||||
{
|
||||
if (m_csvFileNamePerIterationSummary.length() > 0)
|
||||
{
|
||||
|
|
|
@ -80,8 +80,8 @@ HRESULT BindInputFeatures(const LearningModel& model, const LearningModelBinding
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT LoadModel(LearningModel &model, const std::wstring& path, bool capturePerf, OutputHelper& output, const CommandLineArgs& args,
|
||||
uint32_t iterationNum, Profiler<WINML_MODEL_TEST_PERF>& profiler)
|
||||
HRESULT LoadModel(LearningModel& model, const std::wstring& path, bool capturePerf, OutputHelper& output,
|
||||
const CommandLineArgs& args, uint32_t iterationNum, Profiler<WINML_MODEL_TEST_PERF>& profiler)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -111,9 +111,9 @@ HRESULT LoadModel(LearningModel &model, const std::wstring& path, bool capturePe
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CreateSession(LearningModelSession& session, IDirect3DDevice& winrtDevice, LearningModel& model, CommandLineArgs& args, OutputHelper& output,
|
||||
DeviceType deviceType, DeviceCreationLocation deviceCreationLocation,
|
||||
Profiler<WINML_MODEL_TEST_PERF>& profiler)
|
||||
HRESULT CreateSession(LearningModelSession& session, IDirect3DDevice& winrtDevice, LearningModel& model,
|
||||
CommandLineArgs& args, OutputHelper& output, DeviceType deviceType,
|
||||
DeviceCreationLocation deviceCreationLocation, Profiler<WINML_MODEL_TEST_PERF>& profiler)
|
||||
{
|
||||
if (model == nullptr)
|
||||
{
|
||||
|
@ -209,12 +209,14 @@ HRESULT CreateSession(LearningModelSession& session, IDirect3DDevice& winrtDevic
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT BindInputs(LearningModelBinding &context, const LearningModel& model, const LearningModelSession& session, OutputHelper& output,
|
||||
DeviceType deviceType, const CommandLineArgs& args, InputBindingType inputBindingType, InputDataType inputDataType,
|
||||
const IDirect3DDevice& winrtDevice, DeviceCreationLocation deviceCreationLocation, uint32_t iteration,
|
||||
HRESULT BindInputs(LearningModelBinding& context, const LearningModel& model, const LearningModelSession& session,
|
||||
OutputHelper& output, DeviceType deviceType, const CommandLineArgs& args,
|
||||
InputBindingType inputBindingType, InputDataType inputDataType, const IDirect3DDevice& winrtDevice,
|
||||
DeviceCreationLocation deviceCreationLocation, uint32_t iteration,
|
||||
Profiler<WINML_MODEL_TEST_PERF>& profiler)
|
||||
{
|
||||
if (deviceType == DeviceType::CPU && inputDataType == InputDataType::Tensor && inputBindingType == InputBindingType::GPU)
|
||||
if (deviceType == DeviceType::CPU && inputDataType == InputDataType::Tensor &&
|
||||
inputBindingType == InputBindingType::GPU)
|
||||
{
|
||||
std::cout << "Cannot create D3D12 device on client if CPU device type is selected." << std::endl;
|
||||
return E_INVALIDARG;
|
||||
|
@ -238,7 +240,6 @@ HRESULT BindInputs(LearningModelBinding &context, const LearningModel& model, co
|
|||
return hr.code();
|
||||
}
|
||||
|
||||
|
||||
HRESULT bindInputResult =
|
||||
BindInputFeatures(model, context, inputFeatures, args, output, captureIterationPerf, iteration, profiler);
|
||||
|
||||
|
@ -277,14 +278,14 @@ std::vector<std::wstring> GetModelsInDirectory(CommandLineArgs& args, OutputHelp
|
|||
return modelPaths;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CheckIfModelAndConfigurationsAreSupported(LearningModel& model, const std::wstring& modelPath,
|
||||
const DeviceType deviceType,
|
||||
const std::vector<InputDataType>& inputDataTypes,
|
||||
const std::vector<DeviceCreationLocation>& deviceCreationLocations)
|
||||
{
|
||||
// Does user want image as input binding
|
||||
bool hasInputBindingImage = std::any_of(inputDataTypes.begin(), inputDataTypes.end(), [](const InputDataType inputDataType){
|
||||
bool hasInputBindingImage =
|
||||
std::any_of(inputDataTypes.begin(), inputDataTypes.end(), [](const InputDataType inputDataType) {
|
||||
return inputDataType == InputDataType::ImageBGR || inputDataType == InputDataType::ImageRGB;
|
||||
});
|
||||
|
||||
|
@ -345,7 +346,6 @@ HRESULT EvaluateModel(LearningModelEvaluationResult& result, const LearningModel
|
|||
if (args.IsPerIterationCapture())
|
||||
{
|
||||
output.SaveEvalPerformance(profiler, iterationNum);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +500,8 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
|
|||
{
|
||||
LearningModel model = nullptr;
|
||||
|
||||
LoadModel(model, path, args.IsPerformanceCapture() || args.IsPerIterationCapture(), output, args, 0, profiler);
|
||||
LoadModel(model, path, args.IsPerformanceCapture() || args.IsPerIterationCapture(), output, args, 0,
|
||||
profiler);
|
||||
for (auto deviceType : deviceTypes)
|
||||
{
|
||||
lastHr = CheckIfModelAndConfigurationsAreSupported(model, path, deviceType, inputDataTypes,
|
||||
|
@ -542,8 +543,9 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
|
|||
{
|
||||
#if defined(_AMD64_)
|
||||
// PIX markers only work on AMD64
|
||||
// If PIX tool was attached then capture already began for the first iteration before session creation.
|
||||
// This is to begin PIX capture for each iteration after the first iteration.
|
||||
// If PIX tool was attached then capture already began for the first iteration before
|
||||
// session creation. This is to begin PIX capture for each iteration after the first
|
||||
// iteration.
|
||||
if (i > 0 && output.GetGraphicsAnalysis())
|
||||
{
|
||||
output.GetGraphicsAnalysis()->BeginCapture();
|
||||
|
@ -558,8 +560,8 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
|
|||
}
|
||||
LearningModelEvaluationResult result = nullptr;
|
||||
bool capture_perf = args.IsPerformanceCapture() || args.IsPerIterationCapture();
|
||||
lastHr = EvaluateModel(result, model, context, session, args, output,
|
||||
capture_perf, i, profiler);
|
||||
lastHr = EvaluateModel(result, model, context, session, args, output, capture_perf, i,
|
||||
profiler);
|
||||
if (FAILED(lastHr))
|
||||
{
|
||||
output.PrintEvaluatingInfo(i + 1, deviceType, inputBindingType, inputDataType,
|
||||
|
@ -604,6 +606,10 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
|
|||
inputBindingTypeStringified,
|
||||
deviceCreationLocationStringified);
|
||||
}
|
||||
else if (args.IsPerIterationCapture() && args.IsImageInput())
|
||||
{
|
||||
output.WritePerIterationPerformance(args, args.ModelPath(), args.ImagePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче