aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSadik Armagan <sadik.armagan@arm.com>2021-01-11 16:34:01 +0000
committerSadik Armagan <sadik.armagan@arm.com>2021-01-11 16:34:01 +0000
commitf36e10b8947fe5f0984e7428c2d5d5d7fe18007e (patch)
treec531059e65941665de3931983c81f6ab256c75b7
parent1312959112045a46b1c9d2d5f68c47d8194ce865 (diff)
downloadandroid-nn-driver-f36e10b8947fe5f0984e7428c2d5d5d7fe18007e.tar.gz
IVGCVSW-5485 'Add CacheLoadedNetwork options to Android NN Driver'
* Added Flatbuffers dependency to android-nn-driver * Added CacheLoadedNetwork options to android-nn-driver Options will be android.hardware.neuralnetworks@1.3-service-armnn -v -c GpuAcc -n arm-armnn -s -q <file_path> & Signed-off-by: Sadik Armagan <sadik.armagan@arm.com> Change-Id: I2cdf0b84062cb1c6ad4346cd64b00161cfe85920
-rw-r--r--1.2/ArmnnDriverImpl.cpp4
-rw-r--r--1.3/ArmnnDriverImpl.cpp4
-rw-r--r--Android.bp33
-rw-r--r--Android.mk8
-rw-r--r--ArmnnDriverImpl.cpp4
-rw-r--r--DriverOptions.cpp15
-rw-r--r--DriverOptions.hpp4
-rw-r--r--docs/FAQ.md18
-rwxr-xr-xsetup.sh15
-rw-r--r--test/Android.mk4
10 files changed, 100 insertions, 9 deletions
diff --git a/1.2/ArmnnDriverImpl.cpp b/1.2/ArmnnDriverImpl.cpp
index 6d713e0..d5539bc 100644
--- a/1.2/ArmnnDriverImpl.cpp
+++ b/1.2/ArmnnDriverImpl.cpp
@@ -132,7 +132,9 @@ Return<V1_0::ErrorStatus> ArmnnDriverImpl::prepareArmnnModel_1_2(
armnn::BackendOptions gpuAcc("GpuAcc",
{
- { "FastMathEnabled", options.IsFastMathEnabled() }
+ { "FastMathEnabled", options.IsFastMathEnabled() },
+ { "SaveCachedNetwork", options.SaveCachedNetwork() },
+ { "CachedNetworkFilePath", options.GetCachedNetworkFilePath() }
});
armnn::BackendOptions cpuAcc("CpuAcc",
{
diff --git a/1.3/ArmnnDriverImpl.cpp b/1.3/ArmnnDriverImpl.cpp
index b2524d3..595df0a 100644
--- a/1.3/ArmnnDriverImpl.cpp
+++ b/1.3/ArmnnDriverImpl.cpp
@@ -143,7 +143,9 @@ Return<V1_3::ErrorStatus> ArmnnDriverImpl::prepareArmnnModel_1_3(
armnn::BackendOptions gpuAcc("GpuAcc",
{
- { "FastMathEnabled", options.IsFastMathEnabled() }
+ { "FastMathEnabled", options.IsFastMathEnabled() },
+ { "SaveCachedNetwork", options.SaveCachedNetwork() },
+ { "CachedNetworkFilePath", options.GetCachedNetworkFilePath() }
});
armnn::BackendOptions cpuAcc("CpuAcc",
{
diff --git a/Android.bp b/Android.bp
index 5dfe869..fde01e8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -51,6 +51,39 @@ cc_library_static {
],
}
+////////////////////////////////////////////
+// //
+// flatbuffers libs //
+// //
+////////////////////////////////////////////
+cc_defaults {
+ name: "libflatbuffers-defaults",
+ proprietary: true,
+ export_include_dirs: [ "flatbuffers-1.12.0/",
+ "flatbuffers-1.12.0/include",
+ ],
+ local_include_dirs: ["flatbuffers-1.12.0/include",],
+ cflags: [
+ "-O3",
+ "-fexceptions",
+ "-Wno-unused-parameter",
+ "-DFLATBUFFERS_BUILD_FLATC=1"
+ ],
+ cppflags: [
+ "-std=c++14"
+ ],
+ rtti: true,
+}
+
+cc_library_static {
+ name: "libflatbuffers-framework",
+ defaults: ["libflatbuffers-defaults"],
+ srcs: [
+ "flatbuffers-1.12.0/src/flatc.cpp",
+ "flatbuffers-1.12.0/src/flatc_main.cpp",
+ ],
+}
+
subdirs = [
"armnn",
]
diff --git a/Android.mk b/Android.mk
index 9cbf71f..8b884e1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -163,6 +163,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
@@ -290,6 +291,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
@@ -410,6 +412,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
@@ -528,6 +531,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := libarmnn
@@ -604,6 +608,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \
@@ -700,6 +705,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \
@@ -787,6 +793,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \
@@ -865,6 +872,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \
diff --git a/ArmnnDriverImpl.cpp b/ArmnnDriverImpl.cpp
index 0934e2c..ef37cae 100644
--- a/ArmnnDriverImpl.cpp
+++ b/ArmnnDriverImpl.cpp
@@ -107,7 +107,9 @@ Return<V1_0::ErrorStatus> ArmnnDriverImpl<HalPolicy>::prepareModel(
armnn::BackendOptions gpuAcc("GpuAcc",
{
- { "FastMathEnabled", options.IsFastMathEnabled() }
+ { "FastMathEnabled", options.IsFastMathEnabled() },
+ { "SaveCachedNetwork", options.SaveCachedNetwork() },
+ { "CachedNetworkFilePath", options.GetCachedNetworkFilePath() }
});
armnn::BackendOptions cpuAcc("CpuAcc",
{
diff --git a/DriverOptions.cpp b/DriverOptions.cpp
index 6f777e3..c30a440 100644
--- a/DriverOptions.cpp
+++ b/DriverOptions.cpp
@@ -36,6 +36,8 @@ DriverOptions::DriverOptions(armnn::Compute computeDevice, bool fp16Enabled)
, m_EnableGpuProfiling(false)
, m_fp16Enabled(fp16Enabled)
, m_FastMathEnabled(false)
+ , m_ShouldExit(false)
+ , m_SaveCachedNetwork(false)
{
}
@@ -47,6 +49,8 @@ DriverOptions::DriverOptions(const std::vector<armnn::BackendId>& backends, bool
, m_EnableGpuProfiling(false)
, m_fp16Enabled(fp16Enabled)
, m_FastMathEnabled(false)
+ , m_ShouldExit(false)
+ , m_SaveCachedNetwork(false)
{
}
@@ -58,6 +62,7 @@ DriverOptions::DriverOptions(int argc, char** argv)
, m_fp16Enabled(false)
, m_FastMathEnabled(false)
, m_ShouldExit(false)
+ , m_SaveCachedNetwork(false)
{
std::string unsupportedOperationsAsString;
std::string clTunedParametersModeAsString;
@@ -112,6 +117,16 @@ DriverOptions::DriverOptions(int argc, char** argv)
("p,gpu-profiling", "Turns GPU profiling on",
cxxopts::value<bool>(m_EnableGpuProfiling)->default_value("false"))
+ ("q,cached-network-file", "If non-empty, the given file will be used to load/save cached network. "
+ "If save-cached-network option is given will save the cached network to given file."
+ "If save-cached-network option is not given will load the cached network from given "
+ "file.",
+ cxxopts::value<std::string>(m_CachedNetworkFilePath)->default_value(""))
+
+ ("s,save-cached-network", "Enables saving the cached network to the file given with cached-network-file option."
+ " See also --cached-network-file",
+ cxxopts::value<bool>(m_SaveCachedNetwork)->default_value("false"))
+
("t,cl-tuned-parameters-file",
"If non-empty, the given file will be used to load/save CL tuned parameters. "
"See also --cl-tuned-parameters-mode",
diff --git a/DriverOptions.hpp b/DriverOptions.hpp
index 1523652..f3b441c 100644
--- a/DriverOptions.hpp
+++ b/DriverOptions.hpp
@@ -36,6 +36,8 @@ public:
void SetBackends(const std::vector<armnn::BackendId>& backends) { m_Backends = backends; }
bool ShouldExit() const { return m_ShouldExit; }
int GetExitCode() const { return m_ExitCode; }
+ const std::string& GetCachedNetworkFilePath() const { return m_CachedNetworkFilePath; }
+ bool SaveCachedNetwork() const { return m_SaveCachedNetwork; }
private:
std::vector<armnn::BackendId> m_Backends;
@@ -51,6 +53,8 @@ private:
bool m_FastMathEnabled;
bool m_ShouldExit;
int m_ExitCode;
+ std::string m_CachedNetworkFilePath;
+ bool m_SaveCachedNetwork;
};
} // namespace armnn_driver
diff --git a/docs/FAQ.md b/docs/FAQ.md
index 8402571..bd79bb0 100644
--- a/docs/FAQ.md
+++ b/docs/FAQ.md
@@ -20,18 +20,21 @@ An acceptable workaround is to increase the timeout defined in AndroidTest.xml,
Problems seen when trying to build the android-nn-driver obtained from GitHub
-----------------------------------------------------------------------------
-Some users have encountered difficulties when attempting to build copies of the android-nn-driver obtained from GitHub. The build reports missing module source paths from armnn, clframework or boost_1_64_0. These errors can look like this:
+Some users have encountered difficulties when attempting to build copies of the android-nn-driver obtained from GitHub. The build reports missing module source paths from armnn, clframework, flatbuffers-1.12.0 or boost_1_64_0.
+These errors can look
+like this:
'error: vendor/arm/android-nn-driver/Android.bp:45:1: variant "android_arm64_armv7": module "armnn-arm_compute" "module source path "vendor/arm/android-nn-driver/clframework/build/android-arm64v8a/src/core/CL" does not exist'
These errors are due to missing dependencies or incompatiblities between the android-nn-driver and armnn or clframework versions. The android-nn-driver requires boost_1_64_0 to build unit tests. The versions of android-nn-driver, armnn and clframework will have to match for them to work together. For example, the 19.08 version of android-nn-driver, clframework and armnn will work together but none of them will work with earlier or later versions of the others.
-In order to ensure that the correct versions of boost, armnn and the clframework are obtained you can do the following:
+In order to ensure that the correct versions of flatbuffers, boost, armnn and the clframework are obtained you can do the following:
-1. Delete or move any boost, armnn or clframework directories from the android-nn-driver directory.
+1. Delete or move any flatbuffers, boost, armnn or clframework directories from the android-nn-driver directory.
2. Run the setup.sh script in the android-nn-driver directory.
-This will download the correct versions of boost, armnn and the clframework and the android-nn-driver should build correctly. Alternatively you can go to the GitHub pages for android-nn-driver, armnn and computelibrary (clframework) and download versions with the same release tag.
+This will download the correct versions of flatbuffers, boost, armnn and the clframework and the android-nn-driver should build
+correctly. Alternatively you can go to the GitHub pages for android-nn-driver, armnn and computelibrary (clframework) and download versions with the same release tag.
As an example, for 20.05 these would be:
@@ -43,6 +46,10 @@ The correct version of boost (1_64_0) can be downloaded from:
https://www.boost.org/
+The correct version of flatbuffers (1.12.0) can be downloaded from:
+
+https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz
+
Instance Normalization test failures
------------------------------------
@@ -68,5 +75,4 @@ In order to fix these failures you will have to update to a version of Android Q
The Android 10 R3 CTS that can be downloaded from https://source.android.com/compatibility/cts/downloads contains all these patches.
-There is a known issue that even with these patches CTS tests "TestRandomGraph/RandomGraphTest#LargeGraph_TENSOR_FLOAT16_Rank3/41" and "TestRandomGraph/RandomGraphTest#LargeGraph_TENSOR_FLOAT16_Rank2/20 " will still fail on CpuRef. These failures are caused by a LogSoftmax layer followed by a Floor layer which blows up the slight difference between fp16 to fp32. This issue only affects CpuRef with Android Q. These tests are not failing for Android R.
-
+There is a known issue that even with these patches CTS tests "TestRandomGraph/RandomGraphTest#LargeGraph_TENSOR_FLOAT16_Rank3/41" and "TestRandomGraph/RandomGraphTest#LargeGraph_TENSOR_FLOAT16_Rank2/20 " will still fail on CpuRef. These failures are caused by a LogSoftmax layer followed by a Floor layer which blows up the slight difference between fp16 to fp32. This issue only affects CpuRef with Android Q. These tests are not failing for Android R. \ No newline at end of file
diff --git a/setup.sh b/setup.sh
index 1dfc592..3ce0ed5 100755
--- a/setup.sh
+++ b/setup.sh
@@ -26,6 +26,21 @@ if [ ! -d boost_1_64_0 ]; then
rm -rf $BOOST_PKG
fi
+
+if [ ! -d v1.12.0 ]; then
+ echo "++ Downloading FlatBuffers"
+
+ FLATBUFFERS_PKG=v1.12.0.tar.gz
+
+ curl -LOk https://github.com/google/flatbuffers/archive/v1.12.0.tar.gz
+ AssertZeroExitCode "Downloading FlatBuffers failed"
+
+ tar xzf $FLATBUFFERS_PKG
+ AssertZeroExitCode "Unpacking FlatBuffers failed"
+
+ rm -rf $FLATBUFFERS_PKG
+fi
+
if [ ! -d armnn ]; then
echo "++ Downloading armnn"
diff --git a/test/Android.mk b/test/Android.mk
index f6439c6..2b87a41 100644
--- a/test/Android.mk
+++ b/test/Android.mk
@@ -74,6 +74,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
libboost_unit_test_framework \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \
@@ -188,6 +189,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
libboost_unit_test_framework \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \
@@ -293,6 +295,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
libboost_unit_test_framework \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \
@@ -391,6 +394,7 @@ LOCAL_SRC_FILES := \
LOCAL_STATIC_LIBRARIES := \
libneuralnetworks_common \
libboost_unit_test_framework \
+ libflatbuffers-framework \
arm_compute_library
LOCAL_WHOLE_STATIC_LIBRARIES := \