ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Buffer.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef __NNCC_CORE_ADT_KERNEL_BUFFER_H__
18
#define __NNCC_CORE_ADT_KERNEL_BUFFER_H__
19
20
#include "
nncc/core/ADT/kernel/View.h
"
21
#include "
nncc/core/ADT/kernel/ViewImpl.h
"
22
23
#include <vector>
24
25
namespace
nncc
26
{
27
namespace
core
28
{
29
namespace
ADT
30
{
31
namespace
kernel
32
{
33
34
template
<
typename
T>
class
Buffer
final :
public
View
<T>
35
{
36
public
:
37
explicit
Buffer
(
const
Shape
&
shape
,
const
Layout
&layout) : _impl{
shape
, layout}
38
{
39
_buffer.resize(num_elements(
shape
));
40
}
41
42
public
:
43
T
at
(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col)
const override
44
{
45
return
_impl.at(_buffer.begin(), nth, ch, row, col);
46
}
47
48
public
:
49
T &
at
(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col)
override
50
{
51
return
_impl.at(_buffer.begin(), nth, ch, row, col);
52
}
53
54
public
:
55
const
Shape
&
shape
(
void
)
const override
{
return
_impl.shape(); }
56
57
private
:
58
std::vector<T> _buffer;
59
ViewImpl<T>
_impl;
60
};
61
62
template
<
typename
T,
typename
LayoutImpl>
Buffer<T>
make_buffer(
const
Shape
&shape)
63
{
64
return
Buffer<T>
{shape, LayoutImpl{}};
65
}
66
67
}
// namespace kernel
68
}
// namespace ADT
69
}
// namespace core
70
}
// namespace nncc
71
72
#endif
// __NNCC_CORE_ADT_KERNEL_BUFFER_H__
ViewImpl.h
nncc::core::ADT::kernel::Buffer
Definition
Buffer.h:35
nncc::core::ADT::kernel::Buffer::at
T & at(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col) override
Definition
Buffer.h:49
nncc::core::ADT::kernel::Buffer::at
T at(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col) const override
Definition
Buffer.h:43
nncc::core::ADT::kernel::Buffer::shape
const Shape & shape(void) const override
Definition
Buffer.h:55
nncc::core::ADT::kernel::Buffer::Buffer
Buffer(const Shape &shape, const Layout &layout)
Definition
Buffer.h:37
nncc::core::ADT::kernel::Layout
Definition
Layout.h:32
nncc::core::ADT::kernel::Shape
Definition
Shape.h:35
nncc::core::ADT::kernel::ViewImpl
Definition
ViewImpl.h:33
View.h
nncc
Definition
Accessor.h:23
nncc::core::ADT::kernel::View
Definition
View.h:34
compiler
angkor
include
nncc
core
ADT
kernel
Buffer.h
Generated by
1.9.8