Matteo Martincigh | 2135015 | 2018-11-28 16:22:22 +0000 | [diff] [blame^] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "DataLayoutIndexed.hpp" |
| 7 | |
| 8 | using namespace armnn; |
| 9 | |
| 10 | namespace armnnUtils |
| 11 | { |
| 12 | |
| 13 | DataLayoutIndexed::DataLayoutIndexed(armnn::DataLayout dataLayout) |
| 14 | : m_DataLayout(dataLayout) |
| 15 | { |
| 16 | switch (dataLayout) |
| 17 | { |
| 18 | case armnn::DataLayout::NHWC: |
| 19 | m_ChannelsIndex = 3; |
| 20 | m_HeightIndex = 1; |
| 21 | m_WidthIndex = 2; |
| 22 | break; |
| 23 | case armnn::DataLayout::NCHW: |
| 24 | m_ChannelsIndex = 1; |
| 25 | m_HeightIndex = 2; |
| 26 | m_WidthIndex = 3; |
| 27 | break; |
| 28 | default: |
| 29 | throw armnn::InvalidArgumentException("Unknown DataLayout value: " + |
| 30 | std::to_string(static_cast<int>(dataLayout))); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | // Definition in include/armnn/Types.hpp |
| 35 | bool operator==(const DataLayout& dataLayout, const DataLayoutIndexed& indexed) |
| 36 | { |
| 37 | return dataLayout == indexed.GetDataLayout(); |
| 38 | } |
| 39 | |
| 40 | // Definition in include/armnn/Types.hpp |
| 41 | bool operator==(const DataLayoutIndexed& indexed, const DataLayout& dataLayout) |
| 42 | { |
| 43 | return indexed.GetDataLayout() == dataLayout; |
| 44 | } |
| 45 | |
| 46 | } // namespace armnnUtils |