aboutsummaryrefslogtreecommitdiff
path: root/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp
diff options
context:
space:
mode:
authorAlex Gilday <alexander.gilday@arm.com>2018-02-22 11:36:16 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:49:16 +0000
commit27c08abe6947b1ee5b266799f2bb2bf0a05d0def (patch)
tree32dfb3a6d6b199d5138e25b103023f07d88bce29 /src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp
parent9e9cbafa9e6cc6b543c89a96d52fc9c5fde04ceb (diff)
downloadComputeLibrary-27c08abe6947b1ee5b266799f2bb2bf0a05d0def.tar.gz
COMPMID-754: Add validation to LocallyConnected and NEDeconv layers
Change-Id: Ifed8713f4d7f1315af684b30d11323db2b533f10 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/121783 Reviewed-by: Anthony Barbier <anthony.barbier@arm.com> Tested-by: Jenkins <bsgcomp@arm.com> Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
Diffstat (limited to 'src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp')
-rw-r--r--src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp57
1 files changed, 42 insertions, 15 deletions
diff --git a/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp b/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp
index 35beb82689..099626d259 100644
--- a/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp
+++ b/src/core/NEON/kernels/NELocallyConnectedMatrixMultiplyKernel.cpp
@@ -302,6 +302,37 @@ void vector_matrix_multiply_f32(const ITensor *input0, const ITensor *input1, IT
},
ina, out);
}
+
+Status validate_arguments(const ITensorInfo *input0, const ITensorInfo *input1, const ITensorInfo *output)
+{
+ ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input0, input1, output);
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input0, 1, DataType::F16, DataType::F32);
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input1, 1, DataType::F16, DataType::F32);
+ ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::F16, DataType::F32);
+ ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input0, input1, output);
+ ARM_COMPUTE_RETURN_ERROR_ON(input0->dimension(0) != input1->dimension(1));
+
+ return Status{};
+}
+
+std::tuple<Status, Window> validate_and_configure_window(ITensorInfo *input0, ITensorInfo *input1, ITensorInfo *output)
+{
+ const unsigned int num_elems_processed_per_iteration_x = 16;
+
+ Window win = calculate_max_window(*output, Steps(num_elems_processed_per_iteration_x));
+
+ AccessWindowHorizontal input0_access(input0, 0, num_elems_processed_per_iteration_x);
+ AccessWindowHorizontal input1_access(input1, 0, num_elems_processed_per_iteration_x);
+ AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration_x);
+
+ bool window_changed = update_window_and_padding(win, input0_access, input1_access, output_access);
+
+ output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape()));
+
+ Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
+
+ return std::make_tuple(err, win);
+}
} // namespace
NELocallyConnectedMatrixMultiplyKernel::NELocallyConnectedMatrixMultiplyKernel()
@@ -311,31 +342,27 @@ NELocallyConnectedMatrixMultiplyKernel::NELocallyConnectedMatrixMultiplyKernel()
void NELocallyConnectedMatrixMultiplyKernel::configure(const ITensor *input0, const ITensor *input1, ITensor *output)
{
- ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input0, 1, DataType::F16, DataType::F32);
- ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input1, 1, DataType::F16, DataType::F32);
- ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::F16, DataType::F32);
- ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output, 1, DataType::F16, DataType::F32);
- ARM_COMPUTE_ERROR_ON(input0->info()->dimension(0) != input1->info()->dimension(1));
+ ARM_COMPUTE_ERROR_ON_NULLPTR(input0, input1, output);
+ ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input0->info(), input1->info(), output->info()));
_input0 = input0;
_input1 = input1;
_output = output;
- const unsigned int num_elems_processed_per_iteration_x = 16;
-
// Configure kernel window
- Window win = calculate_max_window(*output->info(), Steps(num_elems_processed_per_iteration_x));
+ auto win_config = validate_and_configure_window(input0->info(), input1->info(), output->info());
- AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration_x);
+ ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
- update_window_and_padding(win,
- AccessWindowHorizontal(input0->info(), 0, num_elems_processed_per_iteration_x),
- AccessWindowHorizontal(input1->info(), 0, num_elems_processed_per_iteration_x),
- output_access);
+ INEKernel::configure(std::get<1>(win_config));
+}
- output_access.set_valid_region(win, ValidRegion(Coordinates(), output->info()->tensor_shape()));
+Status NELocallyConnectedMatrixMultiplyKernel::validate(const ITensorInfo *input0, const ITensorInfo *input1, const ITensorInfo *output)
+{
+ ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input0, input1, output));
+ ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input0->clone().get(), input1->clone().get(), output->clone().get())));
- INEKernel::configure(win);
+ return Status{};
}
void NELocallyConnectedMatrixMultiplyKernel::run(const Window &window, const ThreadInfo &info)