Sadik Armagan | 045f6be | 2020-09-10 13:37:32 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "ClBackendModelContext.hpp" |
| 7 | |
| 8 | namespace |
| 9 | { |
| 10 | |
| 11 | bool ParseBool(const armnn::BackendOptions::Var& value, bool defaultValue) |
| 12 | { |
| 13 | if (value.IsBool()) |
| 14 | { |
| 15 | return value.AsBool(); |
| 16 | } |
| 17 | return defaultValue; |
| 18 | } |
| 19 | |
| 20 | } // namespace anonymous |
| 21 | |
| 22 | namespace armnn |
| 23 | { |
| 24 | |
| 25 | ClBackendModelContext::ClBackendModelContext(const ModelOptions& modelOptions) |
| 26 | : m_IsFastMathEnabled(false) |
| 27 | { |
| 28 | if (!modelOptions.empty()) |
| 29 | { |
| 30 | ParseOptions(modelOptions, "GpuAcc", [&](std::string name, const BackendOptions::Var& value) |
| 31 | { |
| 32 | if (name == "FastMathEnabled") |
| 33 | { |
| 34 | m_IsFastMathEnabled |= ParseBool(value, false); |
| 35 | } |
| 36 | }); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | bool ClBackendModelContext::IsFastMathEnabled() const |
| 41 | { |
| 42 | return m_IsFastMathEnabled; |
| 43 | } |
| 44 | |
| 45 | } // namespace armnn |