diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2017-11-14 15:32:57 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | 30902ed3befd225cb3a6915223d0941949b8d265 (patch) | |
tree | 6f701094ae52e8e4dc41b993febbff404e660c82 /src/runtime/CL/functions | |
parent | 77f0f879f8a9371e50fb1c5b2b5f7252b839883c (diff) | |
download | ComputeLibrary-30902ed3befd225cb3a6915223d0941949b8d265.tar.gz |
COMPMID-617: Add validation methods to ML CL functions.
Adds validation support to:
- CLDirectConvolution
- CLNormalizationLayer
- CLSoftmaxLayer
Change-Id: I9bd1e925e6db057c799169405f82ed21d20b87ee
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/95939
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'src/runtime/CL/functions')
-rw-r--r-- | src/runtime/CL/functions/CLDirectConvolutionLayer.cpp | 5 | ||||
-rw-r--r-- | src/runtime/CL/functions/CLNormalizationLayer.cpp | 5 | ||||
-rw-r--r-- | src/runtime/CL/functions/CLSoftmaxLayer.cpp | 37 |
3 files changed, 41 insertions, 6 deletions
diff --git a/src/runtime/CL/functions/CLDirectConvolutionLayer.cpp b/src/runtime/CL/functions/CLDirectConvolutionLayer.cpp index 6fafd9c7f1..8ef7068b88 100644 --- a/src/runtime/CL/functions/CLDirectConvolutionLayer.cpp +++ b/src/runtime/CL/functions/CLDirectConvolutionLayer.cpp @@ -48,6 +48,11 @@ void CLDirectConvolutionLayer::configure(ICLTensor *input, const ICLTensor *weig _input_border_handler.configure(input, _direct_conv_kernel.border_size(), BorderMode::CONSTANT, PixelValue(0)); } +Error CLDirectConvolutionLayer::validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info) +{ + return CLDirectConvolutionLayerKernel::validate(input, weights, biases, output, conv_info); +} + void CLDirectConvolutionLayer::run() { // Run border handler diff --git a/src/runtime/CL/functions/CLNormalizationLayer.cpp b/src/runtime/CL/functions/CLNormalizationLayer.cpp index 648ce6b3a6..eefdec4ba4 100644 --- a/src/runtime/CL/functions/CLNormalizationLayer.cpp +++ b/src/runtime/CL/functions/CLNormalizationLayer.cpp @@ -48,6 +48,11 @@ void CLNormalizationLayer::configure(ICLTensor *input, ICLTensor *output, const _border_handler.configure(input, _norm_kernel.border_size(), BorderMode::CONSTANT, PixelValue(0)); } +Error CLNormalizationLayer::validate(const ITensorInfo *input, const ITensorInfo *output, const NormalizationLayerInfo &norm_info) +{ + return CLNormalizationLayerKernel::validate(input, output, norm_info); +} + void CLNormalizationLayer::run() { // Run border handler diff --git a/src/runtime/CL/functions/CLSoftmaxLayer.cpp b/src/runtime/CL/functions/CLSoftmaxLayer.cpp index ff018d595c..d39335b6e5 100644 --- a/src/runtime/CL/functions/CLSoftmaxLayer.cpp +++ b/src/runtime/CL/functions/CLSoftmaxLayer.cpp @@ -45,16 +45,13 @@ void CLSoftmaxLayer::configure(const ICLTensor *input, ICLTensor *output, float // Create intermediate tensors shapes DataType tmp_data_type = is_data_type_quantized_asymmetric(input->info()->data_type()) ? DataType::S32 : input->info()->data_type(); - TensorInfo tensor_info_tmp(input->info()->tensor_shape(), input->info()->num_channels(), tmp_data_type, input->info()->fixed_point_position()); - tensor_info_tmp.set_quantization_info(input->info()->quantization_info()); + TensorInfo tensor_info_tmp(input->info()->clone()->set_data_type(tmp_data_type).reset_padding()); _tmp.allocator()->init(tensor_info_tmp); TensorShape max_sum_shape = input->info()->tensor_shape(); max_sum_shape.set(0, 1); - TensorInfo tensor_info_max(max_sum_shape, input->info()->num_channels(), input->info()->data_type(), input->info()->fixed_point_position()); - tensor_info_max.set_quantization_info(input->info()->quantization_info()); - _max.allocator()->init(tensor_info_max); - _sum.allocator()->init(TensorInfo(max_sum_shape, input->info()->num_channels(), tmp_data_type, input->info()->fixed_point_position())); + _max.allocator()->init(input->info()->clone()->set_tensor_shape(max_sum_shape).reset_padding()); + _sum.allocator()->init(input->info()->clone()->set_tensor_shape(max_sum_shape).set_data_type(tmp_data_type).reset_padding()); // Set GPU target to kernels _max_shift_exp_sum_kernel.set_target(CLScheduler::get().target()); @@ -84,6 +81,34 @@ void CLSoftmaxLayer::configure(const ICLTensor *input, ICLTensor *output, float _sum.allocator()->allocate(); } +Error CLSoftmaxLayer::validate(const ITensorInfo *input, const ITensorInfo *output) +{ + ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input); + + // Create intermediate tensor info + DataType tmp_data_type = is_data_type_quantized_asymmetric(input->data_type()) ? DataType::S32 : input->data_type(); + TensorInfo tensor_info_tmp(input->clone()->set_data_type(tmp_data_type)); + + TensorShape max_sum_shape = input->tensor_shape(); + max_sum_shape.set(0, 1); + TensorInfo tensor_info_max(input->clone()->set_tensor_shape(max_sum_shape)); + TensorInfo tensor_info_sum(input->clone()->set_tensor_shape(max_sum_shape).set_data_type(tmp_data_type).set_quantization_info(QuantizationInfo())); + + bool run_legacy_path = is_data_type_quantized_asymmetric(input->data_type()); + if(run_legacy_path) + { + ARM_COMPUTE_RETURN_ON_ERROR(CLLogits1DMaxKernel::validate(input, &tensor_info_max)); + ARM_COMPUTE_RETURN_ON_ERROR(CLLogits1DShiftExpSumKernel::validate(input, &tensor_info_max, &tensor_info_tmp, &tensor_info_sum)); + } + else + { + ARM_COMPUTE_RETURN_ON_ERROR(CLLogits1DMaxShiftExpSumKernel::validate(input, &tensor_info_max, &tensor_info_tmp, &tensor_info_sum)); + } + ARM_COMPUTE_RETURN_ON_ERROR(CLLogits1DNormKernel::validate(&tensor_info_tmp, &tensor_info_sum, output)); + + return Error{}; +} + void CLSoftmaxLayer::run() { _memory_group.acquire(); |