blob: 9fbeb998f563a347f1d52dafd7cf8eca7cff9450 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "Globals.h"
25#include "NEON/Helper.h"
26#include "NEON/NEAccessor.h"
27#include "TensorLibrary.h"
28#include "TypePrinter.h"
29#include "Utils.h"
30#include "validation/Datasets.h"
31#include "validation/Validation.h"
32
33#include "arm_compute/core/Helpers.h"
34#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h"
35#include "arm_compute/core/Types.h"
36#include "arm_compute/runtime/Tensor.h"
37#include "arm_compute/runtime/TensorAllocator.h"
38
39#include "boost_wrapper.h"
40
41#include <random>
42#include <string>
43
44using namespace arm_compute;
45using namespace arm_compute::test;
46using namespace arm_compute::test::neon;
47using namespace arm_compute::test::validation;
48
49#ifndef DOXYGEN_SKIP_THIS
50BOOST_AUTO_TEST_SUITE(NEON)
51
52BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
53BOOST_DATA_TEST_CASE(FillBorder, BorderModes() * boost::unit_test::data::make({ PaddingSize{ 0 }, PaddingSize{ 1, 0, 1, 2 }, PaddingSize{ 10 } }), border_mode, padding)
54{
55 constexpr uint8_t border_value = 42U;
56 constexpr uint8_t tensor_value = 89U;
57 BorderSize border_size{ 5 };
58
59 // Create tensors
60 Tensor src = create_tensor(TensorShape{ 10U, 10U, 2U }, DataType::U8);
61
62 src.info()->extend_padding(padding);
63
64 // Allocate tensor
65 src.allocator()->allocate();
66
67 // Check padding is as required
68 validate(src.info()->padding(), padding);
69
70 // Fill tensor with constant value
71 std::uniform_int_distribution<uint8_t> distribution{ tensor_value, tensor_value };
72 library->fill(NEAccessor(src), distribution, 0);
73
74 // Create and configure kernel
75 NEFillBorderKernel fill_border;
76 fill_border.configure(&src, border_size, border_mode, border_value);
77
78 // Run kernel
79 fill_border.run(fill_border.window());
80
81 // Validate border
82 border_size.limit(padding);
83 validate(NEAccessor(src), border_size, border_mode, &border_value);
84
85 // Validate tensor
86 validate(NEAccessor(src), &tensor_value);
87}
88
89BOOST_AUTO_TEST_SUITE_END()
90#endif