blob: cb0a1fd0b56b05e6e697ada4cebb5686511274f3 [file] [log] [blame]
Anthony Barbierdbdab852017-06-23 15:42:00 +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/Reference.h"
32#include "validation/Validation.h"
33
34#include "arm_compute/core/Helpers.h"
35#include "arm_compute/core/Types.h"
36#include "arm_compute/runtime/NEON/functions/NEBitwiseNot.h"
37#include "arm_compute/runtime/Tensor.h"
38#include "arm_compute/runtime/TensorAllocator.h"
39
40#include "boost_wrapper.h"
41
42#include <random>
43#include <string>
44
45using namespace arm_compute;
46using namespace arm_compute::test;
47using namespace arm_compute::test::neon;
48using namespace arm_compute::test::validation;
49
50namespace
51{
52/** Compute Neon bitwise not function.
53 *
54 * @param[in] shape Shape of the input and output tensors.
55 *
56 * @return Computed output tensor.
57 */
58Tensor compute_bitwise_not(const TensorShape &shape)
59{
60 // Create tensors
61 Tensor src = create_tensor(shape, DataType::U8);
62 Tensor dst = create_tensor(shape, DataType::U8);
63
64 // Create not configure function
65 NEBitwiseNot bnot;
66 bnot.configure(&src, &dst);
67
68 // Allocate tensors
69 src.allocator()->allocate();
70 dst.allocator()->allocate();
71
72 BOOST_TEST(!src.info()->is_resizable());
73 BOOST_TEST(!dst.info()->is_resizable());
74
75 // Fill tensors
76 library->fill_tensor_uniform(NEAccessor(src), 0);
77
78 // Compute function
79 bnot.run();
80
81 return dst;
82}
83} // namespace
84
85#ifndef DOXYGEN_SKIP_THIS
86BOOST_AUTO_TEST_SUITE(NEON)
87BOOST_AUTO_TEST_SUITE(BitwiseNot)
88
89BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly"))
90BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape)
91{
92 // Create tensors
93 Tensor src = create_tensor(shape, DataType::U8);
94 Tensor dst = create_tensor(shape, DataType::U8);
95
96 BOOST_TEST(src.info()->is_resizable());
97 BOOST_TEST(dst.info()->is_resizable());
98
99 // Create not configure function
100 NEBitwiseNot bnot;
101 bnot.configure(&src, &dst);
102
103 // Validate valid region
104 const ValidRegion valid_region = shape_to_valid_region(shape);
105 validate(src.info()->valid_region(), valid_region);
106 validate(dst.info()->valid_region(), valid_region);
107
108 // Validate padding
109 const PaddingSize padding(0, required_padding(shape.x(), 16), 0, 0);
110 validate(src.info()->padding(), padding);
111 validate(dst.info()->padding(), padding);
112}
113
114BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
115BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape)
116{
117 // Compute function
118 Tensor dst = compute_bitwise_not(shape);
119
120 // Compute reference
121 RawTensor ref_dst = Reference::compute_reference_bitwise_not(shape);
122
123 // Validate output
124 validate(NEAccessor(dst), ref_dst);
125}
126
127BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly"))
128BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), shape)
129{
130 // Compute function
131 Tensor dst = compute_bitwise_not(shape);
132
133 // Compute reference
134 RawTensor ref_dst = Reference::compute_reference_bitwise_not(shape);
135
136 // Validate output
137 validate(NEAccessor(dst), ref_dst);
138}
139
140BOOST_AUTO_TEST_SUITE_END()
141BOOST_AUTO_TEST_SUITE_END()
142#endif