| 119 | } |
| 120 | |
| 121 | void NEReductionOperation::configure( |
| 122 | ITensor *input, ITensor *output, unsigned int axis, ReductionOperation op, bool keep_dims) |
| 123 | { |
| 124 | ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "NEReductionOperation::configure"); |
| 125 | ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); |
| 126 | ARM_COMPUTE_LOG_PARAMS(input, output, axis, op, keep_dims); |
| 127 | |
| 128 | _is_reshape_required = !keep_dims; |
| 129 | |
| 130 | auto *output_internal = output; |
| 131 | const auto is_arg_min_max = (op == ReductionOperation::ARG_IDX_MAX) || (op == ReductionOperation::ARG_IDX_MIN); |
| 132 | |
| 133 | if (_is_reshape_required) |
| 134 | { |
| 135 | const auto output_internal_shape = |
| 136 | arm_compute::misc::shape_calculator::compute_reduced_shape(input->info()->tensor_shape(), axis); |
| 137 | const auto output_external_shape = |
| 138 | arm_compute::misc::shape_calculator::compute_reduced_shape(input->info()->tensor_shape(), axis, false); |
| 139 | const auto output_data_type = is_arg_min_max ? DataType::S32 : input->info()->data_type(); |
| 140 | const auto num_channels = input->info()->num_channels(); |
| 141 | const auto qinfo = input->info()->quantization_info(); |
| 142 | |
| 143 | _output_internal.allocator()->init(input->info() |
| 144 | ->clone() |
| 145 | ->set_data_type(output_data_type) |
| 146 | .set_tensor_shape(output_internal_shape) |
| 147 | .reset_padding() |
| 148 | .set_is_resizable(true) |
| 149 | .set_num_channels(num_channels) |
| 150 | .set_quantization_info(qinfo)); |
| 151 | _memory_group.manage(&_output_internal); |
| 152 | output_internal = &_output_internal; |
| 153 | auto_init_if_empty(*output->info(), input->info() |
| 154 | ->clone() |
| 155 | ->set_data_type(output_data_type) |
| 156 | .set_tensor_shape(output_external_shape) |
| 157 | .reset_padding() |
| 158 | .set_is_resizable(true)); |
| 159 | } |
| 160 | |
| 161 | ARM_COMPUTE_ERROR_THROW_ON(NEReductionOperation::validate(input->info(), output->info(), axis, op, keep_dims)); |
| 162 | |
| 163 | // Configure reduction kernel |
| 164 | _reduction_kernel = std::make_unique<NEReductionOperationKernel>(); |
| 165 | _reduction_kernel->configure(input, output_internal, axis, op); |
| 166 | _window_split = reduction_window_split_dimension(axis); |
| 167 | _reduction_axis = axis; |
| 168 | |
| 169 | if (_is_reshape_required) |
| 170 | { |
| 171 | _reshape.configure(output_internal, output); |
| 172 | _output_internal.allocator()->allocate(); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | void NEReductionOperation::run() |
| 177 | { |
nothing calls this directly
no test coverage detected