From 9c7fed85d339df64937e8edac3b591b8571ccce8 Mon Sep 17 00:00:00 2001 From: morgolock Date: Wed, 5 Aug 2020 12:30:56 +0100 Subject: COMPMID-3656: Disabled reduce_axis in LOG_SOFTMAX and SOFTMAX Our implementation of reduce_axis is only compliant for default_axis. Validate will throw an error when trying to use a different axis. Change-Id: I4c02aa055bb4474593a3114ec9c83884d3c9120f Signed-off-by: morgolock Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3658 Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins Reviewed-by: SiCong Li --- src/runtime/CL/functions/CLSoftmaxLayer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/runtime/CL/functions/CLSoftmaxLayer.cpp') diff --git a/src/runtime/CL/functions/CLSoftmaxLayer.cpp b/src/runtime/CL/functions/CLSoftmaxLayer.cpp index cd4fdaedd8..f7b2935622 100644 --- a/src/runtime/CL/functions/CLSoftmaxLayer.cpp +++ b/src/runtime/CL/functions/CLSoftmaxLayer.cpp @@ -81,20 +81,20 @@ void CLSoftmaxLayerGeneric::configure_reshape_input_kernel(const CLCompi } template -void CLSoftmaxLayerGeneric::configure(const ICLTensor *input, ICLTensor *output, float beta, size_t reduce_end_axis) +void CLSoftmaxLayerGeneric::configure(const ICLTensor *input, ICLTensor *output, float beta, size_t axis) { - configure(CLKernelLibrary::get().get_compile_context(), input, output, beta, reduce_end_axis); + configure(CLKernelLibrary::get().get_compile_context(), input, output, beta, axis); } template -void CLSoftmaxLayerGeneric::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, float beta, size_t reduce_end_axis) +void CLSoftmaxLayerGeneric::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, float beta, size_t axis) { // Perform validation step ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); - ARM_COMPUTE_ERROR_THROW_ON(CLSoftmaxLayerGeneric::validate(input->info(), output->info(), beta, reduce_end_axis)); + ARM_COMPUTE_ERROR_THROW_ON(CLSoftmaxLayerGeneric::validate(input->info(), output->info(), beta, axis)); // Convert reduce-before axis (inclusive) to first n axes to reduce - size_t first_n_reduce_axes = dim_index_2_num_dims(reduce_end_axis, input->info()->num_dimensions()); + size_t first_n_reduce_axes = dim_index_2_num_dims(axis, input->info()->num_dimensions()); // We only need flattening when the number of axes to reduce is greater than 1 _needs_flattening = first_n_reduce_axes > 1; @@ -171,15 +171,16 @@ void CLSoftmaxLayerGeneric::configure(const CLCompileContext &compile_co } template -Status CLSoftmaxLayerGeneric::validate(const ITensorInfo *input, const ITensorInfo *output, float beta, size_t reduce_end_axis) +Status CLSoftmaxLayerGeneric::validate(const ITensorInfo *input, const ITensorInfo *output, float beta, size_t axis) { ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output); ARM_COMPUTE_RETURN_ERROR_ON_MSG(input->num_dimensions() > 4, "Only up to 4 dimensions are supported"); + ARM_COMPUTE_RETURN_ERROR_ON_MSG(axis != 0, "Only axis 0 supported in tensors"); ARM_COMPUTE_UNUSED(beta); - ARM_COMPUTE_RETURN_ERROR_ON(input->num_dimensions() <= reduce_end_axis); + ARM_COMPUTE_RETURN_ERROR_ON(input->num_dimensions() <= axis); // Convert reduce-before axis (inclusive) to first n axes to reduce - size_t first_n_reduce_axes = dim_index_2_num_dims(reduce_end_axis, input->num_dimensions()); + size_t first_n_reduce_axes = dim_index_2_num_dims(axis, input->num_dimensions()); // Create intermediate tensor info DataType tmp_data_type = is_data_type_quantized_asymmetric(input->data_type()) ? DataType::S32 : input->data_type(); -- cgit v1.2.1