diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2018-10-23 15:14:46 +0100 |
---|---|---|
committer | Matthew Bentham <matthew.bentham@arm.com> | 2018-10-25 09:49:58 +0100 |
commit | 5cc8e56b4ca8d58dc11973c49c10a02a2f13580c (patch) | |
tree | 99f67a0652d2ee27f6cdbdc21c39001e529ee4f1 /tests/ExecuteNetwork | |
parent | 8853c1f6a802fe7549b89b74ed850aec455b923a (diff) | |
download | armnn-5cc8e56b4ca8d58dc11973c49c10a02a2f13580c.tar.gz |
IVGCVSW-2053: Validate BackendId parameters for the InferenceTest (EndToEnd tests) / ExecuteNetwork
!referencetests:154790
Change-Id: Iaf9608ae1e66460079f2546b30d7fbc9b55bb7dd
Diffstat (limited to 'tests/ExecuteNetwork')
-rw-r--r-- | tests/ExecuteNetwork/ExecuteNetwork.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/tests/ExecuteNetwork/ExecuteNetwork.cpp b/tests/ExecuteNetwork/ExecuteNetwork.cpp index 7f1bcd38dc..4ebc9987a5 100644 --- a/tests/ExecuteNetwork/ExecuteNetwork.cpp +++ b/tests/ExecuteNetwork/ExecuteNetwork.cpp @@ -2,8 +2,7 @@ // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // -#include "armnn/ArmNN.hpp" - +#include <armnn/ArmNN.hpp> #include <armnn/TypesUtils.hpp> #if defined(ARMNN_CAFFE_PARSER) @@ -166,13 +165,6 @@ void RemoveDuplicateDevices(std::vector<armnn::BackendId>& computeDevices) computeDevices.end()); } -bool CheckDevicesAreValid(const std::vector<armnn::BackendId>& computeDevices) -{ - return (!computeDevices.empty() - && std::none_of(computeDevices.begin(), computeDevices.end(), - [](armnn::BackendId c){ return c == armnn::Compute::Undefined; })); -} - } // namespace template<typename TParser, typename TDataType> @@ -352,6 +344,10 @@ int RunCsvTest(const armnnUtils::CsvRow &csvRow, size_t subgraphId = 0; + const std::string backendsMessage = std::string("The preferred order of devices to run layers on by default. ") + + std::string("Possible choices: ") + + armnn::BackendRegistryInstance().GetBackendIdsAsString(); + po::options_description desc("Options"); try { @@ -361,7 +357,7 @@ int RunCsvTest(const armnnUtils::CsvRow &csvRow, ("model-path,m", po::value(&modelPath), "Path to model file, e.g. .caffemodel, .prototxt, .tflite," " .onnx") ("compute,c", po::value<std::vector<armnn::BackendId>>()->multitoken(), - "The preferred order of devices to run layers on by default. Possible choices: CpuAcc, CpuRef, GpuAcc") + backendsMessage.c_str()) ("input-name,i", po::value(&inputName), "Identifier of the input tensor in the network.") ("subgraph-number,n", po::value<size_t>(&subgraphId)->default_value(0), "Id of the subgraph to be " "executed. Defaults to 0") @@ -420,9 +416,11 @@ int RunCsvTest(const armnnUtils::CsvRow &csvRow, RemoveDuplicateDevices(computeDevices); // Check that the specified compute devices are valid. - if (!CheckDevicesAreValid(computeDevices)) + std::string invalidBackends; + if (!CheckRequestedBackendsAreValid(computeDevices, armnn::Optional<std::string&>(invalidBackends))) { - BOOST_LOG_TRIVIAL(fatal) << "The list of preferred devices contains an invalid compute"; + BOOST_LOG_TRIVIAL(fatal) << "The list of preferred devices contains invalid backend IDs: " + << invalidBackends; return EXIT_FAILURE; } @@ -452,6 +450,9 @@ int main(int argc, const char* argv[]) size_t subgraphId = 0; + const std::string backendsMessage = "Which device to run layers on by default. Possible choices: " + + armnn::BackendRegistryInstance().GetBackendIdsAsString(); + po::options_description desc("Options"); try { @@ -467,7 +468,7 @@ int main(int argc, const char* argv[]) ("model-path,m", po::value(&modelPath), "Path to model file, e.g. .caffemodel, .prototxt," " .tflite, .onnx") ("compute,c", po::value<std::vector<std::string>>()->multitoken(), - "The preferred order of devices to run layers on by default. Possible choices: CpuAcc, CpuRef, GpuAcc") + backendsMessage.c_str()) ("input-name,i", po::value(&inputName), "Identifier of the input tensor in the network.") ("subgraph-number,x", po::value<size_t>(&subgraphId)->default_value(0), "Id of the subgraph to be executed." "Defaults to 0") @@ -594,9 +595,11 @@ int main(int argc, const char* argv[]) RemoveDuplicateDevices(computeDevices); // Check that the specified compute devices are valid. - if (!CheckDevicesAreValid(computeDevices)) + std::string invalidBackends; + if (!CheckRequestedBackendsAreValid(computeDevices, armnn::Optional<std::string&>(invalidBackends))) { - BOOST_LOG_TRIVIAL(fatal) << "The list of preferred devices contains an invalid compute"; + BOOST_LOG_TRIVIAL(fatal) << "The list of preferred devices contains invalid backend IDs: " + << invalidBackends; return EXIT_FAILURE; } |