Add the use of private CL kernel cache file path sandbox/inki.dae/cl_kernel_cache
authorInki Dae <inki.dae@samsung.com>
Wed, 25 Mar 2020 01:44:22 +0000 (10:44 +0900)
committerInki Dae <inki.dae@samsung.com>
Mon, 30 Mar 2020 04:11:30 +0000 (13:11 +0900)
Change-Id: I3bf58fbeb6c09c1d97880edc8b51d1fe48518d7c
Signed-off-by: Inki Dae <inki.dae@samsung.com>
CMakeLists.txt
packaging/inference-engine-armnn.spec
src/inference_engine_armnn.cpp

index ea4cc2367110f08ac68c85258e81f5fe3da4bccb..95fc77fdce529d2fdcfc360e6a92e218db38b7fe 100644 (file)
@@ -38,6 +38,12 @@ ADD_DEFINITIONS("-DTIZEN_DEBUG")
 
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
+IF(USE_PRIVATE_CACHE_PATH)
+       ADD_DEFINITIONS(-DCACHE_PATH="${PRIVATE_CACHE_PATH}")
+ELSE()
+       ADD_DEFINITIONS(-DCACHE_PATH="./")
+ENDIF()
+
 aux_source_directory(src SOURCES)
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
 
index 1d01dd203a4950a5e6496d6196679de0925da48a..fcc411d0e8bb0d60477a0132c78089b990ecbc71 100644 (file)
@@ -28,6 +28,9 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 %endif
 
+# If you want to designate the location of CL kernel cache files then
+# add below flags as cmake flags.
+# -DUSE_PRIVATE_CACHE_PATH=ON -DPRIVATE_CACHE_PATH=/path/to/
 %cmake .
 
 make %{?jobs:-j%jobs}
index 9486c73f710828b0f569c790829d2aa051b52eac..e600a08e5705c575ebf9b27e3088f865af6ed71a 100644 (file)
 #include "arm_compute/runtime/CL/Utils.h"
 #include "openssl/sha.h"
 
+// CACHE_PATH has user-designated location of the CL kernel
+// cache files, which can be done in build time.
+// Please refer to below flags,
+// USE_PRIVATE_CACHE_PATH=ON means that inference-engine-armnn will use
+// user-designated location, and the location should be assigned to
+// PRIVATE_CACHE_PATH flag like PRIVATE_CACHE_PATH=/path/to/.
+// In default, CACHE_PATH has current directory, "./"
+#define USER_CACHE_PATH        CACHE_PATH
+
 namespace InferenceEngineImpl {
 namespace ARMNNImpl {
 
@@ -155,7 +164,10 @@ std::string InferenceARMNN::GetHashKey(std::string &model_path)
 
        close(fd);
 
-       return s.str();
+       std::string cache_file_path(USER_CACHE_PATH);
+       cache_file_path += s.str();
+
+       return cache_file_path;
 }
 
 int InferenceARMNN::SetTargetDevices(int types)
@@ -325,8 +337,6 @@ int InferenceARMNN::Load(std::vector<std::string> model_paths, inference_model_f
     LOGI("Optimized Network.");
 
        if (mUseCache == true) {
-               LOGI("cache file count = %d", mCacheFile.size());
-
                // restoring CL kernel binaries to memory needs CLBackendContext's instance of ARMCL and
                // the instance is created at armnn::IRuntime::Create function above so make sure to restore
                // CL kernel binaries after creating runtime and before loading model.