@@ -494,21 +494,25 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
494494 std::vector<std::wstring> modelPaths = args.ModelPath ().empty ()
495495 ? GetModelsInDirectory (args, &output)
496496 : std::vector<std::wstring>(1 , args.ModelPath ());
497-
497+ HRESULT lastHr = S_OK;
498498 if (args.IsConcurrentLoad ())
499499 {
500500 ConcurrentLoadModel (modelPaths, args.NumThreads (), args.ThreadInterval (), true );
501501 return 0 ;
502502 }
503-
504503 for (const auto & path: modelPaths)
505504 {
506505 LearningModel model = nullptr ;
507506
508507 LoadModel (model, path, args.IsPerformanceCapture () || args.IsPerIterationCapture (), output, args, 0 , profiler);
509-
510508 for (auto deviceType : deviceTypes)
511509 {
510+ lastHr = CheckIfModelAndConfigurationsAreSupported (model, path, deviceType, inputDataTypes,
511+ deviceCreationLocations);
512+ if (FAILED (lastHr))
513+ {
514+ continue ;
515+ }
512516 for (auto deviceCreationLocation : deviceCreationLocations)
513517 {
514518#if defined(_AMD64_)
@@ -522,23 +526,18 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
522526#endif
523527 LearningModelSession session = nullptr ;
524528 IDirect3DDevice winrtDevice = nullptr ;
525- HRESULT hr = CreateSession (session, winrtDevice, model, args, output, deviceType,
529+ lastHr = CreateSession (session, winrtDevice, model, args, output, deviceType,
526530 deviceCreationLocation, profiler);
531+ if (FAILED (lastHr))
532+ {
533+ continue ;
534+ }
527535 for (auto inputDataType : inputDataTypes)
528536 {
529537 for (auto inputBindingType : inputBindingTypes)
530538 {
531539 for (uint32_t i = 0 ; i < args.NumIterations (); i++)
532540 {
533-
534- hr = CheckIfModelAndConfigurationsAreSupported (model, path, deviceType, inputDataTypes,
535- deviceCreationLocations);
536- if (FAILED (hr))
537- {
538- continue ;
539- }
540-
541-
542541#if defined(_AMD64_)
543542 // PIX markers only work on AMD64
544543 // If PIX tool was attached then capture already began for the first iteration before session creation.
@@ -549,19 +548,18 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
549548 }
550549#endif
551550 LearningModelBinding context (session);
552- hr = BindInputs (context, model, session, output, deviceType, args, inputBindingType,
551+ lastHr = BindInputs (context, model, session, output, deviceType, args, inputBindingType,
553552 inputDataType, winrtDevice, deviceCreationLocation, i, profiler);
554553
555554 LearningModelEvaluationResult result = nullptr ;
556555 bool capture_perf = args.IsPerformanceCapture () || args.IsPerIterationCapture ();
557- hr = EvaluateModel (result, model, context, session, args, output,
556+ lastHr = EvaluateModel (result, model, context, session, args, output,
558557 capture_perf, i, profiler);
559-
560- if (FAILED (hr))
558+ if (FAILED (lastHr))
561559 {
562560 output.PrintEvaluatingInfo (i + 1 , deviceType, inputBindingType, inputDataType,
563561 deviceCreationLocation, " [FAILED]" );
564- return hr ;
562+ break ;
565563 }
566564 else if (!args.TerseOutput () || i == 0 )
567565 {
@@ -584,7 +582,7 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
584582 }
585583
586584 // print metrics after iterations
587- if (args.IsPerformanceCapture ())
585+ if (SUCCEEDED (lastHr) && args.IsPerformanceCapture ())
588586 {
589587 output.PrintResults (profiler, args.NumIterations (), deviceType, inputBindingType,
590588 inputDataType, deviceCreationLocation,
@@ -614,6 +612,7 @@ int run(CommandLineArgs& args, Profiler<WINML_MODEL_TEST_PERF>& profiler) try
614612 }
615613 }
616614 }
615+ return lastHr;
617616 }
618617 return 0 ;
619618}
0 commit comments