ArmNN
 24.08
DataLayoutIndexed.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 using namespace armnn;
9 
10 namespace armnnUtils
11 {
12 
14  : m_DataLayout(dataLayout)
15 {
16  switch (dataLayout)
17  {
19  m_ChannelsIndex = 3;
20  m_HeightIndex = 1;
21  m_WidthIndex = 2;
22  break;
24  m_ChannelsIndex = 1;
25  m_HeightIndex = 2;
26  m_WidthIndex = 3;
27  break;
29  m_DepthIndex = 1;
30  m_HeightIndex = 2;
31  m_WidthIndex = 3;
32  m_ChannelsIndex = 4;
33  break;
35  m_ChannelsIndex = 1;
36  m_DepthIndex = 2;
37  m_HeightIndex = 3;
38  m_WidthIndex = 4;
39  break;
40  default:
41  throw armnn::InvalidArgumentException("Unknown DataLayout value: " +
42  std::to_string(static_cast<int>(dataLayout)));
43  }
44 }
45 
46 bool operator==(const DataLayout& dataLayout, const DataLayoutIndexed& indexed)
47 {
48  return dataLayout == indexed.GetDataLayout();
49 }
50 
51 bool operator==(const DataLayoutIndexed& indexed, const DataLayout& dataLayout)
52 {
53  return indexed.GetDataLayout() == dataLayout;
54 }
55 
56 } // namespace armnnUtils
armnn::DataLayout::NCDHW
@ NCDHW
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::DataLayout::NHWC
@ NHWC
armnnUtils::DataLayoutIndexed
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout.
Definition: DataLayoutIndexed.hpp:17
armnnUtils::DataLayoutIndexed::GetDataLayout
armnn::DataLayout GetDataLayout() const
Definition: DataLayoutIndexed.hpp:22
armnn::DataLayout::NDHWC
@ NDHWC
armnnUtils
Definition: CompatibleTypes.hpp:10
armnn::InvalidArgumentException
Definition: Exceptions.hpp:80
armnnUtils::operator==
bool operator==(const armnn::DataLayout &dataLayout, const DataLayoutIndexed &indexed)
Equality methods.
Definition: DataLayoutIndexed.cpp:46
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnnUtils::DataLayoutIndexed::DataLayoutIndexed
DataLayoutIndexed(armnn::DataLayout dataLayout)
Definition: DataLayoutIndexed.cpp:13
DataLayoutIndexed.hpp
armnn::DataLayout::NCHW
@ NCHW