From 232c45253a84c16fc70eae6406cac5f4048efaca Mon Sep 17 00:00:00 2001 From: Giorgio Arena Date: Thu, 3 Mar 2022 10:09:01 +0000 Subject: Merge kernel prototype patch Resolves: COMPMID-5151 Signed-off-by: Giorgio Arena Change-Id: Ic4024d5cd4819fe917a1d49621f1866ae2e90a37 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7260 Tested-by: Arm Jenkins Reviewed-by: SiCong Li Comments-Addressed: Arm Jenkins --- src/runtime/CL/CLScheduler.cpp | 44 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'src/runtime/CL') diff --git a/src/runtime/CL/CLScheduler.cpp b/src/runtime/CL/CLScheduler.cpp index 9d340438b8..22bf850d6e 100644 --- a/src/runtime/CL/CLScheduler.cpp +++ b/src/runtime/CL/CLScheduler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021 Arm Limited. + * Copyright (c) 2016-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -27,6 +27,10 @@ #include "arm_compute/runtime/CL/CLTuner.h" #include "src/core/CL/ICLKernel.h" +#if defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION) +#include "src/gpu/cl/kernels/experimental/dynamic_fusion/ClCompositeKernel.h" +#endif // defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION) + namespace arm_compute { cl::Context &CLScheduler::context() @@ -185,6 +189,35 @@ void CLScheduler::enqueue_common(ICLKernel &kernel, ITensorPack &tensors, bool f } } +#if defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION) + +void CLScheduler::enqueue_common(ICLKernel &kernel, experimental::dynamic_fusion::TensorBinding &tensors, const experimental::dynamic_fusion::ClExecutionDescriptor &exec_desc, bool flush) +{ + ARM_COMPUTE_ERROR_ON_MSG(!_is_initialised, + "The CLScheduler is not initialised yet! Please call the CLScheduler::get().default_init(), \ + or CLScheduler::get()::init() and CLKernelLibrary::get()::init() function before running functions!"); + + const bool inject_memory = !tensors._binding.empty(); + + // Run kernel + inject_memory ? kernel.run_composite_op(tensors, kernel.window(), _queue, exec_desc) : kernel.run(kernel.window(), _queue); + + if(_job_chaining_enabled) + { + if(++_job_chaining_count >= _job_chaining_size) + { + _job_chaining_count = 0; + _queue.flush(); + } + } + else if(flush) + { + _queue.flush(); + } +} + +#endif // defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION) + void CLScheduler::enqueue(ICLKernel &kernel, bool flush) { ITensorPack pack; @@ -196,6 +229,15 @@ void CLScheduler::enqueue_op(ICLKernel &kernel, ITensorPack &tensors, bool flush enqueue_common(kernel, tensors, flush); } +#if defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION) + +void CLScheduler::enqueue_op(ICLKernel &kernel, experimental::dynamic_fusion::TensorBinding &tensors, const experimental::dynamic_fusion::ClExecutionDescriptor &exec_desc, bool flush) +{ + enqueue_common(kernel, tensors, exec_desc, flush); +} + +#endif // defined(ENABLE_EXPERIMENTAL_DYNAMIC_FUSION) + void CLScheduler::enable_job_chaining(int job_chaining_size) { _job_chaining_enabled = true; -- cgit v1.2.1