Sadik Armagan | 8f397a1 | 2022-06-17 15:38:22 +0100 | [diff] [blame] | 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 |
| 30 | class ModelToINetworkTransformer |
| 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 |