From cd083cf70fed41858407d1f7e082f760a2dbe87a Mon Sep 17 00:00:00 2001 From: Murray Kornelsen Date: Wed, 13 Jul 2022 20:43:15 -0400 Subject: Use parent buffer in CLSubTensor. This avoids calling enqueueMapBuffer repeatedly when mapping multiple children of the same parent. Signed-off-by: Murray Kornelsen Change-Id: I7ff554915a37320dfd94f15a6fb01a72a235cf39 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7920 Reviewed-by: Gunes Bayir Reviewed-by: Pablo Marquez Tello Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Benchmark: Arm Jenkins --- src/runtime/CL/CLSubTensor.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/runtime/CL') diff --git a/src/runtime/CL/CLSubTensor.cpp b/src/runtime/CL/CLSubTensor.cpp index d0822414c3..14936ae23c 100644 --- a/src/runtime/CL/CLSubTensor.cpp +++ b/src/runtime/CL/CLSubTensor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 Arm Limited. + * Copyright (c) 2017-2019, 2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -81,11 +81,15 @@ void CLSubTensor::unmap() uint8_t *CLSubTensor::do_map(cl::CommandQueue &q, bool blocking) { ARM_COMPUTE_ERROR_ON(cl_buffer().get() == nullptr); - return static_cast(q.enqueueMapBuffer(cl_buffer(), blocking ? CL_TRUE : CL_FALSE, CL_MAP_READ | CL_MAP_WRITE, 0, info()->total_size())); + if(_parent->buffer() == nullptr) + { + _parent->map(q, blocking); + } + return _parent->buffer(); } void CLSubTensor::do_unmap(cl::CommandQueue &q) { ARM_COMPUTE_ERROR_ON(cl_buffer().get() == nullptr); - q.enqueueUnmapMemObject(cl_buffer(), buffer()); + _parent->unmap(q); } -- cgit v1.2.1