From ff2719299ea76a95f20a35a7900875a8152e293a Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Wed, 17 Jul 2019 15:59:32 +0100 Subject: COMPMID-2336: Fix validation for quantized NEDepthwiseConvolutionLayer Assertions from calculate_quantized_multiplier_less_than_one were not captured resulting in incorrect computation being performed on invalid inputs. This patch also fixes a discrepancy between the interfaces of validate and configure methods of NEDirectConvolutionLayerOutputStageKernel. Change-Id: I011822f63b4062b5b3346ef047adc684e0bffa3d Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/1552 Reviewed-by: Giorgio Arena Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins --- .../kernels/NEDirectConvolutionLayerOutputStageKernel.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/NEON/kernels/NEDirectConvolutionLayerOutputStageKernel.cpp b/src/core/NEON/kernels/NEDirectConvolutionLayerOutputStageKernel.cpp index 7e113935c5..7c029a6b54 100644 --- a/src/core/NEON/kernels/NEDirectConvolutionLayerOutputStageKernel.cpp +++ b/src/core/NEON/kernels/NEDirectConvolutionLayerOutputStageKernel.cpp @@ -42,14 +42,18 @@ using namespace arm_compute; namespace { -Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output) +Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, + int result_fixedpoint_multiplier, int result_shift, int result_offset_after_shift) { + ARM_COMPUTE_UNUSED(result_fixedpoint_multiplier); + ARM_COMPUTE_UNUSED(result_offset_after_shift); ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input); ARM_COMPUTE_RETURN_ERROR_ON(input->data_layout() == DataLayout::UNKNOWN); ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QASYMM8, DataType::F16, DataType::S32, DataType::F32); + ARM_COMPUTE_RETURN_ERROR_ON_MSG(result_shift < 0, "Result shift must be a non negative integer"); if(bias != nullptr) { ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(bias, 1, DataType::F16, DataType::S32, DataType::F32); @@ -475,7 +479,8 @@ void NEDirectConvolutionLayerOutputStageKernel::configure(ITensor *input, const } // Perform validation step - ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (bias == nullptr) ? nullptr : bias->info(), (output == nullptr) ? nullptr : output->info())); + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (bias == nullptr) ? nullptr : bias->info(), (output == nullptr) ? nullptr : output->info(), + result_fixedpoint_multiplier, result_shift, result_offset_after_shift)); _func = nullptr; _bias = bias; @@ -577,9 +582,10 @@ void NEDirectConvolutionLayerOutputStageKernel::configure(ITensor *input, const } } -Status NEDirectConvolutionLayerOutputStageKernel::validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output) +Status NEDirectConvolutionLayerOutputStageKernel::validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, + int result_fixedpoint_multiplier, int result_shift, int result_offset_after_shift) { - ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, bias, output)); + ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, bias, output, result_fixedpoint_multiplier, result_shift, result_offset_after_shift)); ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), bias == nullptr ? nullptr : bias->clone().get(), output == nullptr ? nullptr : output->clone().get()).first); return Status{}; -- cgit v1.2.1