telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #include "NeonWorkloadUtils.hpp" |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame^] | 6 | #include <backends/aclCommon/ArmComputeTensorUtils.hpp> |
| 7 | #include <backends/aclCommon/ArmComputeUtils.hpp> |
| 8 | #include <backends/CpuTensorHandle.hpp> |
| 9 | #include <backends/NeonTensorHandle.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 10 | |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame^] | 11 | #include <armnn/Utils.hpp> |
| 12 | #include <armnn/Exceptions.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 14 | #include <cstring> |
| 15 | #include <boost/assert.hpp> |
| 16 | #include <boost/cast.hpp> |
| 17 | #include <boost/format.hpp> |
| 18 | |
| 19 | #include "Profiling.hpp" |
| 20 | |
| 21 | #include "NeonLayerSupport.hpp" |
David Beck | 711fa31 | 2018-09-24 10:46:38 +0100 | [diff] [blame^] | 22 | #include <armnn/Types.hpp> |
| 23 | #include <Half.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 24 | |
| 25 | using namespace armnn::armcomputetensorutils; |
| 26 | |
| 27 | namespace armnn |
| 28 | { |
| 29 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 30 | // Allocates a tensor and copy the contents in data to the tensor contents. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 31 | template<typename T> |
| 32 | void InitialiseArmComputeTensorData(arm_compute::Tensor& tensor, const T* data) |
| 33 | { |
| 34 | InitialiseArmComputeTensorEmpty(tensor); |
| 35 | CopyArmComputeITensorData(data, tensor); |
| 36 | } |
| 37 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 38 | template void InitialiseArmComputeTensorData(arm_compute::Tensor& tensor, const Half* data); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | template void InitialiseArmComputeTensorData(arm_compute::Tensor& tensor, const float* data); |
| 40 | template void InitialiseArmComputeTensorData(arm_compute::Tensor& tensor, const uint8_t* data); |
| 41 | template void InitialiseArmComputeTensorData(arm_compute::Tensor& tensor, const int32_t* data); |
| 42 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 43 | void InitializeArmComputeTensorDataForFloatTypes(arm_compute::Tensor& tensor, |
| 44 | const ConstCpuTensorHandle* handle) |
| 45 | { |
| 46 | BOOST_ASSERT(handle); |
| 47 | switch(handle->GetTensorInfo().GetDataType()) |
| 48 | { |
| 49 | case DataType::Float16: |
| 50 | InitialiseArmComputeTensorData(tensor, handle->GetConstTensor<Half>()); |
| 51 | break; |
| 52 | case DataType::Float32: |
| 53 | InitialiseArmComputeTensorData(tensor, handle->GetConstTensor<float>()); |
| 54 | break; |
| 55 | default: |
| 56 | BOOST_ASSERT_MSG(false, "Unexpected floating point type."); |
| 57 | } |
| 58 | }; |
| 59 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 60 | } //namespace armnn |