From a09de0c8b2ed0f1481502d3b023375609362d9e3 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Fri, 1 Sep 2017 20:41:12 +0100 Subject: COMPMID-415: Rename and move tests The boost validation is now "standalone" in validation_old and builds as arm_compute_validation_old. The new validation builds now as arm_compute_validation. Change-Id: Ib93ba848a25680ac60afb92b461d574a0757150d Reviewed-on: http://mpd-gerrit.cambridge.arm.com/86187 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- tests/benchmark/fixtures/ActivationLayerFixture.h | 82 ++++++++++++++++ tests/benchmark/fixtures/AlexNetFixture.h | 89 ++++++++++++++++++ .../fixtures/BatchNormalizationLayerFixture.h | 102 ++++++++++++++++++++ tests/benchmark/fixtures/ConvolutionLayerFixture.h | 93 +++++++++++++++++++ .../fixtures/DepthwiseConvolutionFixture.h | 88 ++++++++++++++++++ .../DepthwiseSeparableConvolutionLayerFixture.h | 103 +++++++++++++++++++++ tests/benchmark/fixtures/FloorFixture.h | 78 ++++++++++++++++ .../fixtures/FullyConnectedLayerFixture.h | 93 +++++++++++++++++++ tests/benchmark/fixtures/GEMMFixture.h | 89 ++++++++++++++++++ tests/benchmark/fixtures/LeNet5Fixture.h | 77 +++++++++++++++ .../benchmark/fixtures/NormalizationLayerFixture.h | 82 ++++++++++++++++ tests/benchmark/fixtures/PoolingLayerFixture.h | 83 +++++++++++++++++ tests/benchmark/fixtures/ROIPoolingLayerFixture.h | 95 +++++++++++++++++++ 13 files changed, 1154 insertions(+) create mode 100644 tests/benchmark/fixtures/ActivationLayerFixture.h create mode 100644 tests/benchmark/fixtures/AlexNetFixture.h create mode 100644 tests/benchmark/fixtures/BatchNormalizationLayerFixture.h create mode 100644 tests/benchmark/fixtures/ConvolutionLayerFixture.h create mode 100644 tests/benchmark/fixtures/DepthwiseConvolutionFixture.h create mode 100644 tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h create mode 100644 tests/benchmark/fixtures/FloorFixture.h create mode 100644 tests/benchmark/fixtures/FullyConnectedLayerFixture.h create mode 100644 tests/benchmark/fixtures/GEMMFixture.h create mode 100644 tests/benchmark/fixtures/LeNet5Fixture.h create mode 100644 tests/benchmark/fixtures/NormalizationLayerFixture.h create mode 100644 tests/benchmark/fixtures/PoolingLayerFixture.h create mode 100644 tests/benchmark/fixtures/ROIPoolingLayerFixture.h (limited to 'tests/benchmark/fixtures') diff --git a/tests/benchmark/fixtures/ActivationLayerFixture.h b/tests/benchmark/fixtures/ActivationLayerFixture.h new file mode 100644 index 0000000000..9ded063a37 --- /dev/null +++ b/tests/benchmark/fixtures/ActivationLayerFixture.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class ActivationLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, ActivationLayerInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + shape.set(shape.num_dimensions(), batches); + + // Create tensors + const int fixed_point_position = 4; + src = create_tensor(shape, data_type, 1, fixed_point_position); + dst = create_tensor(shape, data_type, 1, fixed_point_position); + + // Create and configure function + act_layer.configure(&src, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + act_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function act_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ACTIVATIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/AlexNetFixture.h b/tests/benchmark/fixtures/AlexNetFixture.h new file mode 100644 index 0000000000..961f4e889f --- /dev/null +++ b/tests/benchmark/fixtures/AlexNetFixture.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ALEXNETFIXTURE +#define ARM_COMPUTE_TEST_ALEXNETFIXTURE + +#include "tests/AssetsLibrary.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" +#include "tests/networks/AlexNetNetwork.h" + +namespace arm_compute +{ +namespace test +{ +template + +class AlexNetFixture : public framework::Fixture +{ +public: + template + void setup(DataType data_type, int batches) + { + constexpr bool weights_reshaped = true; + constexpr int fixed_point_position = 4; + + network.init(data_type, fixed_point_position, batches, weights_reshaped); + network.build(); + network.allocate(); + network.fill_random(); + } + + void run() + { + network.run(); + } + + void teardown() + { + network.clear(); + } + +private: + networks::AlexNetNetwork + network{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ALEXNETFIXTURE */ diff --git a/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h new file mode 100644 index 0000000000..79dbc76300 --- /dev/null +++ b/tests/benchmark/fixtures/BatchNormalizationLayerFixture.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class BatchNormalizationLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape tensor_shape, TensorShape param_shape, float epsilon, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + tensor_shape.set(tensor_shape.num_dimensions(), batches); + + // Create tensors + src = create_tensor(tensor_shape, data_type, 1, fixed_point_position); + dst = create_tensor(tensor_shape, data_type, 1, fixed_point_position); + mean = create_tensor(param_shape, data_type, 1, fixed_point_position); + variance = create_tensor(param_shape, data_type, 1, fixed_point_position); + beta = create_tensor(param_shape, data_type, 1, fixed_point_position); + gamma = create_tensor(param_shape, data_type, 1, fixed_point_position); + + // Create and configure function + batch_norm_layer.configure(&src, &dst, &mean, &variance, &beta, &gamma, epsilon); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + mean.allocator()->allocate(); + variance.allocator()->allocate(); + beta.allocator()->allocate(); + gamma.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(mean), 1); + library->fill_tensor_uniform(Accessor(variance), 2); + library->fill_tensor_uniform(Accessor(beta), 3); + library->fill_tensor_uniform(Accessor(gamma), 4); + } + + void run() + { + batch_norm_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + mean.allocator()->free(); + variance.allocator()->free(); + beta.allocator()->free(); + gamma.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + TensorType mean{}; + TensorType variance{}; + TensorType beta{}; + TensorType gamma{}; + Function batch_norm_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_BATCHNORMALIZATIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/ConvolutionLayerFixture.h b/tests/benchmark/fixtures/ConvolutionLayerFixture.h new file mode 100644 index 0000000000..fd508d4500 --- /dev/null +++ b/tests/benchmark/fixtures/ConvolutionLayerFixture.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class ConvolutionLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, PadStrideInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(3 /* batch */, batches); + dst_shape.set(3 /* batch */, batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + conv_layer.configure(&src, &weights, &biases, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(weights), 1); + library->fill_tensor_uniform(Accessor(biases), 2); + } + + void run() + { + conv_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + weights.allocator()->free(); + biases.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType weights{}; + TensorType biases{}; + TensorType dst{}; + Function conv_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_CONVOLUTIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/DepthwiseConvolutionFixture.h b/tests/benchmark/fixtures/DepthwiseConvolutionFixture.h new file mode 100644 index 0000000000..e080fe253b --- /dev/null +++ b/tests/benchmark/fixtures/DepthwiseConvolutionFixture.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE +#define ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class DepthwiseConvolutionFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape dst_shape, PadStrideInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(3 /* batch */, batches); + dst_shape.set(3 /* batch */, batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + depth_conv.configure(&src, &dst, &weights, info); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(weights), 1); + } + + void run() + { + depth_conv.run(); + } + + void teardown() + { + src.allocator()->free(); + weights.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType weights{}; + TensorType dst{}; + Function depth_conv{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISECONVOLUTIONFIXTURE */ diff --git a/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h new file mode 100644 index 0000000000..928b0c7328 --- /dev/null +++ b/tests/benchmark/fixtures/DepthwiseSeparableConvolutionLayerFixture.h @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class DepthwiseSeparableConvolutionLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape depthwise_weights_shape, TensorShape depthwise_out_shape, TensorShape pointwise_weights_shape, TensorShape biases_shape, TensorShape dst_shape, + PadStrideInfo pad_stride_depthwise_info, PadStrideInfo pad_stride_pointwise_info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(3 /* batch */, batches); + depthwise_out_shape.set(3 /* batch */, batches); + dst_shape.set(3 /* batch */, batches); + + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + depthwise_weights = create_tensor(depthwise_weights_shape, data_type, 1, fixed_point_position); + depthwise_out = create_tensor(depthwise_out_shape, data_type, 1, fixed_point_position); + pointwise_weights = create_tensor(pointwise_weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + depth_sep_conv_layer.configure(&src, &depthwise_weights, &depthwise_out, &pointwise_weights, &biases, &dst, pad_stride_depthwise_info, pad_stride_pointwise_info); + + // Allocate tensors + src.allocator()->allocate(); + depthwise_weights.allocator()->allocate(); + depthwise_out.allocator()->allocate(); + pointwise_weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(depthwise_weights), 1); + library->fill_tensor_uniform(Accessor(pointwise_weights), 2); + library->fill_tensor_uniform(Accessor(biases), 3); + } + + void run() + { + depth_sep_conv_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + depthwise_weights.allocator()->free(); + depthwise_out.allocator()->free(); + pointwise_weights.allocator()->free(); + biases.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType depthwise_weights{}; + TensorType depthwise_out{}; + TensorType pointwise_weights{}; + TensorType biases{}; + TensorType dst{}; + Function depth_sep_conv_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_DEPTHWISESEPARABLECONVOLUTIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/FloorFixture.h b/tests/benchmark/fixtures/FloorFixture.h new file mode 100644 index 0000000000..8de87b886b --- /dev/null +++ b/tests/benchmark/fixtures/FloorFixture.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FLOORFIXTURE +#define ARM_COMPUTE_TEST_FLOORFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class FloorFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, DataType data_type) + { + // Create tensors + src = create_tensor(shape, data_type); + dst = create_tensor(shape, data_type); + + // Create and configure function + floor_func.configure(&src, &dst); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + floor_func.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function floor_func{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FLOORFIXTURE */ diff --git a/tests/benchmark/fixtures/FullyConnectedLayerFixture.h b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h new file mode 100644 index 0000000000..2d1f2334b6 --- /dev/null +++ b/tests/benchmark/fixtures/FullyConnectedLayerFixture.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE +#define ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class FullyConnectedLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape weights_shape, TensorShape biases_shape, TensorShape dst_shape, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(src_shape.num_dimensions() /* batch */, batches); + dst_shape.set(dst_shape.num_dimensions() /* batch */, batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + weights = create_tensor(weights_shape, data_type, 1, fixed_point_position); + biases = create_tensor(biases_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + fc_layer.configure(&src, &weights, &biases, &dst); + + // Allocate tensors + src.allocator()->allocate(); + weights.allocator()->allocate(); + biases.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + library->fill_tensor_uniform(Accessor(weights), 1); + library->fill_tensor_uniform(Accessor(biases), 2); + } + + void run() + { + fc_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + weights.allocator()->free(); + biases.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType weights{}; + TensorType biases{}; + TensorType dst{}; + Function fc_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_FULLYCONNECTEDLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/GEMMFixture.h b/tests/benchmark/fixtures/GEMMFixture.h new file mode 100644 index 0000000000..0c41c67af1 --- /dev/null +++ b/tests/benchmark/fixtures/GEMMFixture.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_GEMMFIXTURE +#define ARM_COMPUTE_TEST_GEMMFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class GEMMFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape_a, TensorShape shape_b, TensorShape shape_c, TensorShape shape_dst, float alpha, float beta, DataType data_type) + { + constexpr int fixed_point_position = 4; + + // Create tensors + a = create_tensor(shape_a, data_type, 1, fixed_point_position); + b = create_tensor(shape_b, data_type, 1, fixed_point_position); + c = create_tensor(shape_c, data_type, 1, fixed_point_position); + dst = create_tensor(shape_dst, data_type, 1, fixed_point_position); + + // Create and configure function + gemm.configure(&a, &b, &c, &dst, alpha, beta); + + // Allocate tensors + a.allocator()->allocate(); + b.allocator()->allocate(); + c.allocator()->allocate(); + dst.allocator()->allocate(); + + library->fill_tensor_uniform(Accessor(a), 0); + library->fill_tensor_uniform(Accessor(b), 1); + library->fill_tensor_uniform(Accessor(c), 2); + } + + void run() + { + gemm.run(); + } + + void teardown() + { + a.allocator()->free(); + b.allocator()->free(); + c.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType a{}; + TensorType b{}; + TensorType c{}; + TensorType dst{}; + Function gemm{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_GEMMFIXTURE */ diff --git a/tests/benchmark/fixtures/LeNet5Fixture.h b/tests/benchmark/fixtures/LeNet5Fixture.h new file mode 100644 index 0000000000..77a09d3025 --- /dev/null +++ b/tests/benchmark/fixtures/LeNet5Fixture.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_LENET5FIXTURE +#define ARM_COMPUTE_TEST_LENET5FIXTURE + +#include "tests/AssetsLibrary.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" +#include "tests/networks/LeNet5Network.h" + +namespace arm_compute +{ +namespace test +{ +template +class LeNet5Fixture : public framework::Fixture +{ +public: + template + void setup(int batches) + { + network.init(batches); + network.build(); + network.allocate(); + network.fill_random(); + } + + void run() + { + network.run(); + } + + void teardown() + { + network.clear(); + } + +private: + networks::LeNet5Network + network{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_LENET5FIXTURE */ diff --git a/tests/benchmark/fixtures/NormalizationLayerFixture.h b/tests/benchmark/fixtures/NormalizationLayerFixture.h new file mode 100644 index 0000000000..41dd8a7b27 --- /dev/null +++ b/tests/benchmark/fixtures/NormalizationLayerFixture.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE +#define ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class NormalizationLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, NormalizationLayerInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + shape.set(shape.num_dimensions(), batches); + + // Create tensors + src = create_tensor(shape, data_type, 1, fixed_point_position); + dst = create_tensor(shape, data_type, 1, fixed_point_position); + + // Create and configure function + norm_layer.configure(&src, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + norm_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function norm_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_NORMALIZATIONLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/PoolingLayerFixture.h b/tests/benchmark/fixtures/PoolingLayerFixture.h new file mode 100644 index 0000000000..2060301531 --- /dev/null +++ b/tests/benchmark/fixtures/PoolingLayerFixture.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE +#define ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class PoolingLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape src_shape, TensorShape dst_shape, PoolingLayerInfo info, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + src_shape.set(src_shape.num_dimensions(), batches); + dst_shape.set(dst_shape.num_dimensions(), batches); + + // Create tensors + src = create_tensor(src_shape, data_type, 1, fixed_point_position); + dst = create_tensor(dst_shape, data_type, 1, fixed_point_position); + + // Create and configure function + pool_layer.configure(&src, &dst, info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + pool_layer.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + Function pool_layer{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_POOLINGLAYERFIXTURE */ diff --git a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h new file mode 100644 index 0000000000..76c2280b74 --- /dev/null +++ b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE +#define ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "tests/Globals.h" +#include "tests/Utils.h" +#include "tests/framework/Fixture.h" + +#include + +namespace arm_compute +{ +namespace test +{ +/** Fixture that can be used for NEON and CL */ +template +class ROIPoolingLayerFixture : public framework::Fixture +{ +public: + template + void setup(TensorShape shape, const ROIPoolingLayerInfo pool_info, unsigned int num_rois, DataType data_type, int batches) + { + // Set batched in source and destination shapes + const unsigned int fixed_point_position = 4; + TensorShape shape_dst; + shape.set(shape.num_dimensions(), batches); + shape_dst.set(0, pool_info.pooled_width()); + shape_dst.set(1, pool_info.pooled_height()); + shape_dst.set(2, shape.z()); + shape_dst.set(3, num_rois); + + // Create tensors + src = create_tensor(shape, data_type, 1, fixed_point_position); + dst = create_tensor(shape_dst, data_type, 1, fixed_point_position); + + // Create random ROIs + std::vector rois = generate_random_rois(shape, pool_info, num_rois, 0U); + rois_array = arm_compute::support::cpp14::make_unique(num_rois); + fill_array(ArrayAccessor(*rois_array), rois); + + // Create and configure function + roi_pool.configure(&src, rois_array.get(), &dst, pool_info); + + // Allocate tensors + src.allocator()->allocate(); + dst.allocator()->allocate(); + + // Fill tensors + library->fill_tensor_uniform(Accessor(src), 0); + } + + void run() + { + roi_pool.run(); + } + + void teardown() + { + src.allocator()->free(); + dst.allocator()->free(); + } + +private: + TensorType src{}; + TensorType dst{}; + std::unique_ptr rois_array{}; + Function roi_pool{}; +}; +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ROIPOOLINGLAYERFIXTURE */ -- cgit v1.2.1