From e2af6f4322a1e2b8b3c391fb721a6a80c281477f Mon Sep 17 00:00:00 2001 From: Narumol Prangnawarat Date: Fri, 28 Jan 2022 17:59:18 +0000 Subject: IVGCVSW-6552 Add support of aligned host memory * Add AllocatedData functions to OutputHandler * Enable import aligned memory in ImportInputs * Enable import aligned memory in ImportOutputs * Allow to import input and output if the memory is aligned * Implement Reconfigure function on ClConvolution2dWorkload * End-to-end test on Ref and Cl to ensure that input and output memory are imported when aligned Signed-off-by: Narumol Prangnawarat Change-Id: I9e5e4c26d1ac2f1d806803ade5f64c6479c51718 --- src/backends/cl/workloads/ClBaseWorkload.hpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/backends/cl/workloads/ClBaseWorkload.hpp') diff --git a/src/backends/cl/workloads/ClBaseWorkload.hpp b/src/backends/cl/workloads/ClBaseWorkload.hpp index e74fc84f4f..03417e33ae 100644 --- a/src/backends/cl/workloads/ClBaseWorkload.hpp +++ b/src/backends/cl/workloads/ClBaseWorkload.hpp @@ -20,17 +20,38 @@ public: // Replace input tensor handle with the given TensorHandle and call Reconfigure() void ReplaceInputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override { + ITensorHandle* backupHandle = this->m_Data.m_Inputs[slot]; this->m_Data.m_Inputs[slot] = tensorHandle; - Reconfigure(); + try + { + Reconfigure(); + } + catch(armnn::UnimplementedException& e) + { + // Cannot reconfigure, revert the slot back and throw the exception. + this->m_Data.m_Inputs[slot] = backupHandle; + throw e; + } } // Replace output tensor handle with the given TensorHandle and call Reconfigure() void ReplaceOutputTensorHandle(ITensorHandle* tensorHandle, unsigned int slot) override { + ITensorHandle* backupHandle = this->m_Data.m_Outputs[slot]; this->m_Data.m_Outputs[slot] = tensorHandle; - Reconfigure(); + try + { + Reconfigure(); + } + catch(armnn::UnimplementedException& e) + { + // Cannot reconfigure, revert the slot back and throw the exception. + this->m_Data.m_Inputs[slot] = backupHandle; + throw e; + } } +protected: // Reconfigure the workload configuration. Throw armnn::UnimplementedException by default. virtual void Reconfigure() { -- cgit v1.2.1