blob: 5d9f70035797fef1bfe6e3642d9ceaaf7bb2aefe [file] [log] [blame]
telsoa015307bc12018-03-09 13:51:08 +00001//
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
telsoa01ce3e84a2018-08-31 09:31:35 +01008#include "ArmnnDriver.hpp"
9
10#include <NeuralNetworks.h>
11
telsoa015307bc12018-03-09 13:51:08 +000012#include <armnn/ArmNN.hpp>
13#include <CpuExecutor.h>
14
15#include <vector>
16#include <string>
17
18namespace armnn_driver
19{
20
21extern const armnn::PermutationVector g_DontPermute;
22
23class UnsupportedOperand: public std::runtime_error
24{
25public:
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.
35void 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
39void* GetMemoryFromPool(DataLocation location,
40 const std::vector<android::nn::RunTimePoolInfo>& memPools);
41
42/// Can throw UnsupportedOperand
43armnn::TensorInfo GetTensorInfoForOperand(const Operand& operand);
44
45std::string GetOperandSummary(const Operand& operand);
kevmay01bc5f7842018-08-30 12:34:39 +010046
47template <typename Model>
48std::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}
telsoa015307bc12018-03-09 13:51:08 +000078
79void DumpTensor(const std::string& dumpDir,
telsoa01ce3e84a2018-08-31 09:31:35 +010080 const std::string& requestName,
81 const std::string& tensorName,
82 const armnn::ConstTensor& tensor);
83
84void DumpJsonProfilingIfRequired(bool gpuProfilingEnabled,
85 const std::string& dumpDir,
86 armnn::NetworkId networkId,
87 const armnn::IProfiler* profiler);
telsoa015307bc12018-03-09 13:51:08 +000088
surmeh0176660052018-03-29 16:33:54 +010089void ExportNetworkGraphToDotFile(const armnn::IOptimizedNetwork& optimizedNetwork,
90 const std::string& dumpDir,
telsoa01ce3e84a2018-08-31 09:31:35 +010091 const ::android::hardware::neuralnetworks::V1_0::Model& model);
92
kevmay01bc5f7842018-08-30 12:34:39 +010093}