aboutsummaryrefslogtreecommitdiff
path: root/tests/datasets
diff options
context:
space:
mode:
authorRamy Elgammal <ramy.elgammal@arm.com>2022-11-08 02:14:46 +0000
committerRamy Elgammal <ramy.elgammal@arm.com>2022-11-29 10:24:59 +0000
commit404462af4ca002ece819161a03a4bdb19a87abf2 (patch)
tree09cf812530afcbe3fc524ce7eded5f06129e0889 /tests/datasets
parent03b2971ac69a86f10a1566938d1a25afee15746c (diff)
downloadComputeLibrary-404462af4ca002ece819161a03a4bdb19a87abf2.tar.gz
Adding GpuAdd to dynamic fusion operators
- Provide support for Add operator - Auto initialize the destination tensor before testing fusion in conv2d and elementwise binary ops. Resolves: COMPMID-5518 Signed-off-by: Ramy Elgammal <ramy.elgammal@arm.com> Change-Id: Ibd815020f02b57f88eea7c2921bdcf98605d99c5 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8617 Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Gunes Bayir <gunes.bayir@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/datasets')
-rw-r--r--tests/datasets/DynamicFusionDataset.h126
-rw-r--r--tests/datasets/ShapeDatasets.h70
2 files changed, 196 insertions, 0 deletions
diff --git a/tests/datasets/DynamicFusionDataset.h b/tests/datasets/DynamicFusionDataset.h
new file mode 100644
index 0000000000..5a1453b9ab
--- /dev/null
+++ b/tests/datasets/DynamicFusionDataset.h
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2022 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 TESTS_DATASETS_DYNAMICFUSIONDATASET
+#define TESTS_DATASETS_DYNAMICFUSIONDATASET
+
+#include "utils/TypePrinter.h"
+
+#include "arm_compute/core/TensorShape.h"
+#include "arm_compute/core/Types.h"
+
+namespace arm_compute
+{
+namespace test
+{
+namespace datasets
+{
+class DynamicFusionThreeInputs
+{
+public:
+ using type = std::tuple<TensorShape, TensorShape, TensorShape>;
+
+ struct iterator
+ {
+ iterator(std::vector<TensorShape>::const_iterator shape0_it,
+ std::vector<TensorShape>::const_iterator shape1_it,
+ std::vector<TensorShape>::const_iterator shape2_it)
+ : _shape0_it{ std::move(shape0_it) },
+ _shape1_it{ std::move(shape1_it) },
+ _shape2_it{ std::move(shape2_it) }
+ {
+ }
+
+ std::string description() const
+ {
+ std::stringstream description;
+ description << "shape0=" << *_shape0_it << ":";
+ description << "shape1=" << *_shape1_it << ":";
+ description << "shape2=" << *_shape2_it << ":";
+
+ return description.str();
+ }
+
+ DynamicFusionThreeInputs::type operator*() const
+ {
+ return std::make_tuple(*_shape0_it, *_shape1_it, *_shape2_it);
+ }
+
+ iterator &operator++()
+ {
+ ++_shape0_it;
+ ++_shape1_it;
+ ++_shape2_it;
+
+ return *this;
+ }
+
+ private:
+ std::vector<TensorShape>::const_iterator _shape0_it;
+ std::vector<TensorShape>::const_iterator _shape1_it;
+ std::vector<TensorShape>::const_iterator _shape2_it;
+ };
+
+ iterator begin() const
+ {
+ return iterator(_shape0_shapes.begin(), _shape1_shapes.begin(), _shape2_shapes.begin());
+ }
+
+ int size() const
+ {
+ return std::min(_shape0_shapes.size(), std::min(_shape1_shapes.size(), _shape2_shapes.size()));
+ }
+
+ void add_config(TensorShape shape0, TensorShape shape1, TensorShape shape2)
+ {
+ _shape0_shapes.emplace_back(std::move(shape0));
+ _shape1_shapes.emplace_back(std::move(shape1));
+ _shape2_shapes.emplace_back(std::move(shape2));
+ }
+
+protected:
+ DynamicFusionThreeInputs() = default;
+ DynamicFusionThreeInputs(DynamicFusionThreeInputs &&) = default;
+
+private:
+ std::vector<TensorShape> _shape0_shapes{};
+ std::vector<TensorShape> _shape1_shapes{};
+ std::vector<TensorShape> _shape2_shapes{};
+};
+
+class DynamicFusionElementwiseBinaryTwoOpsSmallShapes final : public DynamicFusionThreeInputs
+{
+public:
+ DynamicFusionElementwiseBinaryTwoOpsSmallShapes()
+ {
+ add_config(TensorShape{ 9U, 9U, 5U }, TensorShape{ 9U, 9U, 5U }, TensorShape{ 9U, 9U, 5U });
+ add_config(TensorShape{ 9U, 9U, 5U }, TensorShape{ 1U, 1U, 1U } /* Broadcast in X, Y, Z*/, TensorShape{ 9U, 9U, 5U });
+ add_config(TensorShape{ 27U, 13U, 2U }, TensorShape{ 27U, 1U, 1U } /* Broadcast in Y and Z*/, TensorShape{ 27U, 13U, 2U });
+ add_config(TensorShape{ 27U, 13U, 2U }, TensorShape{ 27U, 13U, 2U }, TensorShape{ 27U, 1U, 1U } /* Broadcast in Y and Z*/);
+ }
+};
+
+} // namespace datasets
+} // namespace test
+} // namespace arm_compute
+#endif /* TESTS_DATASETS_DYNAMICFUSIONDATASET */
diff --git a/tests/datasets/ShapeDatasets.h b/tests/datasets/ShapeDatasets.h
index e4277a981e..047457c99e 100644
--- a/tests/datasets/ShapeDatasets.h
+++ b/tests/datasets/ShapeDatasets.h
@@ -212,6 +212,25 @@ public:
}
};
+/** Data set containing small tensor shapes. */
+class SmallShapesNoBatches final : public ShapeDataset
+{
+public:
+ SmallShapesNoBatches()
+ : ShapeDataset("Shape",
+ {
+ // Batch size 1
+ TensorShape{ 3U, 11U },
+ TensorShape{ 1U, 16U },
+ TensorShape{ 27U, 13U, 7U },
+ TensorShape{ 7U, 7U, 17U },
+ TensorShape{ 33U, 13U, 2U },
+ TensorShape{ 11U, 11U, 3U }
+ })
+ {
+ }
+};
+
/** Data set containing pairs of tiny tensor shapes that are broadcast compatible. */
class TinyShapesBroadcast final : public framework::dataset::ZipDataset<ShapeDataset, ShapeDataset>
{
@@ -282,6 +301,44 @@ public:
}
};
+class TemporaryLimitedSmallShapesBroadcast final : public framework::dataset::ZipDataset<ShapeDataset, ShapeDataset>
+{
+public:
+ TemporaryLimitedSmallShapesBroadcast()
+ : ZipDataset<ShapeDataset, ShapeDataset>(
+ ShapeDataset("Shape0",
+ {
+ TensorShape{ 9U, 9U, 5U },
+ TensorShape{ 27U, 13U, 2U },
+ }),
+ ShapeDataset("Shape1",
+ {
+ TensorShape{ 1U, 1U, 1U }, // Broadcast in X, Y, Z
+ TensorShape{ 27U, 1U, 1U }, // Broadcast in Y and Z
+ }))
+ {
+ }
+};
+
+class TemporaryLimitedLargeShapesBroadcast final : public framework::dataset::ZipDataset<ShapeDataset, ShapeDataset>
+{
+public:
+ TemporaryLimitedLargeShapesBroadcast()
+ : ZipDataset<ShapeDataset, ShapeDataset>(
+ ShapeDataset("Shape0",
+ {
+ TensorShape{ 127U, 25U, 5U },
+ TensorShape{ 485, 40U, 10U }
+ }),
+ ShapeDataset("Shape1",
+ {
+ TensorShape{ 1U, 1U, 1U }, // Broadcast in X, Y, Z
+ TensorShape{ 485U, 1U, 1U }, // Broadcast in Y, Z
+ }))
+ {
+ }
+};
+
/** Data set containing medium tensor shapes. */
class MediumShapes final : public ShapeDataset
{
@@ -359,6 +416,19 @@ public:
}
};
+/** Data set containing large tensor shapes. */
+class LargeShapesNoBatches final : public ShapeDataset
+{
+public:
+ LargeShapesNoBatches()
+ : ShapeDataset("Shape",
+ {
+ TensorShape{ 582U, 131U, 2U },
+ })
+ {
+ }
+};
+
/** Data set containing pairs of large tensor shapes that are broadcast compatible. */
class LargeShapesBroadcast final : public framework::dataset::ZipDataset<ShapeDataset, ShapeDataset>
{