aboutsummaryrefslogtreecommitdiff
path: root/tests/benchmark
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2017-12-18 14:34:53 +0000
committerAnthony Barbier <anthony.barbier@arm.com>2018-11-02 16:42:33 +0000
commit6e993b5b8ea9c31ac4856b72d969dce704f82396 (patch)
tree5b52d6d63e75c29d6880dc58f708dae2e62f92e5 /tests/benchmark
parent1d1c0267e72017d40458e38886ff87b2179c4219 (diff)
downloadComputeLibrary-6e993b5b8ea9c31ac4856b72d969dce704f82396.tar.gz
COMPMID-761 Add CL/NEON QuantizationLayer benchmark tests
Change-Id: Ib50687139e6083a7fcc90cbc6d2e78aad9876c2b Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/113748 Reviewed-by: Pablo Tello <pablo.tello@arm.com> Tested-by: Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/benchmark')
-rw-r--r--tests/benchmark/CL/QuantizationLayer.cpp56
-rw-r--r--tests/benchmark/NEON/QuantizationLayer.cpp56
-rw-r--r--tests/benchmark/fixtures/QuantizationLayerFixture.h80
3 files changed, 192 insertions, 0 deletions
diff --git a/tests/benchmark/CL/QuantizationLayer.cpp b/tests/benchmark/CL/QuantizationLayer.cpp
new file mode 100644
index 0000000000..2dc775af0a
--- /dev/null
+++ b/tests/benchmark/CL/QuantizationLayer.cpp
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/CL/CLTensor.h"
+#include "arm_compute/runtime/CL/CLTensorAllocator.h"
+#include "arm_compute/runtime/CL/functions/CLQuantizationLayer.h"
+#include "tests/CL/CLAccessor.h"
+#include "tests/benchmark/fixtures/QuantizationLayerFixture.h"
+#include "tests/datasets/ShapeDatasets.h"
+#include "tests/framework/Macros.h"
+#include "tests/framework/datasets/Datasets.h"
+#include "utils/TypePrinter.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace benchmark
+{
+namespace
+{
+const auto data_types = framework::dataset::make("DataType", { DataType::F32 });
+} // namespace
+
+using CLQuantizationLayerFixture = QuantizationLayerFixture<CLTensor, CLQuantizationLayer, CLAccessor>;
+
+TEST_SUITE(CL)
+
+REGISTER_FIXTURE_DATA_TEST_CASE(QuantizationLayer, CLQuantizationLayerFixture, framework::DatasetMode::ALL,
+ framework::dataset::combine(datasets::Small3DShapes(), data_types));
+
+TEST_SUITE_END()
+} // namespace benchmark
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/benchmark/NEON/QuantizationLayer.cpp b/tests/benchmark/NEON/QuantizationLayer.cpp
new file mode 100644
index 0000000000..8db67287d2
--- /dev/null
+++ b/tests/benchmark/NEON/QuantizationLayer.cpp
@@ -0,0 +1,56 @@
+/*
+ * 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.
+ */
+#include "arm_compute/core/Types.h"
+#include "arm_compute/runtime/NEON/functions/NEQuantizationLayer.h"
+#include "arm_compute/runtime/Tensor.h"
+#include "arm_compute/runtime/TensorAllocator.h"
+#include "tests/NEON/Accessor.h"
+#include "tests/benchmark/fixtures/QuantizationLayerFixture.h"
+#include "tests/datasets/ShapeDatasets.h"
+#include "tests/framework/Macros.h"
+#include "tests/framework/datasets/Datasets.h"
+#include "utils/TypePrinter.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace benchmark
+{
+namespace
+{
+const auto data_types = framework::dataset::make("DataType", { DataType::F32 });
+} // namespace
+
+using NEQuantizationLayerFixture = QuantizationLayerFixture<Tensor, NEQuantizationLayer, Accessor>;
+
+TEST_SUITE(NEON)
+
+REGISTER_FIXTURE_DATA_TEST_CASE(QuantizationLayer, NEQuantizationLayerFixture, framework::DatasetMode::ALL,
+ framework::dataset::combine(datasets::Small3DShapes(), data_types));
+
+TEST_SUITE_END()
+} // namespace benchmark
+} // namespace test
+} // namespace arm_compute
diff --git a/tests/benchmark/fixtures/QuantizationLayerFixture.h b/tests/benchmark/fixtures/QuantizationLayerFixture.h
new file mode 100644
index 0000000000..5981f9995c
--- /dev/null
+++ b/tests/benchmark/fixtures/QuantizationLayerFixture.h
@@ -0,0 +1,80 @@
+/*
+ * 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_QUANTIZATION_LAYER_FIXTURE
+#define ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE
+
+#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
+{
+namespace benchmark
+{
+template <typename TensorType, typename Function, typename Accessor>
+class QuantizationLayerFixture : public framework::Fixture
+{
+public:
+ template <typename...>
+ void setup(TensorShape shape, DataType data_type)
+ {
+ // Create tensors
+ src = create_tensor<TensorType>(shape, data_type);
+ dst = create_tensor<TensorType>(shape, DataType::U8);
+
+ // Create and configure function
+ quantization_func.configure(&src, &dst);
+
+ // Allocate tensors
+ src.allocator()->allocate();
+ dst.allocator()->allocate();
+
+ // Fill tensors
+ library->fill_tensor_uniform(Accessor(src), 0);
+ }
+
+ void run()
+ {
+ quantization_func.run();
+ }
+
+ void teardown()
+ {
+ src.allocator()->free();
+ dst.allocator()->free();
+ }
+
+private:
+ TensorType src{};
+ TensorType dst{};
+ Function quantization_func{};
+};
+} // namespace benchmark
+} // namespace test
+} // namespace arm_compute
+#endif /* ARM_COMPUTE_TEST_QUANTIZATION_LAYER_FIXTURE */