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 | #pragma once |
| 6 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 7 | #include <backendsCommon/Workload.hpp> |
| 8 | #include <aclCommon/ArmComputeTensorUtils.hpp> |
| 9 | #include <neon/NeonTensorHandle.hpp> |
| 10 | #include <neon/NeonTimer.hpp> |
| 11 | #include <backendsCommon/CpuTensorHandle.hpp> |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame] | 12 | #include <arm_compute/runtime/NEON/NEFunctions.h> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
Nattapat Chaimanowong | 177d8d2 | 2018-10-16 13:21:27 +0100 | [diff] [blame] | 14 | #include <Half.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 15 | |
Nattapat Chaimanowong | 177d8d2 | 2018-10-16 13:21:27 +0100 | [diff] [blame] | 16 | #define ARMNN_SCOPED_PROFILING_EVENT_NEON(name) \ |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 17 | ARMNN_SCOPED_PROFILING_EVENT_WITH_INSTRUMENTS(armnn::Compute::CpuAcc, \ |
| 18 | name, \ |
Nina Drozd | 69851b5 | 2018-09-21 18:42:09 +0100 | [diff] [blame] | 19 | armnn::NeonTimer(), \ |
| 20 | armnn::WallClockTimer()) |
Nattapat Chaimanowong | 177d8d2 | 2018-10-16 13:21:27 +0100 | [diff] [blame] | 21 | |
| 22 | using namespace armnn::armcomputetensorutils; |
| 23 | |
| 24 | namespace armnn |
| 25 | { |
| 26 | |
| 27 | template <typename T> |
| 28 | void CopyArmComputeTensorData(arm_compute::Tensor& dstTensor, const T* srcData) |
| 29 | { |
| 30 | InitialiseArmComputeTensorEmpty(dstTensor); |
| 31 | CopyArmComputeITensorData(srcData, dstTensor); |
| 32 | } |
| 33 | |
| 34 | inline void InitializeArmComputeTensorData(arm_compute::Tensor& tensor, |
| 35 | const ConstCpuTensorHandle* handle) |
| 36 | { |
| 37 | BOOST_ASSERT(handle); |
| 38 | |
| 39 | switch(handle->GetTensorInfo().GetDataType()) |
| 40 | { |
| 41 | case DataType::Float16: |
| 42 | CopyArmComputeTensorData(tensor, handle->GetConstTensor<armnn::Half>()); |
| 43 | break; |
| 44 | case DataType::Float32: |
| 45 | CopyArmComputeTensorData(tensor, handle->GetConstTensor<float>()); |
| 46 | break; |
| 47 | case DataType::QuantisedAsymm8: |
| 48 | CopyArmComputeTensorData(tensor, handle->GetConstTensor<uint8_t>()); |
| 49 | break; |
| 50 | case DataType::Signed32: |
| 51 | CopyArmComputeTensorData(tensor, handle->GetConstTensor<int32_t>()); |
| 52 | break; |
| 53 | default: |
| 54 | BOOST_ASSERT_MSG(false, "Unexpected tensor type."); |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | } //namespace armnn |