24.02
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
w
Variables
Typedefs
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
w
Enumerations
a
b
c
d
e
f
g
j
l
m
n
o
p
q
r
s
t
u
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
c
d
e
f
i
j
l
m
o
p
r
s
v
w
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
v
w
Enumerations
Enumerator
Related Functions
Files
File List
File Members
All
a
b
c
d
e
f
g
h
i
l
m
o
r
s
t
u
v
x
z
Functions
a
b
c
g
i
m
r
s
t
v
z
Variables
Typedefs
Macros
a
c
d
e
f
h
i
l
o
s
t
u
v
x
Examples
▼
Arm NN
►
Quick Start Guide
►
Arm NN Operators
►
Build Guides
►
Contribution Guides
►
Software Components
Frequently asked questions
How to use the Android NDK to build Arm NN
Contribution Guidelines
►
Namespaces
►
Classes
▼
Files
►
File List
►
File Members
►
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
SampleDynamicAdditionWorkload.cpp
Go to the documentation of this file.
1
//
2
// Copyright © 2020 Arm Ltd. All rights reserved.
3
// SPDX-License-Identifier: MIT
4
//
5
6
#include <
armnn/backends/ITensorHandle.hpp
>
7
8
#include "
SampleDynamicAdditionWorkload.hpp
"
9
#include "
SampleTensorHandle.hpp
"
10
11
namespace
sdb
// sample dynamic backend
12
{
13
14
inline
const
armnn::TensorInfo
&
GetTensorInfo
(
const
armnn::ITensorHandle
* tensorHandle)
15
{
16
// We know that reference workloads use RefTensorHandles for inputs and outputs
17
const
SampleTensorHandle
* sampleTensorHandle =
18
static_cast<
const
SampleTensorHandle
*
>
(tensorHandle);
19
return
sampleTensorHandle->
GetTensorInfo
();
20
}
21
22
const
float
*
GetInputTensorData
(
unsigned
int
idx,
const
armnn::AdditionQueueDescriptor
& data)
23
{
24
const
armnn::ITensorHandle
* tensorHandle = data.
m_Inputs
[idx];
25
return
reinterpret_cast<
const
float
*
>
(tensorHandle->
Map
());
26
}
27
28
float
*
GetOutputTensorData
(
unsigned
int
idx,
const
armnn::AdditionQueueDescriptor
& data)
29
{
30
armnn::ITensorHandle
* tensorHandle = data.
m_Outputs
[idx];
31
return
reinterpret_cast<
float
*
>
(tensorHandle->
Map
());
32
}
33
34
SampleDynamicAdditionWorkload::SampleDynamicAdditionWorkload
(
const
armnn::AdditionQueueDescriptor
& descriptor,
35
const
armnn::WorkloadInfo
& info)
36
: BaseWorkload(descriptor, info)
37
{}
38
39
void
SampleDynamicAdditionWorkload::Execute
()
const
40
{
41
const
armnn::TensorInfo
& info =
GetTensorInfo
(
m_Data
.
m_Inputs
[0]);
42
unsigned
int
num = info.GetNumElements();
43
44
const
float
* inputData0 =
GetInputTensorData
(0,
m_Data
);
45
const
float
* inputData1 =
GetInputTensorData
(1,
m_Data
);
46
float
* outputData =
GetOutputTensorData
(0,
m_Data
);
47
48
for
(
unsigned
int
i = 0; i < num; ++i)
49
{
50
outputData[i] = inputData0[i] + inputData1[i];
51
}
52
}
53
54
}
// namespace sdb // sample dynamic backend
SampleTensorHandle.hpp
armnn::TensorInfo
Definition:
Tensor.hpp:152
armnn::ITensorHandle
Definition:
ITensorHandle.hpp:16
sdb
Definition:
SampleDynamicAdditionWorkload.cpp:11
sdb::SampleDynamicAdditionWorkload::Execute
void Execute() const override
Definition:
SampleDynamicAdditionWorkload.cpp:39
sdb::GetTensorInfo
const armnn::TensorInfo & GetTensorInfo(const armnn::ITensorHandle *tensorHandle)
Definition:
SampleDynamicAdditionWorkload.cpp:14
sdb::SampleDynamicAdditionWorkload::SampleDynamicAdditionWorkload
SampleDynamicAdditionWorkload(const armnn::AdditionQueueDescriptor &descriptor, const armnn::WorkloadInfo &info)
Definition:
SampleDynamicAdditionWorkload.cpp:34
ITensorHandle.hpp
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition:
WorkloadInfo.hpp:16
armnn::AdditionQueueDescriptor
Definition:
WorkloadData.hpp:258
sdb::SampleTensorHandle
Definition:
SampleTensorHandle.hpp:15
armnn::QueueDescriptor::m_Outputs
std::vector< ITensorHandle * > m_Outputs
Definition:
WorkloadData.hpp:27
armnn::BaseWorkload< armnn::AdditionQueueDescriptor >::m_Data
armnn::AdditionQueueDescriptor m_Data
Definition:
Workload.hpp:89
sdb::SampleTensorHandle::GetTensorInfo
const armnn::TensorInfo & GetTensorInfo() const
Definition:
SampleTensorHandle.hpp:49
SampleDynamicAdditionWorkload.hpp
sdb::GetInputTensorData
const float * GetInputTensorData(unsigned int idx, const armnn::AdditionQueueDescriptor &data)
Definition:
SampleDynamicAdditionWorkload.cpp:22
armnn::QueueDescriptor::m_Inputs
std::vector< ITensorHandle * > m_Inputs
Definition:
WorkloadData.hpp:26
armnn::ITensorHandle::Map
virtual const void * Map(bool blocking=true) const =0
Map the tensor data for access.
sdb::GetOutputTensorData
float * GetOutputTensorData(unsigned int idx, const armnn::AdditionQueueDescriptor &data)
Definition:
SampleDynamicAdditionWorkload.cpp:28
src
dynamic
sample
SampleDynamicAdditionWorkload.cpp
Generated on Wed Feb 14 2024 16:36:17 for Arm NN by
1.8.17