IVGCVSW-4206 Optionally parse unsupported ops in ExecuteNetwork

Change-Id: I593e2540bd870d70aabb2c959f4e63a899967269
Signed-off-by: Derek Lamberti <derek.lamberti@arm.com>
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp
index 5926932..16e1fd3 100644
--- a/tests/ExecuteNetwork/ExecuteNetwork.cpp
+++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp
@@ -110,7 +110,9 @@
             ("file-only-external-profiling,g", po::bool_switch()->default_value(false),
              "If enabled then the 'file-only' test mode of external profiling will be enabled")
             ("counter-capture-period,u", po::value<uint32_t>(&counterCapturePeriod)->default_value(150u),
-             "If profiling is enabled in 'file-only' mode this is the capture period that will be used in the test");
+             "If profiling is enabled in 'file-only' mode this is the capture period that will be used in the test")
+            ("parse-unsupported", po::bool_switch()->default_value(false),
+                "Add unsupported operators as stand-in layers (where supported by parser)");
     }
     catch (const std::exception& e)
     {
@@ -155,6 +157,8 @@
     bool printIntermediate = vm["print-intermediate-layers"].as<bool>();
     bool enableExternalProfiling = vm["enable-external-profiling"].as<bool>();
     bool fileOnlyExternalProfiling = vm["file-only-external-profiling"].as<bool>();
+    bool parseUnsupported = vm["parse-unsupported"].as<bool>();
+
 
     // Check whether we have to load test cases from a file.
     if (CheckOption(vm, "test-cases"))
@@ -202,7 +206,7 @@
                 testCase.values.insert(testCase.values.begin(), executableName);
                 results.push_back(std::async(std::launch::async, RunCsvTest, std::cref(testCase), std::cref(runtime),
                                              enableProfiling, enableFp16TurboMode, thresholdTime, printIntermediate,
-                                             enableLayerDetails));
+                                             enableLayerDetails, parseUnsupported));
             }
 
             // Check results
@@ -222,7 +226,7 @@
                 testCase.values.insert(testCase.values.begin(), executableName);
                 if (RunCsvTest(testCase, runtime, enableProfiling,
                                enableFp16TurboMode, thresholdTime, printIntermediate,
-                               enableLayerDetails) != EXIT_SUCCESS)
+                               enableLayerDetails, parseUnsupported) != EXIT_SUCCESS)
                 {
                     return EXIT_FAILURE;
                 }
@@ -268,6 +272,6 @@
         return RunTest(modelFormat, inputTensorShapes, computeDevices, dynamicBackendsPath, modelPath, inputNames,
                        inputTensorDataFilePaths, inputTypes, quantizeInput, outputTypes, outputNames,
                        outputTensorFiles, enableProfiling, enableFp16TurboMode, thresholdTime, printIntermediate,
-                       subgraphId, enableLayerDetails, runtime);
+                       subgraphId, enableLayerDetails, parseUnsupported, runtime);
     }
 }
diff --git a/tests/InferenceModel.hpp b/tests/InferenceModel.hpp
index 9e054c4..6ec63ba 100644
--- a/tests/InferenceModel.hpp
+++ b/tests/InferenceModel.hpp
@@ -93,6 +93,7 @@
     bool                            m_VisualizePostOptimizationModel;
     bool                            m_EnableFp16TurboMode;
     bool                            m_PrintIntermediateLayers;
+    bool                            m_ParseUnsupported;
 
     Params()
         : m_ComputeDevices{}
@@ -101,6 +102,7 @@
         , m_VisualizePostOptimizationModel(false)
         , m_EnableFp16TurboMode(false)
         , m_PrintIntermediateLayers(false)
+        , m_ParseUnsupported(false)
     {}
 };
 
@@ -235,7 +237,9 @@
         const std::string& modelPath = params.m_ModelPath;
 
         // Create a network from a file on disk
-        auto parser(IParser::Create());
+        IParser::TfLiteParserOptions options;
+        options.m_StandInLayerForUnsupported = params.m_ParseUnsupported;
+        auto parser(IParser::Create(options));
 
         armnn::INetworkPtr network{nullptr, [](armnn::INetwork *){}};
 
diff --git a/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp b/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp
index 2556a10..ff8b9af 100644
--- a/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp
+++ b/tests/NetworkExecutionUtils/NetworkExecutionUtils.hpp
@@ -371,6 +371,7 @@
     size_t                        m_SubgraphId;
     bool                          m_EnableLayerDetails = false;
     bool                          m_GenerateTensorData;
+    bool                          m_ParseUnsupported = false;
 };
 
 template<typename TParser, typename TDataType>
@@ -534,6 +535,7 @@
             bool printIntermediate,
             const size_t subgraphId,
             bool enableLayerDetails = false,
+            bool parseUnsupported = false,
             const std::shared_ptr<armnn::IRuntime>& runtime = nullptr)
 {
     std::string modelFormat = boost::trim_copy(format);
@@ -657,6 +659,7 @@
     params.m_SubgraphId               = subgraphId;
     params.m_EnableLayerDetails       = enableLayerDetails;
     params.m_GenerateTensorData       = inputTensorDataFilePathsVector.empty();
+    params.m_ParseUnsupported         = parseUnsupported;
 
     // Warn if ExecuteNetwork will generate dummy input data
     if (params.m_GenerateTensorData)
@@ -727,7 +730,7 @@
 
 int RunCsvTest(const armnnUtils::CsvRow &csvRow, const std::shared_ptr<armnn::IRuntime>& runtime,
                const bool enableProfiling, const bool enableFp16TurboMode, const double& thresholdTime,
-               const bool printIntermediate, bool enableLayerDetails = false)
+               const bool printIntermediate, bool enableLayerDetails = false, bool parseUnuspported = false)
 {
     std::string modelFormat;
     std::string modelPath;
@@ -841,5 +844,5 @@
     return RunTest(modelFormat, inputTensorShapes, computeDevices, dynamicBackendsPath, modelPath, inputNames,
                    inputTensorDataFilePaths, inputTypes, quantizeInput, outputTypes, outputNames, outputTensorFiles,
                    enableProfiling, enableFp16TurboMode, thresholdTime, printIntermediate, subgraphId,
-                   enableLayerDetails);
+                   enableLayerDetails, parseUnuspported);
 }