telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // See LICENSE file in the project root for full license information. |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 8 | #include "ArmnnDriver.hpp" |
| 9 | |
| 10 | #include <NeuralNetworks.h> |
| 11 | |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 12 | #include <armnn/ArmNN.hpp> |
| 13 | #include <CpuExecutor.h> |
| 14 | |
| 15 | #include <vector> |
| 16 | #include <string> |
| 17 | |
| 18 | namespace armnn_driver |
| 19 | { |
| 20 | |
| 21 | extern const armnn::PermutationVector g_DontPermute; |
| 22 | |
| 23 | class UnsupportedOperand: public std::runtime_error |
| 24 | { |
| 25 | public: |
| 26 | UnsupportedOperand(const OperandType type) |
| 27 | : std::runtime_error("Operand type is unsupported") |
| 28 | , m_type(type) |
| 29 | {} |
| 30 | |
| 31 | OperandType m_type; |
| 32 | }; |
| 33 | |
| 34 | /// Swizzles tensor data in @a input according to the dimension mappings. |
| 35 | void SwizzleAndroidNn4dTensorToArmNn(const armnn::TensorInfo& tensor, const void* input, void* output, |
| 36 | const armnn::PermutationVector& mappings); |
| 37 | |
| 38 | /// Returns a pointer to a specific location in a pool |
| 39 | void* GetMemoryFromPool(DataLocation location, |
| 40 | const std::vector<android::nn::RunTimePoolInfo>& memPools); |
| 41 | |
| 42 | /// Can throw UnsupportedOperand |
| 43 | armnn::TensorInfo GetTensorInfoForOperand(const Operand& operand); |
| 44 | |
| 45 | std::string GetOperandSummary(const Operand& operand); |
kevmay01 | bc5f784 | 2018-08-30 12:34:39 +0100 | [diff] [blame^] | 46 | |
| 47 | template <typename Model> |
| 48 | std::string GetModelSummary(const Model& model) |
| 49 | { |
| 50 | std::stringstream result; |
| 51 | |
| 52 | result << model.inputIndexes.size() << " input(s), " << model.operations.size() << " operation(s), " << |
| 53 | model.outputIndexes.size() << " output(s), " << model.operands.size() << " operand(s)" << std::endl; |
| 54 | |
| 55 | result << "Inputs: "; |
| 56 | for (uint32_t i = 0; i < model.inputIndexes.size(); i++) |
| 57 | { |
| 58 | result << GetOperandSummary(model.operands[model.inputIndexes[i]]) << ", "; |
| 59 | } |
| 60 | result << std::endl; |
| 61 | |
| 62 | result << "Operations: "; |
| 63 | for (uint32_t i = 0; i < model.operations.size(); i++) |
| 64 | { |
| 65 | result << toString(model.operations[i].type).c_str() << ", "; |
| 66 | } |
| 67 | result << std::endl; |
| 68 | |
| 69 | result << "Outputs: "; |
| 70 | for (uint32_t i = 0; i < model.outputIndexes.size(); i++) |
| 71 | { |
| 72 | result << GetOperandSummary(model.operands[model.outputIndexes[i]]) << ", "; |
| 73 | } |
| 74 | result << std::endl; |
| 75 | |
| 76 | return result.str(); |
| 77 | } |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 78 | |
| 79 | void DumpTensor(const std::string& dumpDir, |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 80 | const std::string& requestName, |
| 81 | const std::string& tensorName, |
| 82 | const armnn::ConstTensor& tensor); |
| 83 | |
| 84 | void DumpJsonProfilingIfRequired(bool gpuProfilingEnabled, |
| 85 | const std::string& dumpDir, |
| 86 | armnn::NetworkId networkId, |
| 87 | const armnn::IProfiler* profiler); |
telsoa01 | 5307bc1 | 2018-03-09 13:51:08 +0000 | [diff] [blame] | 88 | |
surmeh01 | 7666005 | 2018-03-29 16:33:54 +0100 | [diff] [blame] | 89 | void ExportNetworkGraphToDotFile(const armnn::IOptimizedNetwork& optimizedNetwork, |
| 90 | const std::string& dumpDir, |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 91 | const ::android::hardware::neuralnetworks::V1_0::Model& model); |
| 92 | |
kevmay01 | bc5f784 | 2018-08-30 12:34:39 +0100 | [diff] [blame^] | 93 | } |