diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-05-11 14:19:13 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:52:06 +0000 |
commit | 1b4cbc0e9aba5ffb19f07d10dc102f532762b7d2 (patch) | |
tree | ccf098a5c61fd94ccc4e6d6dbbebcb8f56940fd8 /src/core/CL/kernels | |
parent | 851a322305f670225f17c516d70720d00cb44711 (diff) | |
download | ComputeLibrary-1b4cbc0e9aba5ffb19f07d10dc102f532762b7d2.tar.gz |
COMPMID-1142: (OCLGrind) Invalid read in batchnormalization_layer_nhwc
Adds padding to mean/var/beta/gamma as in nhwc their process step is not
1.
Change-Id: Ibd2de58fa2e6b8a8eb2414496cc19371bfa40571
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/130894
Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CL/kernels')
-rw-r--r-- | src/core/CL/kernels/CLBatchNormalizationLayerKernel.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/src/core/CL/kernels/CLBatchNormalizationLayerKernel.cpp b/src/core/CL/kernels/CLBatchNormalizationLayerKernel.cpp index 3a2211c522..293361b963 100644 --- a/src/core/CL/kernels/CLBatchNormalizationLayerKernel.cpp +++ b/src/core/CL/kernels/CLBatchNormalizationLayerKernel.cpp @@ -83,7 +83,8 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, return Status{}; } -std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output) +std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, + ITensorInfo *mean, ITensorInfo *var, ITensorInfo *beta, ITensorInfo *gamma) { if(output != nullptr) { @@ -109,6 +110,24 @@ std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITen window_changed = update_window_and_padding(win, input_access); } + if(input->data_layout() == DataLayout::NHWC) + { + AccessWindowHorizontal mean_access(mean, 0, num_elems_processed_per_iteration); + AccessWindowHorizontal var_access(var, 0, num_elems_processed_per_iteration); + window_changed = window_changed || update_window_and_padding(win, mean_access, var_access); + + if(beta != nullptr) + { + AccessWindowHorizontal beta_access(beta, 0, num_elems_processed_per_iteration); + window_changed = window_changed || update_window_and_padding(win, beta_access); + } + if(gamma != nullptr) + { + AccessWindowHorizontal gamma_access(gamma, 0, num_elems_processed_per_iteration); + window_changed = window_changed || update_window_and_padding(win, gamma_access); + } + } + Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{}; return std::make_pair(err, win); } @@ -169,7 +188,10 @@ void CLBatchNormalizationLayerKernel::configure(ICLTensor *input, ICLTensor *out _kernel.setArg<cl_float>(idx++, _epsilon); // Configure kernel window - auto win_config = validate_and_configure_window(input->info(), (_run_in_place) ? nullptr : output->info()); + auto win_config = validate_and_configure_window(input->info(), (_run_in_place) ? nullptr : output->info(), + mean->info(), var->info(), + (beta != nullptr) ? beta->info() : nullptr, + (gamma != nullptr) ? gamma->info() : nullptr); ARM_COMPUTE_ERROR_THROW_ON(win_config.first); ICLKernel::configure(win_config.second); @@ -192,7 +214,11 @@ Status CLBatchNormalizationLayerKernel::validate(const ITensorInfo *input, const { const bool run_in_place = (output == nullptr) || (output == input); ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, mean, var, beta, gamma, epsilon, act_info)); - ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), (run_in_place) ? nullptr : output->clone().get()).first); + ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), (run_in_place) ? nullptr : output->clone().get(), + mean->clone().get(), var->clone().get(), + (beta != nullptr) ? beta->clone().get() : nullptr, + (gamma != nullptr) ? gamma->clone().get() : nullptr) + .first); return Status{}; } |