1 // 2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 #pragma once 6 7 #include <armnn/backends/IBackendContext.hpp> 8 9 #include<string> 10 11 namespace armnn 12 { 13 14 /// The ClBackendModelContext is used to pass in CL specific backend ModelOptions. The supported backend ModelOptions 15 /// are: 16 /// - "FastMathEnabled"\n 17 /// Using the fast_math flag can lead to performance improvements in fp32 and fp16 layers but may result in\n 18 /// results with reduced or different precision. The fast_math flag will not have any effect on int8 performance. 19 /// - "SaveCachedNetwork"\n 20 /// Using the save_cached_network flag enables saving the cached network\n 21 /// to a file given with the cached_network_file_path option. 22 /// - "CachedNetworkFilePath"\n 23 /// If the cached_network_file_path is a valid file and the save_cached_network flag is present\n 24 /// then the cached network will be saved to the given file.\n 25 /// If the cached_network_file_path is a valid file and the save_cached_network flag is not present\n 26 /// then the cached network will be loaded from the given file.\n 27 /// This will remove the time taken for initial compilation of kernels and speed up the first execution. 28 class ClBackendModelContext : public IBackendModelContext 29 { 30 public: 31 ClBackendModelContext(const ModelOptions& modelOptions); 32 33 std::string GetCachedNetworkFilePath() const; 34 35 bool IsFastMathEnabled() const; 36 37 bool SaveCachedNetwork() const; 38 39 int GetCachedFileDescriptor() const; 40 41 private: 42 std::string m_CachedNetworkFilePath; 43 bool m_IsFastMathEnabled; 44 bool m_SaveCachedNetwork; 45 int m_CachedFileDescriptor; 46 47 }; 48 49 } // namespace armnn