ArmNN
 24.02
ModelToINetworkTransformer.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 //#include "ArmnnDriver.hpp"
9 #include "Converter.hpp"
10 
11 #include <armnn/ArmNN.hpp>
12 
13 #include <nnapi/IPreparedModel.h>
14 #include <nnapi/Result.h>
15 #include <nnapi/TypeUtils.h>
16 #include <nnapi/Types.h>
17 #include <nnapi/Validation.h>
18 
19 #include <set>
20 #include <map>
21 #include <vector>
22 
23 namespace armnn_driver
24 {
25 
26 using namespace android::nn;
27 
28 // A helper template class performing the conversion from an AndroidNN driver Model representation,
29 // to an armnn::INetwork object
31 {
32 public:
33  ModelToINetworkTransformer(const std::vector<armnn::BackendId>& backends,
34  const Model& model,
35  const std::set<unsigned int>& forcedUnsupportedOperations);
36 
37  ConversionResult GetConversionResult() const { return m_ConversionResult; }
38 
39  // Returns the ArmNN INetwork corresponding to the input model, if preparation went smoothly, nullptr otherwise.
40  armnn::INetwork* GetINetwork() const { return m_Data.m_Network.get(); }
41 
42  bool IsOperationSupported(uint32_t operationIndex) const;
43 
44 private:
45  void Convert();
46 
47  // Shared aggregate input/output/internal data
48  ConversionData m_Data;
49 
50  // Input data
51  const Model& m_Model;
52  const std::set<unsigned int>& m_ForcedUnsupportedOperations;
53 
54  // Output data
55  ConversionResult m_ConversionResult;
56  std::map<uint32_t, bool> m_OperationSupported;
57 };
58 
59 } // armnn_driver
armnn_driver::ConversionData
Definition: ConversionUtils.hpp:53
armnn_driver::ConversionResult
ConversionResult
Definition: ConversionUtils.hpp:127
armnn_driver
Helper classes.
Definition: ArmnnDevice.cpp:37
armnn_driver::Model
::android::nn::Model Model
Helper classes.
Definition: ConversionUtils.hpp:45
android::nn
Definition: support_library_service.cpp:10
ArmNN.hpp
armnn_driver::ModelToINetworkTransformer::GetINetwork
armnn::INetwork * GetINetwork() const
Definition: ModelToINetworkTransformer.hpp:40
Converter.hpp
armnn_driver::ModelToINetworkTransformer::GetConversionResult
ConversionResult GetConversionResult() const
Definition: ModelToINetworkTransformer.hpp:37
armnn_driver::ModelToINetworkTransformer
Definition: ModelToINetworkTransformer.hpp:30
armnn::INetwork
Main network class which provides the interface for building up a neural network.
Definition: INetwork.hpp:347