From c7b1e84ac5f3ada1b2f78c66979ef4d44804a955 Mon Sep 17 00:00:00 2001 From: SiCongLi Date: Mon, 22 Feb 2021 14:28:33 +0000 Subject: Remove usage of valid window region in NHWC CPU kernels - Part1 Replace all calculate_max_window(ValidRegion, ...) with calculate_max_window(TensorShape, ...) in CPU kernels Resolves COMPMID-4152 (1/2) Change-Id: I7403ea6b24b9e7889890839142a06439d6c8a499 Signed-off-by: SiCongLi Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5202 Reviewed-by: Georgios Pinitas Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins --- src/core/NEON/kernels/NELogicalKernel.cpp | 5 ++--- .../NEON/kernels/NEPixelWiseMultiplicationKernel.cpp | 20 +++++--------------- src/core/NEON/kernels/NESelectKernel.cpp | 2 +- 3 files changed, 8 insertions(+), 19 deletions(-) (limited to 'src/core/NEON/kernels') diff --git a/src/core/NEON/kernels/NELogicalKernel.cpp b/src/core/NEON/kernels/NELogicalKernel.cpp index d98694ffe1..e1c24da777 100644 --- a/src/core/NEON/kernels/NELogicalKernel.cpp +++ b/src/core/NEON/kernels/NELogicalKernel.cpp @@ -287,9 +287,8 @@ void NELogicalKernel::configure(const ITensorInfo *input1, const ITensorInfo *in if(op != LogicalOperation::Not) { ARM_COMPUTE_ERROR_ON_NULLPTR(input2); - const std::pair broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(*input1, *input2); - out_shape = broadcast_pair.first; - win = calculate_max_window(broadcast_pair.second, Steps()); + out_shape = TensorShape::broadcast_shape(input1->tensor_shape(), input2->tensor_shape()); + win = calculate_max_window(out_shape, Steps()); } ICPPKernel::configure(win); diff --git a/src/core/NEON/kernels/NEPixelWiseMultiplicationKernel.cpp b/src/core/NEON/kernels/NEPixelWiseMultiplicationKernel.cpp index 6661326ea8..b287e18281 100644 --- a/src/core/NEON/kernels/NEPixelWiseMultiplicationKernel.cpp +++ b/src/core/NEON/kernels/NEPixelWiseMultiplicationKernel.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020 Arm Limited. + * Copyright (c) 2016-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -1486,9 +1486,7 @@ void NEPixelWiseMultiplicationKernel::configure(ITensorInfo *input1, ITensorInfo ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input1, input2, output, scale, overflow_policy, rounding_policy)); - const std::pair broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(*input1, *input2); - const TensorShape &out_shape = broadcast_pair.first; - const ValidRegion &valid_region = broadcast_pair.second; + const TensorShape &out_shape = TensorShape::broadcast_shape(input1->tensor_shape(), input2->tensor_shape()); // Auto initialize output if not initialized set_shape_if_empty(*output, out_shape); @@ -1624,10 +1622,7 @@ void NEPixelWiseMultiplicationKernel::configure(ITensorInfo *input1, ITensorInfo } // Configure kernel window - Coordinates coord; - coord.set_num_dimensions(output->num_dimensions()); - output->set_valid_region(valid_region); - Window win = calculate_max_window(valid_region, Steps()); + Window win = calculate_max_window(out_shape); INEKernel::configure(win); } @@ -1692,19 +1687,14 @@ void NEComplexPixelWiseMultiplicationKernel::configure(ITensorInfo *input1, ITen ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output); ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_complex(input1, input2, output)); - const std::pair broadcast_pair = ITensorInfo::broadcast_shape_and_valid_region(*input1, *input2); - const TensorShape &out_shape = broadcast_pair.first; - const ValidRegion &valid_region = broadcast_pair.second; + const TensorShape &out_shape = TensorShape::broadcast_shape(input1->tensor_shape(), input2->tensor_shape()); // Auto initialize output if not initialized const TensorInfo out_info(out_shape, input1->num_channels(), input1->data_type()); auto_init_if_empty(*output, out_info); // Configure kernel window - Coordinates coord; - coord.set_num_dimensions(output->num_dimensions()); - output->set_valid_region(valid_region); - Window win = calculate_max_window(valid_region, Steps()); + Window win = calculate_max_window(out_shape); INEKernel::configure(win); } diff --git a/src/core/NEON/kernels/NESelectKernel.cpp b/src/core/NEON/kernels/NESelectKernel.cpp index 1d5f2b61a1..22cd442889 100644 --- a/src/core/NEON/kernels/NESelectKernel.cpp +++ b/src/core/NEON/kernels/NESelectKernel.cpp @@ -224,7 +224,7 @@ void NESelectKernel::configure(const ITensor *c, const ITensor *x, const ITensor _function = it->second; } - Window win = calculate_max_window(x->info()->valid_region()); + Window win = calculate_max_window(*x->info()); INEKernel::configure(win); } -- cgit v1.2.1