25.11
Loading...
Searching...
No Matches
TensorBufferArrayView.hpp
Go to the documentation of this file.
1
//
2
// Copyright © 2017, 2024 Arm Ltd. All rights reserved.
3
// SPDX-License-Identifier: MIT
4
//
5
6
#pragma once
7
8
#include <
armnn/Tensor.hpp
>
9
10
#include <
armnnUtils/DataLayoutIndexed.hpp
>
11
12
namespace
armnn
13
{
14
15
// Utility class providing access to raw tensor memory based on indices along each dimension.
16
template
<
typename
DataType>
17
class
TensorBufferArrayView
18
{
19
public
:
20
TensorBufferArrayView
(
const
TensorShape
& shape,
DataType
* data,
21
armnnUtils::DataLayoutIndexed
dataLayout =
DataLayout::NCHW
)
22
: m_Shape(shape)
23
, m_Data(data)
24
, m_DataLayout(dataLayout)
25
{
26
ARMNN_THROW_INVALIDARG_MSG_IF_FALSE
(m_Shape.GetNumDimensions() == 4,
27
"Only $d tensors are supported by TensorBufferArrayView."
);
28
}
29
30
DataType
&
Get
(
unsigned
int
b,
unsigned
int
c,
unsigned
int
h,
unsigned
int
w)
const
31
{
32
return
m_Data[m_DataLayout.GetIndex(m_Shape, b, c, h, w)];
33
}
34
35
private
:
36
const
TensorShape
m_Shape;
37
DataType
* m_Data;
38
armnnUtils::DataLayoutIndexed
m_DataLayout;
39
};
40
41
}
//namespace armnn
DataLayoutIndexed.hpp
ARMNN_THROW_INVALIDARG_MSG_IF_FALSE
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
Definition
Exceptions.hpp:210
Tensor.hpp
armnn::TensorBufferArrayView::TensorBufferArrayView
TensorBufferArrayView(const TensorShape &shape, DataType *data, armnnUtils::DataLayoutIndexed dataLayout=DataLayout::NCHW)
Definition
TensorBufferArrayView.hpp:20
armnn::TensorBufferArrayView::Get
DataType & Get(unsigned int b, unsigned int c, unsigned int h, unsigned int w) const
Definition
TensorBufferArrayView.hpp:30
armnn::TensorShape
Definition
Tensor.hpp:21
armnnUtils::DataLayoutIndexed
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout.
Definition
DataLayoutIndexed.hpp:18
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition
01_00_quick_start.dox:7
armnn::DataLayout::NCHW
@ NCHW
Definition
Types.hpp:64
armnn::DataType
DataType
Definition
Types.hpp:49
src
backends
reference
workloads
TensorBufferArrayView.hpp
Generated on
for Arm NN by
1.14.0