diff options
author | Sheri Zhang <sheri.zhang@arm.com> | 2020-10-28 14:01:55 +0000 |
---|---|---|
committer | Sheri Zhang <sheri.zhang@arm.com> | 2020-10-29 10:59:49 +0000 |
commit | 11d73272b8df5ceb2629fb916b84c768b7c5c65a (patch) | |
tree | bf05af923ac27c720d033bf7b671e7266487f5a0 /src/core/CL/kernels/CLFlattenLayerKernel.cpp | |
parent | 7292362dce62b3f39d6c35e9601b5c12ab770a3f (diff) | |
download | ComputeLibrary-11d73272b8df5ceb2629fb916b84c768b7c5c65a.tar.gz |
COMPMID-3706: Add padding assert for kernels that don't have padding
Signed-off-by: Sheri Zhang <sheri.zhang@arm.com>
Change-Id: I0a3f0a989a4db9a2abc9c89429e94af4c6b6b366
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4274
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Manuel Bottini <manuel.bottini@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLFlattenLayerKernel.cpp')
-rw-r--r-- | src/core/CL/kernels/CLFlattenLayerKernel.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/core/CL/kernels/CLFlattenLayerKernel.cpp b/src/core/CL/kernels/CLFlattenLayerKernel.cpp index dc1d33869f..590fcee6fd 100644 --- a/src/core/CL/kernels/CLFlattenLayerKernel.cpp +++ b/src/core/CL/kernels/CLFlattenLayerKernel.cpp @@ -52,18 +52,6 @@ Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output) return Status{}; } - -std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output) -{ - // Output tensor auto initialization if not yet initialized - auto_init_if_empty(*output, input->clone()->set_tensor_shape(compute_flatten_shape(input))); - - Window win = calculate_max_window(*input, Steps()); // Flatten does not need paddings - - output->set_valid_region(ValidRegion(Coordinates(), output->tensor_shape())); - - return std::make_pair(Status{}, win); -} } // namespace CLFlattenLayerKernel::CLFlattenLayerKernel() @@ -79,16 +67,17 @@ void CLFlattenLayerKernel::configure(const ICLTensor *input, ICLTensor *output) void CLFlattenLayerKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output) { ARM_COMPUTE_ERROR_ON_NULLPTR(input, output); + + // Output tensor auto initialization if not yet initialized + auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(compute_flatten_shape(input->info()))); + + auto padding_info = get_padding_info({ input, output }); + ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info())); _input = input; _output = output; - // Configure kernel window - auto win_config = validate_and_configure_window(input->info(), output->info()); - ARM_COMPUTE_ERROR_THROW_ON(win_config.first); - ICLKernel::configure_internal(win_config.second); - CLBuildOptions build_opts; build_opts.add_option("-DDATA_TYPE=" + get_cl_unsigned_type_from_element_size(data_size_from_type(input->info()->data_type()))); build_opts.add_option("-DSRC_WIDTH=" + support::cpp11::to_string(input->info()->dimension(0))); @@ -99,6 +88,14 @@ void CLFlattenLayerKernel::configure(const CLCompileContext &compile_context, co // Create kernel _kernel = create_kernel(compile_context, "flatten", build_opts.options()); + // Configure kernel window + Window win = calculate_max_window(*input->info(), Steps()); + ICLKernel::configure_internal(win); + + output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape())); + + ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info)); + // Set config_id for enabling LWS tuning _config_id = "flatten"; _config_id += "_"; @@ -118,7 +115,6 @@ void CLFlattenLayerKernel::configure(const CLCompileContext &compile_context, co Status CLFlattenLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output) { ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output)); - ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get()).first); return Status{}; } |