aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/kernels/CLArithmeticAdditionKernel.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2017-07-03 18:17:28 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:15:39 +0100
commitf0dea703ce3e2b465e79298bca95c4952a60f608 (patch)
tree487c9ab15ea8cef9d57aa3256599cde616310eeb /src/core/CL/kernels/CLArithmeticAdditionKernel.cpp
parent1dad50ea7b662e7c07a0a06bbbd175fd1bcf9bfc (diff)
downloadComputeLibrary-f0dea703ce3e2b465e79298bca95c4952a60f608.tar.gz
COMPMID-417: Auto configuration for Add/Sub/Mul Neon/CL.
Change-Id: I3580de76bc53d342b53443d1077b1407d75a672a Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79570 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Michele DiGiorgio <michele.digiorgio@arm.com> Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
Diffstat (limited to 'src/core/CL/kernels/CLArithmeticAdditionKernel.cpp')
-rw-r--r--src/core/CL/kernels/CLArithmeticAdditionKernel.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/core/CL/kernels/CLArithmeticAdditionKernel.cpp b/src/core/CL/kernels/CLArithmeticAdditionKernel.cpp
index aaa62d0268..0cb0847784 100644
--- a/src/core/CL/kernels/CLArithmeticAdditionKernel.cpp
+++ b/src/core/CL/kernels/CLArithmeticAdditionKernel.cpp
@@ -48,9 +48,32 @@ CLArithmeticAdditionKernel::CLArithmeticAdditionKernel()
void CLArithmeticAdditionKernel::configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ConvertPolicy policy)
{
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input1, input2, output);
+
+ // Auto initialize output if not initialized
+ {
+ set_shape_if_empty(*output->info(), input1->info()->tensor_shape());
+
+ if(input1->info()->data_type() == DataType::S16 || input2->info()->data_type() == DataType::S16)
+ {
+ set_format_if_unknown(*output->info(), Format::S16);
+ }
+ else if(input1->info()->data_type() == DataType::F32 || input2->info()->data_type() == DataType::F32)
+ {
+ set_format_if_unknown(*output->info(), Format::F32);
+ }
+ else if(input1->info()->data_type() == DataType::F16 && input2->info()->data_type() == DataType::F16)
+ {
+ set_format_if_unknown(*output->info(), Format::F16);
+ }
+ }
+
+ ARM_COMPUTE_ERROR_ON_MISMATCHING_SHAPES(input1, input2, output);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input1, 1, DataType::U8, DataType::S16, DataType::F16, DataType::F32);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input2, 1, DataType::U8, DataType::S16, DataType::F16, DataType::F32);
ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::U8, DataType::S16, DataType::F16, DataType::F32);
+ ARM_COMPUTE_ERROR_ON_MSG(output->info()->data_type() == DataType::U8 && (input1->info()->data_type() != DataType::U8 || input2->info()->data_type() != DataType::U8),
+ "Output can only be U8 if both inputs are U8");
_input1 = input1;
_input2 = input2;
@@ -58,12 +81,6 @@ void CLArithmeticAdditionKernel::configure(const ICLTensor *input1, const ICLTen
const bool has_float_out = is_data_type_float(output->info()->data_type());
- // Check for invalid combination
- if(output->info()->data_type() == DataType::U8 && (input1->info()->data_type() != DataType::U8 || input2->info()->data_type() != DataType::U8))
- {
- ARM_COMPUTE_ERROR("You called with the wrong data types.");
- }
-
// Set kernel build options
std::set<std::string> build_opts;
build_opts.emplace((policy == ConvertPolicy::WRAP || has_float_out) ? "-DWRAP" : "-DSATURATE");