aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sloyan <matthew.sloyan@arm.com>2021-02-11 16:57:38 +0000
committerMatthew Sloyan <matthew.sloyan@arm.com>2021-02-12 18:15:12 +0000
commitcd639c98c347c1addae8c65eb1f4d8e75b468fdb (patch)
treed6a4a1ea0d649df94a30272c7247f43071f4e8b1
parent21469d2498017241d4caac4097479e249d78bf5d (diff)
downloadandroid-nn-driver-cd639c98c347c1addae8c65eb1f4d8e75b468fdb.tar.gz
IVGCVSW-5685 Add CpuAcc specific configuration option numberOfThreads
* Added --number-of-threads command line option to android-nn-driver !armnn:5068 Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com> Change-Id: I248326bf3c0355a7a17b70cb1aac7b7976820c12
-rw-r--r--1.2/ArmnnDriverImpl.cpp3
-rw-r--r--1.3/ArmnnDriverImpl.cpp3
-rw-r--r--ArmnnDriverImpl.cpp3
-rw-r--r--DriverOptions.cpp9
-rw-r--r--DriverOptions.hpp2
5 files changed, 17 insertions, 3 deletions
diff --git a/1.2/ArmnnDriverImpl.cpp b/1.2/ArmnnDriverImpl.cpp
index 2ef51db..94fb3c8 100644
--- a/1.2/ArmnnDriverImpl.cpp
+++ b/1.2/ArmnnDriverImpl.cpp
@@ -143,7 +143,8 @@ Return<V1_0::ErrorStatus> ArmnnDriverImpl::prepareArmnnModel_1_2(
});
armnn::BackendOptions cpuAcc("CpuAcc",
{
- { "FastMathEnabled", options.IsFastMathEnabled() }
+ { "FastMathEnabled", options.IsFastMathEnabled() },
+ { "NumberOfThreads", options.GetNumberOfThreads() }
});
OptOptions.m_ModelOptions.push_back(gpuAcc);
OptOptions.m_ModelOptions.push_back(cpuAcc);
diff --git a/1.3/ArmnnDriverImpl.cpp b/1.3/ArmnnDriverImpl.cpp
index c9f0340..f5a6e85 100644
--- a/1.3/ArmnnDriverImpl.cpp
+++ b/1.3/ArmnnDriverImpl.cpp
@@ -154,7 +154,8 @@ Return<V1_3::ErrorStatus> ArmnnDriverImpl::prepareArmnnModel_1_3(
});
armnn::BackendOptions cpuAcc("CpuAcc",
{
- { "FastMathEnabled", options.IsFastMathEnabled() }
+ { "FastMathEnabled", options.IsFastMathEnabled() },
+ { "NumberOfThreads", options.GetNumberOfThreads() }
});
OptOptions.m_ModelOptions.push_back(gpuAcc);
OptOptions.m_ModelOptions.push_back(cpuAcc);
diff --git a/ArmnnDriverImpl.cpp b/ArmnnDriverImpl.cpp
index 917370c..2381595 100644
--- a/ArmnnDriverImpl.cpp
+++ b/ArmnnDriverImpl.cpp
@@ -118,7 +118,8 @@ Return<V1_0::ErrorStatus> ArmnnDriverImpl<HalPolicy>::prepareModel(
});
armnn::BackendOptions cpuAcc("CpuAcc",
{
- { "FastMathEnabled", options.IsFastMathEnabled() }
+ { "FastMathEnabled", options.IsFastMathEnabled() },
+ { "NumberOfThreads", options.GetNumberOfThreads() }
});
OptOptions.m_ModelOptions.push_back(gpuAcc);
OptOptions.m_ModelOptions.push_back(cpuAcc);
diff --git a/DriverOptions.cpp b/DriverOptions.cpp
index c30a440..3f9b76e 100644
--- a/DriverOptions.cpp
+++ b/DriverOptions.cpp
@@ -38,6 +38,7 @@ DriverOptions::DriverOptions(armnn::Compute computeDevice, bool fp16Enabled)
, m_FastMathEnabled(false)
, m_ShouldExit(false)
, m_SaveCachedNetwork(false)
+ , m_NumberOfThreads(0)
{
}
@@ -51,6 +52,7 @@ DriverOptions::DriverOptions(const std::vector<armnn::BackendId>& backends, bool
, m_FastMathEnabled(false)
, m_ShouldExit(false)
, m_SaveCachedNetwork(false)
+ , m_NumberOfThreads(0)
{
}
@@ -63,6 +65,7 @@ DriverOptions::DriverOptions(int argc, char** argv)
, m_FastMathEnabled(false)
, m_ShouldExit(false)
, m_SaveCachedNetwork(false)
+ , m_NumberOfThreads(0)
{
std::string unsupportedOperationsAsString;
std::string clTunedParametersModeAsString;
@@ -127,6 +130,12 @@ DriverOptions::DriverOptions(int argc, char** argv)
" See also --cached-network-file",
cxxopts::value<bool>(m_SaveCachedNetwork)->default_value("false"))
+ ("number-of-threads",
+ "Assign the number of threads used by the CpuAcc backend. "
+ "Input value must be between 1 and 64. "
+ "Default is set to 0 (Backend will decide number of threads to use).",
+ cxxopts::value<unsigned int>(m_NumberOfThreads)->default_value("0"))
+
("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 f3b441c..bab611a 100644
--- a/DriverOptions.hpp
+++ b/DriverOptions.hpp
@@ -38,6 +38,7 @@ public:
int GetExitCode() const { return m_ExitCode; }
const std::string& GetCachedNetworkFilePath() const { return m_CachedNetworkFilePath; }
bool SaveCachedNetwork() const { return m_SaveCachedNetwork; }
+ unsigned int GetNumberOfThreads() const { return m_NumberOfThreads; }
private:
std::vector<armnn::BackendId> m_Backends;
@@ -55,6 +56,7 @@ private:
int m_ExitCode;
std::string m_CachedNetworkFilePath;
bool m_SaveCachedNetwork;
+ unsigned int m_NumberOfThreads;
};
} // namespace armnn_driver