blob: 5a311ef6dd4770835cf29552605b718a7b5446d2 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001#ifdef INTERNAL_ONLY //FIXME Delete this file before the release
2/*
3 * Copyright (c) 2017 ARM Limited.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to
9 * deal in the Software without restriction, including without limitation the
10 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11 * sell copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
Anthony Barbier6ff3b192017-09-04 18:44:23 +010025#include "NEON/NEAccessor.h"
26#include "validation/Validation.h"
27
28#include "arm_compute/runtime/NEON/functions/NEActivationLayer.h"
29#include "arm_compute/runtime/NEON/functions/NEConvolutionLayer.h"
30#include "arm_compute/runtime/NEON/functions/NEFullyConnectedLayer.h"
31#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h"
32#include "arm_compute/runtime/NEON/functions/NESoftmaxLayer.h"
33
34#include "model_objects/LeNet5.h"
35
36using namespace arm_compute;
37using namespace arm_compute::test;
38using namespace arm_compute::test::neon;
39using namespace arm_compute::test::validation;
40
41namespace
42{
43using NELeNet5Model = model_objects::LeNet5<Tensor,
44 NEAccessor,
45 NEActivationLayer,
46 NEConvolutionLayer,
47 NEFullyConnectedLayer,
48 NEPoolingLayer,
49 NESoftmaxLayer>;
50std::vector<unsigned int> compute_lenet5(unsigned int batches, std::string input_file)
51{
52 std::vector<std::string> weight_files = { "cnn_data/lenet_model/conv1_w.dat",
53 "cnn_data/lenet_model/conv2_w.dat",
54 "cnn_data/lenet_model/ip1_w.dat",
55 "cnn_data/lenet_model/ip2_w.dat"
56 };
57
58 std::vector<std::string> bias_files = { "cnn_data/lenet_model/conv1_b.dat",
59 "cnn_data/lenet_model/conv2_b.dat",
60 "cnn_data/lenet_model/ip1_b.dat",
61 "cnn_data/lenet_model/ip2_b.dat"
62 };
63 NELeNet5Model network{};
64 network.build(batches);
65 network.fill(weight_files, bias_files);
66 network.feed(std::move(input_file));
67 network.run();
68
69 return network.get_classifications();
70}
71} // namespace
72
73#ifndef DOXYGEN_SKIP_THIS
74BOOST_AUTO_TEST_SUITE(SYSTEM_TESTS)
75BOOST_AUTO_TEST_SUITE(NEON)
76
77BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
78BOOST_AUTO_TEST_CASE(LeNet5)
79{
80 // Compute alexnet
81 std::vector<unsigned int> classified_labels = compute_lenet5(10, "cnn_data/mnist_data/input100.dat");
82
83 // Expected labels
84 std::vector<unsigned int> expected_labels = { 7, 2, 1, 0, 4, 1, 4, 9, 5, 9 };
85
86 // Validate labels
87 validate(classified_labels, expected_labels);
88}
89
90BOOST_AUTO_TEST_SUITE_END()
91BOOST_AUTO_TEST_SUITE_END()
92#endif
93#endif /* INTERNAL_ONLY */