From 97e258000f99c6a5f872f4e8968eaf6a93de2cf7 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Thu, 25 Mar 2021 12:37:45 +0000 Subject: Check biases pointer before referencing in CLDirectConvolutionLayer The biases input can be nullptr, hence we need to check before referencing. A test is also added to ensure a successful configure and run of Direct Convolution when there is no bias. Resolves: COMPMID-4315 Change-Id: I23223efd6ced81215aff490221fb4606945c139b Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5322 Tested-by: Arm Jenkins Reviewed-by: James Conroy Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- tests/validation/CL/DirectConvolutionLayer.cpp | 43 ++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tests/validation/CL/DirectConvolutionLayer.cpp') diff --git a/tests/validation/CL/DirectConvolutionLayer.cpp b/tests/validation/CL/DirectConvolutionLayer.cpp index 4671d8c3ec..c01234020f 100644 --- a/tests/validation/CL/DirectConvolutionLayer.cpp +++ b/tests/validation/CL/DirectConvolutionLayer.cpp @@ -87,6 +87,49 @@ const auto ActivationFunctionsDataset = framework::dataset::make("ActivationInfo TEST_SUITE(CL) TEST_SUITE(DirectConvolutionLayer) +/** Check whether the configuration of a Direct Convolution layer with no + * bias leads to a successful execution. + */ +TEST_CASE(NoBias, framework::DatasetMode::PRECOMMIT) +{ + const auto src_shape = TensorShape(27U, 13U, 2U); + const auto weights_shape = TensorShape(3U, 3U, 2U, 4U); + const auto bias_shape = TensorShape(4U); + const auto dst_shape = TensorShape(25U, 11U, 4U); + constexpr auto dt = DataType::F32; + + auto src = create_tensor(src_shape, dt); + auto weights = create_tensor(weights_shape, dt); + auto dst = create_tensor(dst_shape, dt); + + const auto conv_info = PadStrideInfo(1, 1, 0, 0); + + // Create Direct Convolution function + CLDirectConvolutionLayer conv{}; + conv.configure(&src, &weights, nullptr, &dst, conv_info); + + src.allocator()->allocate(); + weights.allocator()->allocate(); + dst.allocator()->allocate(); + + library->fill_tensor_value(CLAccessor(src), 1.f); + library->fill_tensor_value(CLAccessor(weights), 1.f); + + conv.run(); + + // Compute reference to compare + SimpleTensor ref_src{ src_shape, dt }; + SimpleTensor ref_weights{ weights_shape, dt }; + SimpleTensor ref_bias{ bias_shape, dt }; + library->fill_tensor_value(ref_src, 1.f); + library->fill_tensor_value(ref_weights, 1.f); + // No bias + library->fill_tensor_value(ref_bias, 0.f); + auto ref_dst = reference::convolution_layer(ref_src, ref_weights, ref_bias, dst_shape, conv_info); + + validate(CLAccessor(dst), ref_dst); +} + // *INDENT-OFF* // clang-format off DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(zip(zip( -- cgit v1.2.1