blob: 3ce4c6ffc9ca77f15072470d7ec995bc006bdad7 [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"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010025#include "NEON/NEAccessor.h"
26#include "TensorLibrary.h"
27#include "TypePrinter.h"
28#include "Utils.h"
29#include "validation/Datasets.h"
30#include "validation/Validation.h"
31
32#include "arm_compute/core/Helpers.h"
33#include "arm_compute/core/NEON/kernels/NEFillBorderKernel.h"
34#include "arm_compute/core/Types.h"
35#include "arm_compute/runtime/Tensor.h"
36#include "arm_compute/runtime/TensorAllocator.h"
37
38#include "boost_wrapper.h"
39
40#include <random>
41#include <string>
42
43using namespace arm_compute;
44using namespace arm_compute::test;
45using namespace arm_compute::test::neon;
46using namespace arm_compute::test::validation;
47
48#ifndef DOXYGEN_SKIP_THIS
49BOOST_AUTO_TEST_SUITE(NEON)
50
51BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
52BOOST_DATA_TEST_CASE(FillBorder, BorderModes() * boost::unit_test::data::make({ PaddingSize{ 0 }, PaddingSize{ 1, 0, 1, 2 }, PaddingSize{ 10 } }), border_mode, padding)
53{
54 constexpr uint8_t border_value = 42U;
55 constexpr uint8_t tensor_value = 89U;
56 BorderSize border_size{ 5 };
57
58 // Create tensors
Moritz Pflanzer94450f12017-06-30 12:48:43 +010059 Tensor src = create_tensor<Tensor>(TensorShape{ 10U, 10U, 2U }, DataType::U8);
Anthony Barbier6ff3b192017-09-04 18:44:23 +010060
61 src.info()->extend_padding(padding);
62
63 // Allocate tensor
64 src.allocator()->allocate();
65
66 // Check padding is as required
67 validate(src.info()->padding(), padding);
68
69 // Fill tensor with constant value
70 std::uniform_int_distribution<uint8_t> distribution{ tensor_value, tensor_value };
71 library->fill(NEAccessor(src), distribution, 0);
72
73 // Create and configure kernel
74 NEFillBorderKernel fill_border;
75 fill_border.configure(&src, border_size, border_mode, border_value);
76
77 // Run kernel
78 fill_border.run(fill_border.window());
79
80 // Validate border
81 border_size.limit(padding);
82 validate(NEAccessor(src), border_size, border_mode, &border_value);
83
84 // Validate tensor
85 validate(NEAccessor(src), &tensor_value);
86}
87
88BOOST_AUTO_TEST_SUITE_END()
Anthony Barbierac69aa12017-07-03 17:39:37 +010089#endif /* DOXYGEN_SKIP_THIS */