ArmNN
 26.01
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
11
12namespace armnn
13{
14
15// Utility class providing access to raw tensor memory based on indices along each dimension.
16template <typename DataType>
18{
19public:
22 : m_Shape(shape)
23 , m_Data(data)
24 , m_DataLayout(dataLayout)
25 {
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
35private:
36 const TensorShape m_Shape;
37 DataType* m_Data;
39};
40
41} //namespace armnn
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
TensorBufferArrayView(const TensorShape &shape, DataType *data, armnnUtils::DataLayoutIndexed dataLayout=DataLayout::NCHW)
DataType & Get(unsigned int b, unsigned int c, unsigned int h, unsigned int w) const
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition Tensor.cpp:174
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout.
unsigned int GetIndex(const armnn::TensorShape &shape, unsigned int batchIndex, unsigned int channelIndex, unsigned int heightIndex, unsigned int widthIndex) const
Copyright (c) 2021 ARM Limited and Contributors.
DataType
Definition Types.hpp:49