@@ -121,6 +121,7 @@ namespace WinMLRunnerTest
121121 {
122122 Assert::Fail (L" Failed to open tensor files\n " );
123123 }
124+
124125 bool isFirstRow = true ;
125126 while (!tensorFileStream.eof ())
126127 {
@@ -554,6 +555,30 @@ namespace WinMLRunnerTest
554555 Assert::AreEqual (S_OK, RunProc ((wchar_t *)command.c_str ()));
555556 }
556557
558+ TEST_METHOD (ProvidedImageInputFolder)
559+ {
560+ // Make test_folder_input folder before starting the tests
561+ std::string mkFolderCommand = " mkdir " + std::string (INPUT_FOLDER_PATH.begin (), INPUT_FOLDER_PATH.end ());
562+ system (mkFolderCommand.c_str ());
563+
564+ std::vector<std::string> images = { " fish.png" , " kitten_224.png" };
565+
566+ // Copy images from list to test_folder_input
567+ for (auto image : images)
568+ {
569+ std::string copyCommand = " Copy " ;
570+ copyCommand += image;
571+ copyCommand += ' ' + std::string (INPUT_FOLDER_PATH.begin (), INPUT_FOLDER_PATH.end ());
572+ system (copyCommand.c_str ());
573+ }
574+ const std::wstring command = BuildCommand ({ EXE_PATH, L" -model" , L" SqueezeNet.onnx" , L" -InputImageFolder" , INPUT_FOLDER_PATH });
575+ Assert::AreEqual (S_OK, RunProc ((wchar_t *)command.c_str ()));
576+
577+ std::string removeCommand = " rd /s /q " ;
578+ removeCommand += std::string (INPUT_FOLDER_PATH.begin (), INPUT_FOLDER_PATH.end ());
579+ system (removeCommand.c_str ());
580+ }
581+
557582 TEST_METHOD (AutoScaleImage)
558583 {
559584 const std::wstring modelPath = CURRENT_PATH + L" SqueezeNet.onnx" ;
@@ -563,15 +588,18 @@ namespace WinMLRunnerTest
563588 Assert::AreEqual (S_OK, RunProc ((wchar_t *)command.c_str ()));
564589 }
565590
566- TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensor )
591+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuPerIterationPerformance )
567592 const std::wstring modelPath = CURRENT_PATH + L" SqueezeNet.onnx" ;
568593 const std::wstring inputPath = CURRENT_PATH + L" fish.png" ;
569594 const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
570- const std::wstring command = BuildCommand ({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
571- L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -GPU" });
595+ const std::wstring command =
596+ BuildCommand ({ EXE_PATH, L" -model" , modelPath, L" -input" , inputPath, L" -PerfOutput" , OUTPUT_PATH, L" -perf" ,
597+ L" -SavePerIterationPerf" , L" -BaseOutputPath" , tensorDataPath,
598+ L" -PerIterationPath PerIterationData" , L" -CPU" });
572599 Assert::AreEqual (S_OK, RunProc ((wchar_t *)command.c_str ()));
573- Assert::AreEqual (true , CompareTensors (L" OutputTensorData\\ Squeezenet_fish_input_GPU.csv" ,
574- tensorDataPath + L" \\ softmaxout_1GpuIteration1.csv" ));
600+
601+ // We need to expect one more line because of the header
602+ Assert::AreEqual (static_cast <size_t >(2 ), GetOutputCSVLineCount (tensorDataPath + L" \\ PerIterationData\\ Summary.csv" ));
575603 }
576604
577605 TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuSaveTensor)
@@ -585,15 +613,15 @@ namespace WinMLRunnerTest
585613 tensorDataPath + L" \\ softmaxout_1CpuIteration1.csv" ));
586614 }
587615
588- TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensorImageDenotation )
589- const std::wstring modelPath = CURRENT_PATH + L" mnist .onnx" ;
590- const std::wstring inputPath = CURRENT_PATH + L" mnist_28 .png" ;
616+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensor )
617+ const std::wstring modelPath = CURRENT_PATH + L" SqueezeNet .onnx" ;
618+ const std::wstring inputPath = CURRENT_PATH + L" fish .png" ;
591619 const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
592620 const std::wstring command = BuildCommand ({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
593621 L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -GPU" });
594622 Assert::AreEqual (S_OK, RunProc ((wchar_t *)command.c_str ()));
595- Assert::AreEqual (true , CompareTensors (L" OutputTensorData\\ Mnist_8_input_GPU .csv" ,
596- tensorDataPath + L" \\ Plus214_Output_0GpuIteration1 .csv" ));
623+ Assert::AreEqual (true , CompareTensors (L" OutputTensorData\\ Squeezenet_fish_input_GPU .csv" ,
624+ tensorDataPath + L" \\ softmaxout_1GpuIteration1 .csv" ));
597625 }
598626
599627 TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuSaveTensorImageDenotation)
@@ -607,15 +635,15 @@ namespace WinMLRunnerTest
607635 tensorDataPath + L" \\ Plus214_Output_0CpuIteration1.csv" ));
608636 }
609637
610- TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensorFp16 )
611- const std::wstring modelPath = CURRENT_PATH + L"SqueezeNet_fp16 .onnx";
612- const std::wstring inputPath = CURRENT_PATH + L" fish .png" ;
638+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensorImageDenotation )
639+ const std::wstring modelPath = CURRENT_PATH + L"mnist .onnx";
640+ const std::wstring inputPath = CURRENT_PATH + L" mnist_28 .png" ;
613641 const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
614642 const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
615643 L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -GPU" });
616644 Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
617- Assert::AreEqual (true , CompareTensorsFP16 (L" OutputTensorData\\ Squeezenet_fp16_fish_input_GPU .csv" ,
618- tensorDataPath + L" \\ softmaxout_1GpuIteration1 .csv" ));
645+ Assert::AreEqual (true , CompareTensors (L" OutputTensorData\\ Mnist_8_input_GPU .csv" ,
646+ tensorDataPath + L" \\ Plus214_Output_0GpuIteration1 .csv" ));
619647 }
620648
621649 TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuSaveTensorFp16)
@@ -629,41 +657,87 @@ namespace WinMLRunnerTest
629657 tensorDataPath + L" \\ softmaxout_1CpuIteration1.csv" ));
630658 }
631659
632- TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuPerIterationPerformance)
660+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensorFp16)
661+ const std::wstring modelPath = CURRENT_PATH + L"SqueezeNet_fp16.onnx";
662+ const std::wstring inputPath = CURRENT_PATH + L" fish.png" ;
663+ const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
664+ const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
665+ L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -GPU" });
666+ Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
667+ Assert::AreEqual (true , CompareTensorsFP16(L" OutputTensorData\\ Squeezenet_fp16_fish_input_GPU.csv" ,
668+ tensorDataPath + L" \\ softmaxout_1GpuIteration1.csv" ));
669+ }
670+
671+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuSaveTensorTensorizeIdentity)
633672 const std::wstring modelPath = CURRENT_PATH + L"SqueezeNet.onnx";
673+ const std::wstring inputPath = CURRENT_PATH + L" fish.png" ;
634674 const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
635- const std::wstring command =
636- BuildCommand ({ EXE_PATH, L" -model" , modelPath, L" -PerfOutput" , OUTPUT_PATH, L" -perf" ,
637- L" -SavePerIterationPerf" , L" -BaseOutputPath" , tensorDataPath,
638- L" -PerIterationPath PerIterationData" , L" -CPU" });
675+ const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
676+ L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -CPU" ,
677+ L" -Tensor" });
639678 Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
679+ Assert::AreEqual (true , CompareTensors(L" OutputTensorData\\ Squeezenet_fish_input_CPU.csv" ,
680+ tensorDataPath + L" \\ softmaxout_1CpuIteration1.csv" ));
681+ }
640682
641- // We need to expect one more line because of the header
642- Assert::AreEqual (static_cast <size_t >(2 ), GetOutputCSVLineCount(tensorDataPath + L" \\ PerIterationData\\ Summary.csv" ));
683+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensorTensorizeIdentity)
684+ const std::wstring modelPath = CURRENT_PATH + L"SqueezeNet.onnx";
685+ const std::wstring inputPath = CURRENT_PATH + L" fish.png" ;
686+ const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
687+ const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
688+ L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -GPU" ,
689+ L" -Tensor Identity" });
690+ Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
691+ Assert::AreEqual (true , CompareTensors(L" OutputTensorData\\ Squeezenet_fish_input_GPU.csv" ,
692+ tensorDataPath + L" \\ softmaxout_1GpuIteration1.csv" ));
643693 }
644694
645- TEST_METHOD (ProvidedImageInputFolder)
646- {
647- // Make test_folder_input folder before starting the tests
648- std::string mkFolderCommand = " mkdir " + std::string (INPUT_FOLDER_PATH.begin (), INPUT_FOLDER_PATH.end ());
649- system (mkFolderCommand.c_str ());
695+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuSaveTensorTensorizeScaleMeanStdDev)
696+ const std::wstring modelPath = CURRENT_PATH + L"DenseNet121_fp32.onnx";
697+ const std::wstring inputPath = CURRENT_PATH + L" kitten_224.png" ;
698+ const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
699+ const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
700+ L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -CPU" ,
701+ L" -Tensor Normalize 255 0.485,0.456,0.406 0.229,0.224,0.225" });
702+ Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
703+ Assert::AreEqual (true , CompareTensors(L" OutputTensorData\\ DenseNet121_fp32_kitten_224_input_CPU.csv" ,
704+ tensorDataPath + L" \\ fc6_1CpuIteration1.csv" ));
705+ }
650706
651- std::vector<std::string> images = { " fish.png" , " kitten_224.png" };
707+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensorTensorizeScaleMeanStdDev)
708+ const std::wstring modelPath = CURRENT_PATH + L"DenseNet121_fp32.onnx";
709+ const std::wstring inputPath = CURRENT_PATH + L" kitten_224.png" ;
710+ const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
711+ const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
712+ L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -GPU" ,
713+ L" -Tensor Normalize 255 0.485,0.456,0.406 0.229,0.224,0.225" });
714+ Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
715+ Assert::AreEqual (true , CompareTensors(L" OutputTensorData\\ DenseNet121_fp32_kitten_224_input_GPU.csv" ,
716+ tensorDataPath + L" \\ fc6_1GpuIteration1.csv" ));
717+ }
652718
653- // Copy images from list to test_folder_input
654- for (auto image : images)
655- {
656- std::string copyCommand = " Copy " ;
657- copyCommand += image;
658- copyCommand += ' ' + std::string (INPUT_FOLDER_PATH.begin (), INPUT_FOLDER_PATH.end ());
659- system (copyCommand.c_str ());
660- }
661- const std::wstring command = BuildCommand ({ EXE_PATH, L" -model" , L" SqueezeNet.onnx" , L" -InputImageFolder" , INPUT_FOLDER_PATH });
719+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyCpuSaveTensorTensorizeScaleMeanStdDevFP16)
720+ const std::wstring modelPath = CURRENT_PATH + L"DenseNet121_fp16.onnx";
721+ const std::wstring inputPath = CURRENT_PATH + L" kitten_224.png" ;
722+ const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
723+ const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
724+ L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -CPU" ,
725+ L" -Tensor Normalize 255 0.485,0.456,0.406 0.229,0.224,0.225" });
662726 Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
727+ Assert::AreEqual (true , CompareTensors(L" OutputTensorData\\ DenseNet121_fp16_kitten_224_input_CPU.csv" ,
728+ tensorDataPath + L" \\ fc6_1CpuIteration1.csv" ));
729+ }
663730
664- std::string removeCommand = " rd /s /q " ;
665- removeCommand += std::string (INPUT_FOLDER_PATH.begin (), INPUT_FOLDER_PATH.end ());
666- system (removeCommand.c_str ());
731+ TEST_METHOD_WITH_NAME (ProvidedImageInputOnlyGpuSaveTensorTensorizeScaleMeanStdDevFP16)
732+ const std::wstring modelPath = CURRENT_PATH + L"DenseNet121_fp16.onnx";
733+ const std::wstring inputPath = CURRENT_PATH + L" kitten_224.png" ;
734+ const std::wstring tensorDataPath = TENSOR_DATA_PATH + L" \\ " + METHOD_NAME;
735+ const std::wstring command = BuildCommand({ EXE_PATH, L" -model " , modelPath, L" -input" , inputPath,
736+ L" -SaveTensorData" , L" First" , L" -PerIterationPath" , tensorDataPath, L" -GPU" ,
737+ L" -Tensor Normalize 255 0.485,0.456,0.406 0.229,0.224,0.225" });
738+ Assert::AreEqual (S_OK, RunProc((wchar_t *)command.c_str()));
739+ Assert::AreEqual (true , CompareTensorsFP16(L" OutputTensorData\\ DenseNet121_fp16_kitten_224_input_GPU.csv" ,
740+ tensorDataPath + L" \\ fc6_1GpuIteration1.csv" ));
667741 }
668742 };
669743
@@ -823,7 +897,7 @@ namespace WinMLRunnerTest
823897
824898 TEST_METHOD (TestTopK)
825899 {
826- const std::wstring command = BuildCommand ({ EXE_PATH, L" -model" , L" SqueezeNet.onnx" , L" -TopK" , L" 5" });
900+ const std::wstring command = BuildCommand ({ EXE_PATH, L" -model" , CURRENT_PATH + L" SqueezeNet.onnx" , L" -TopK" , L" 5" });
827901 Assert::AreEqual (S_OK, RunProc ((wchar_t *)command.c_str ()));
828902 }
829903
0 commit comments