Quantization history configuration parameters
authorAjay Jayaraj <ajayj@ti.com>
Mon, 15 Oct 2018 16:49:01 +0000 (11:49 -0500)
committerAjay Jayaraj <ajayj@ti.com>
Mon, 15 Oct 2018 16:49:01 +0000 (11:49 -0500)
Added the following parameters to Configuration:
* quantHistoryParam1
* quantHistoryParam2
* quantMargin

These parameters can be specified in the configuration file or set
directly in the code.

(MCT-1062)

tidl_api/inc/configuration.h
tidl_api/src/configuration.cpp
tidl_api/src/configuration_parser.cpp
tidl_api/src/executor.cpp
tidl_api/src/executor_impl.h
tidl_api/src/parameters.h

index a26fbb9c309eb1b6276661da34b13a6a915ac3e3..913272a7f2bc1954e156507f448befdfb0eb01d8 100644 (file)
@@ -121,6 +121,10 @@ class Configuration
     //! size.
     bool showHeapStats;
 
+    int    quantHistoryParam1;
+    int    quantHistoryParam2;
+    int    quantMargin;
+
     //! Default constructor.
     Configuration();
 
index 789638730f21791b4f303c405eeb68abb57da0fe..8f512e8654d9d8fdce08732eaf093597e1628df3 100644 (file)
@@ -43,7 +43,10 @@ Configuration::Configuration(): numFrames(0), inHeight(0), inWidth(0),
                      PARAM_HEAP_SIZE(9 << 20),    // 9MB for mobileNet1
                      enableOutputTrace(false),
                      enableApiTrace(false),
-                     showHeapStats(false)
+                     showHeapStats(false),
+                     quantHistoryParam1(20),
+                     quantHistoryParam2(5),
+                     quantMargin(0)
 {
 }
 
index 5871e718bd74a1c2206ea0a0f292ec4d9f47bccb..f4575605ca7a68cc783706e463aa318f46c0806b 100644 (file)
@@ -80,7 +80,12 @@ struct ConfigParser : qi::grammar<Iterator, ascii::space_type>
          lit("outData")       >> '=' >> q_path[ph::ref(x.outData) = _1]       |
          lit("netBinFile")    >> '=' >> q_path[ph::ref(x.netBinFile) = _1]    |
          lit("paramsBinFile") >> '=' >> q_path[ph::ref(x.paramsBinFile) = _1] |
-         lit("enableTrace")   >> '=' >> bool_[ph::ref(x.enableOutputTrace)= _1]
+         lit("enableTrace")   >> '=' >> bool_[ph::ref(x.enableOutputTrace)= _1] |
+         lit("quantHistoryParam1")   >> '=' >>
+                                   int_[ph::ref(x.quantHistoryParam1)= _1] |
+         lit("quantHistoryParam2")   >> '=' >>
+                                   int_[ph::ref(x.quantHistoryParam2)= _1] |
+         lit("quantMargin")   >> '=' >> int_[ph::ref(x.quantMargin)= _1]
          ;
     }
 
index 9bd3a6e72678664e48a7728a93dc12fe2cdb07f0..2535f90aef11625baea0d5818d7ddecdbd3489d5 100644 (file)
@@ -115,7 +115,7 @@ bool ExecutorImpl::Initialize(const Configuration& configuration)
     up_malloc_ddr<TIDL_CreateParams> shared_createparam(
                                             malloc_ddr<TIDL_CreateParams>(),
                                             &__free_ddr);
-    InitializeNetworkCreateParam(shared_createparam.get());
+    InitializeNetworkCreateParam(shared_createparam.get(), configuration);
 
     // Read network from file into network struct in TIDL_CreateParams
     sTIDL_Network_t *net = &(shared_createparam.get())->net;
@@ -237,7 +237,8 @@ void ExecutorImpl::Cleanup()
 }
 
 
-void ExecutorImpl::InitializeNetworkCreateParam(TIDL_CreateParams *CP)
+void ExecutorImpl::InitializeNetworkCreateParam(TIDL_CreateParams *CP,
+                                                const Configuration& c)
 {
     CP->currCoreId           = layers_group_id_m;
     CP->currLayersGroupId    = layers_group_id_m;
@@ -245,9 +246,9 @@ void ExecutorImpl::InitializeNetworkCreateParam(TIDL_CreateParams *CP)
     CP->l2MemSize            = tidl::internal::DMEM1_SIZE;
     CP->l3MemSize            = tidl::internal::OCMC_SIZE;
 
-    CP->quantHistoryParam1   = tidl::internal::QUANT_HISTORY_PARAM1;
-    CP->quantHistoryParam2   = tidl::internal::QUANT_HISTORY_PARAM2;
-    CP->quantMargin          = tidl::internal::QUANT_MARGIN;
+    CP->quantHistoryParam1   = c.quantHistoryParam1;
+    CP->quantHistoryParam2   = c.quantHistoryParam2;
+    CP->quantMargin          = c.quantMargin;
 
     // If trace is enabled, setup the device TIDL library to allocate separate
     // output buffers for each layer. This makes it possible for the host
index a6a84215858b6f192bcb602ff879bc6bd5f5db75..bc6b187668714039e48ce9bfdb600ee019f705c6 100644 (file)
@@ -63,7 +63,8 @@ class ExecutorImpl
         ExecutionObjects execution_objects_m;
 
     private:
-        void InitializeNetworkCreateParam(TIDL_CreateParams *cp);
+        void InitializeNetworkCreateParam(TIDL_CreateParams *cp,
+                                          const Configuration& c);
         bool InitializeNetworkParams(TIDL_CreateParams *cp);
         void Cleanup();
 
index eb93fd2e37c780dcda7c1de9eb9b9b75911554b9..3ea047eeb8bf36a9d15e5304705104afaa9fb65f 100644 (file)
@@ -34,9 +34,6 @@ namespace internal {
 const size_t DMEM0_SIZE             = 8*1024;
 const size_t DMEM1_SIZE             = 128*1024;
 const size_t OCMC_SIZE              = 320*1024;
-const int    QUANT_HISTORY_PARAM1   = 20;
-const int    QUANT_HISTORY_PARAM2   = 5;
-const int    QUANT_MARGIN           = 0;
 const int    CURR_LAYERS_GROUP_ID   = 1;
 const int    CURR_CORE_ID           = 1;