From 5ff38da7e18e91243a7f6b8e642f8b40f5846068 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Tue, 2 Mar 2021 09:41:13 +0000 Subject: Create ClPRelu operator Make the class that was in experimental namespace as ClOperator to prepare porting to new interface. The followings are added as a part of this change Also, in-place computation is now correctly considered to be aligned with the class description. Test cases to test in-place computation are added. Partially Implements: COMPMID-4184 Signed-off-by: Sang-Hoon Park Change-Id: I71c18ab47fe0370a2060d5303a58ff3650c0093f Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5201 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio --- src/runtime/CL/functions/CLPReluLayer.cpp | 46 ++++++++----------------------- 1 file changed, 12 insertions(+), 34 deletions(-) (limited to 'src/runtime/CL/functions/CLPReluLayer.cpp') diff --git a/src/runtime/CL/functions/CLPReluLayer.cpp b/src/runtime/CL/functions/CLPReluLayer.cpp index 74286d46ca..bb7aff218d 100644 --- a/src/runtime/CL/functions/CLPReluLayer.cpp +++ b/src/runtime/CL/functions/CLPReluLayer.cpp @@ -21,44 +21,22 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "src/core/gpu/cl/kernels/ClElementwiseKernel.h" - -#include "arm_compute/core/CL/ICLTensor.h" -#include "arm_compute/runtime/CL/CLScheduler.h" #include "arm_compute/runtime/CL/functions/CLPReluLayer.h" +#include "arm_compute/core/CL/CLKernelLibrary.h" +#include "arm_compute/core/CL/ICLTensor.h" +#include "src/core/gpu/cl/IClKernel.h" +#include "src/runtime/gpu/cl/operators/ClPRelu.h" namespace arm_compute { -namespace experimental -{ -CLPReluLayer::CLPReluLayer() -{ -} - -void CLPReluLayer::configure(const CLCompileContext &compile_context, ITensorInfo *input, ITensorInfo *alpha, ITensorInfo *output) -{ - auto k = std::make_unique(); - k->configure(compile_context, ArithmeticOperation::PRELU, input, alpha, output); - _kernel = std::move(k); -} - -Status CLPReluLayer::validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output) -{ - return arm_compute::opencl::kernels::ClArithmeticKernel::validate(ArithmeticOperation::PRELU, input, alpha, output); -} - -void CLPReluLayer::run(ITensorPack &tensors) -{ - ICLOperator::run(tensors); -} -} // namespace experimental +using OperatorType = opencl::ClPRelu; struct CLPReluLayer::Impl { - const ICLTensor *src_0{ nullptr }; - const ICLTensor *src_1{ nullptr }; - ICLTensor *dst{ nullptr }; - std::unique_ptr op{ nullptr }; + const ICLTensor *src_0{ nullptr }; + const ICLTensor *src_1{ nullptr }; + ICLTensor *dst{ nullptr }; + std::unique_ptr op{ nullptr }; }; CLPReluLayer::CLPReluLayer() @@ -79,13 +57,13 @@ void CLPReluLayer::configure(const CLCompileContext &compile_context, ICLTensor _impl->src_0 = input; _impl->src_1 = alpha; _impl->dst = output; - _impl->op = std::make_unique(); - _impl->op->configure(compile_context, input->info(), alpha->info(), output->info()); + _impl->op = std::make_unique(); + _impl->op->configure(compile_context, input->info(), alpha->info(), (output == nullptr ? input->info() : output->info())); } Status CLPReluLayer::validate(const ITensorInfo *input, const ITensorInfo *alpha, const ITensorInfo *output) { - return experimental::CLPReluLayer::validate(input, alpha, output); + return OperatorType::validate(input, alpha, output); } void CLPReluLayer::run() -- cgit v1.2.1