blob: 63f3539164649642e4d89dd08b5ebcd5c332002e [file] [log] [blame]
Teresa Charlin98b0dcb2022-01-18 22:09:29 +00001//
2// Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8#include <armnn/backends/Workload.hpp>
9
10namespace armnn
11{
12template <typename QueueDescriptor>
13class NeonBaseWorkload : public BaseWorkload<QueueDescriptor>
14{
15public:
16 NeonBaseWorkload(const QueueDescriptor& descriptor, const WorkloadInfo& info)
17 : BaseWorkload<QueueDescriptor>(descriptor, info)
18 {}
19
20 // Replace input tensor handle with the given TensorHandle and call Reconfigure()
21 void ReplaceInputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override
22 {
Narumol Prangnawarate2af6f42022-01-28 17:59:18 +000023 ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot];
Teresa Charlin98b0dcb2022-01-18 22:09:29 +000024 this->m_Data.m_Inputs[slot] = tensorHandle;
Narumol Prangnawarate2af6f42022-01-28 17:59:18 +000025 try
26 {
27 Reconfigure();
28 }
29 catch(armnn::UnimplementedException& e)
30 {
31 // Cannot reconfigure, revert the slot back and throw the exception.
32 this->m_Data.m_Inputs[slot] = backupHandle;
33 throw e;
34 }
Teresa Charlin98b0dcb2022-01-18 22:09:29 +000035 }
36
37 // Replace output tensor handle with the given TensorHandle and call Reconfigure()
38 void ReplaceOutputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override
39 {
Narumol Prangnawarate2af6f42022-01-28 17:59:18 +000040 ITensorHandle* backupHandle = this->m_Data.m_Outputs[slot];
Teresa Charlin98b0dcb2022-01-18 22:09:29 +000041 this->m_Data.m_Outputs[slot] = tensorHandle;
Narumol Prangnawarate2af6f42022-01-28 17:59:18 +000042 try
43 {
44 Reconfigure();
45 }
46 catch(armnn::UnimplementedException& e)
47 {
48 // Cannot reconfigure, revert the slot back and throw the exception.
49 this->m_Data.m_Inputs[slot] = backupHandle;
50 throw e;
51 }
Teresa Charlin98b0dcb2022-01-18 22:09:29 +000052 }
53
Narumol Prangnawarate2af6f42022-01-28 17:59:18 +000054protected:
Teresa Charlin98b0dcb2022-01-18 22:09:29 +000055 // Reconfigure the workload configuration. Throw armnn::UnimplementedException by default.
56 virtual void Reconfigure()
57 {
58 throw armnn::UnimplementedException("Reconfigure not implemented for this workload");
59 }
60};
61} //namespace armnn