aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/kernels/CLReshapeLayerKernel.cpp
diff options
context:
space:
mode:
authorGiuseppe Rossini <giuseppe.rossini@arm.com>2018-08-22 12:07:48 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:54:54 +0000
commit84797636b0ad44c16838df4177cf5a05aa929781 (patch)
tree28570365dca0eb915ec29eec85441c9c2833b76f /src/core/CL/kernels/CLReshapeLayerKernel.cpp
parent77589b58d55a181d49d5d94126c7e204af2835bc (diff)
downloadComputeLibrary-84797636b0ad44c16838df4177cf5a05aa929781.tar.gz
[COMPMID-1483] Add validate method to CLReshapeLayer
Change-Id: I33079e07acad83e0740c87b06546cc0f0f51301c Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/145164 Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLReshapeLayerKernel.cpp')
-rw-r--r--src/core/CL/kernels/CLReshapeLayerKernel.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/core/CL/kernels/CLReshapeLayerKernel.cpp b/src/core/CL/kernels/CLReshapeLayerKernel.cpp
index c7efa9a82d..a275e9e874 100644
--- a/src/core/CL/kernels/CLReshapeLayerKernel.cpp
+++ b/src/core/CL/kernels/CLReshapeLayerKernel.cpp
@@ -39,6 +39,25 @@
using namespace arm_compute;
+namespace
+{
+Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input);
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8, DataType::S8, DataType::QASYMM8,
+ DataType::U16, DataType::S16,
+ DataType::U32, DataType::S32, DataType::F16, DataType::F32);
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(output);
+
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input, output);
+ ARM_COMPUTE_RETURN_ERROR_ON(input->tensor_shape().total_size() != output->tensor_shape().total_size());
+
+ return Status{};
+}
+
+} // namespace
+
CLReshapeLayerKernel::CLReshapeLayerKernel()
: _input(nullptr), _output(nullptr)
{
@@ -46,20 +65,12 @@ CLReshapeLayerKernel::CLReshapeLayerKernel()
void CLReshapeLayerKernel::configure(const ICLTensor *input, ICLTensor *output)
{
- ARM_COMPUTE_ERROR_ON_F16_UNSUPPORTED(input);
- ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::U8, DataType::S8, DataType::QASYMM8,
- DataType::U16, DataType::S16,
- DataType::U32, DataType::S32, DataType::F16, DataType::F32);
- ARM_COMPUTE_ERROR_ON_NULLPTR(output);
- ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
- ARM_COMPUTE_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input, output);
- ARM_COMPUTE_ERROR_ON(input->info()->tensor_shape().total_size() != output->info()->tensor_shape().total_size());
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
+ ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
_input = input;
_output = output;
- constexpr unsigned int num_elems_processed_per_iteration = 1;
-
// Create kernel
std::set<std::string> build_opts = { "-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type()) };
_kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel("reshape_layer", build_opts));
@@ -84,15 +95,18 @@ void CLReshapeLayerKernel::configure(const ICLTensor *input, ICLTensor *output)
_kernel.setArg<cl_int2>(idx++, output_shape);
// Configure kernel window
- Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration));
+ Window win = calculate_max_window(*input->info());
- AccessWindowHorizontal input_access(input->info(), 0, num_elems_processed_per_iteration);
- AccessWindowStatic output_access(output->info(), 0, 0, output->info()->tensor_shape().x(), output->info()->tensor_shape().y());
- update_window_and_padding(win, input_access, output_access);
+ // Set the output valid region
+ output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
+ ICLKernel::configure_internal(win);
+}
- output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape()));
+Status CLReshapeLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output)
+{
+ ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
- ICLKernel::configure_internal(win);
+ return Status{};
}
void CLReshapeLayerKernel::run(const Window &window, cl::CommandQueue &queue)