blob: 647677b4fb4d14eab556a45e75b36dfef6489b88 [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5
6#include "RefBaseConstantWorkload.hpp"
7
8#include "RefWorkloadUtils.hpp"
9
10#include <armnn/Types.hpp>
11
12#include <boost/assert.hpp>
13
14#include <cstring>
15
16namespace armnn
17{
18
19template <armnn::DataType DataType>
20void RefBaseConstantWorkload<DataType>::Execute() const
21{
22 // Considering the reference backend independently, it could be possible to initialise the intermediate tensor
23 // created by the layer output handler at workload construction time, rather than at workload execution time.
24 // However, this is not an option for other backends (e.g. CL). For consistency, we prefer to align all
25 // implementations.
26 // A similar argument can be made about performing the memory copy in the first place (the layer output handler
27 // could have a non-owning reference to the layer output tensor managed by the const input layer); again, this is
28 // not an option for other backends, and the extra complexity required to make this work for the reference backend
29 // may not be worth the effort (skipping a memory copy in the first inference).
30 if (!m_RanOnce)
31 {
32 const ConstantQueueDescriptor& data = this->m_Data;
33
34 BOOST_ASSERT(data.m_LayerOutput != nullptr);
35
36 const TensorInfo& outputInfo = GetTensorInfo(data.m_Outputs[0]);
37 BOOST_ASSERT(data.m_LayerOutput->GetTensorInfo().GetNumBytes() == outputInfo.GetNumBytes());
38
39 memcpy(GetOutputTensorData<void>(0, data), data.m_LayerOutput->GetConstTensor<void>(),
40 outputInfo.GetNumBytes());
41
42 m_RanOnce = true;
43 }
44}
45
46template class RefBaseConstantWorkload<DataType::Float32>;
47template class RefBaseConstantWorkload<DataType::QuantisedAsymm8>;
48
49} //namespace armnn