blob: 4feb6aa4522f9159cd9d4c08302fe8e187d83805 [file] [log] [blame]
Sadik Armagan045f6be2020-09-10 13:37:32 +01001//
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
Sadik Armagandea8fb62020-11-26 10:38:11 +00009#include<string>
10
Sadik Armagan045f6be2020-09-10 13:37:32 +010011namespace armnn
12{
13
Mike Kellyf9f33a02020-10-14 11:48:21 +010014/// 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.
Matthew Sloyan9d7a3322021-01-12 16:19:43 +000019/// - "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.
Sadik Armagan045f6be2020-09-10 13:37:32 +010028class ClBackendModelContext : public IBackendModelContext
29{
30public:
31 ClBackendModelContext(const ModelOptions& modelOptions);
32
Sadik Armagandea8fb62020-11-26 10:38:11 +000033 std::string GetCachedNetworkFilePath() const;
34
Sadik Armagan045f6be2020-09-10 13:37:32 +010035 bool IsFastMathEnabled() const;
36
Sadik Armagandea8fb62020-11-26 10:38:11 +000037 bool SaveCachedNetwork() const;
38
Sadik Armaganb7851f92021-10-06 16:37:02 +010039 int GetCachedFileDescriptor() const;
40
Sadik Armagan045f6be2020-09-10 13:37:32 +010041private:
Sadik Armagandea8fb62020-11-26 10:38:11 +000042 std::string m_CachedNetworkFilePath;
Sadik Armagan045f6be2020-09-10 13:37:32 +010043 bool m_IsFastMathEnabled;
Sadik Armagandea8fb62020-11-26 10:38:11 +000044 bool m_SaveCachedNetwork;
Sadik Armaganb7851f92021-10-06 16:37:02 +010045 int m_CachedFileDescriptor;
Sadik Armagandea8fb62020-11-26 10:38:11 +000046
Sadik Armagan045f6be2020-09-10 13:37:32 +010047};
48
49} // namespace armnn