aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/fixtures
diff options
context:
space:
mode:
Diffstat (limited to 'tests/validation/fixtures')
-rw-r--r--tests/validation/fixtures/SliceOperationsFixtures.h (renamed from tests/validation/fixtures/StridedSliceFixture.h)65
1 files changed, 64 insertions, 1 deletions
diff --git a/tests/validation/fixtures/StridedSliceFixture.h b/tests/validation/fixtures/SliceOperationsFixtures.h
index 26442ad834..018bafba6c 100644
--- a/tests/validation/fixtures/StridedSliceFixture.h
+++ b/tests/validation/fixtures/SliceOperationsFixtures.h
@@ -34,7 +34,7 @@
#include "tests/framework/Asserts.h"
#include "tests/framework/Fixture.h"
#include "tests/validation/Helpers.h"
-#include "tests/validation/reference/StridedSlice.h"
+#include "tests/validation/reference/SliceOperations.h"
namespace arm_compute
{
@@ -43,6 +43,69 @@ namespace test
namespace validation
{
template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
+class SliceFixture : public framework::Fixture
+{
+public:
+ template <typename...>
+ void setup(TensorShape shape, Coordinates starts, Coordinates ends, DataType data_type)
+ {
+ _target = compute_target(shape, starts, ends, data_type);
+ _reference = compute_reference(shape, starts, ends, data_type);
+ }
+
+protected:
+ template <typename U>
+ void fill(U &&tensor, int i)
+ {
+ library->fill_tensor_uniform(tensor, i);
+ }
+
+ TensorType compute_target(const TensorShape &shape, const Coordinates &starts, const Coordinates &ends, DataType data_type)
+ {
+ // Create tensors
+ TensorType src = create_tensor<TensorType>(shape, data_type);
+ TensorType dst;
+
+ // Create and configure function
+ FunctionType slice;
+ slice.configure(&src, &dst, starts, ends);
+
+ ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+
+ // Allocate tensors
+ src.allocator()->allocate();
+ dst.allocator()->allocate();
+
+ ARM_COMPUTE_EXPECT(!src.info()->is_resizable(), framework::LogLevel::ERRORS);
+ ARM_COMPUTE_EXPECT(!dst.info()->is_resizable(), framework::LogLevel::ERRORS);
+
+ // Fill tensors
+ fill(AccessorType(src), 0);
+ fill(AccessorType(dst), 1);
+
+ // Compute function
+ slice.run();
+
+ return dst;
+ }
+
+ SimpleTensor<T> compute_reference(const TensorShape &shape, const Coordinates &starts, const Coordinates &ends, DataType data_type)
+ {
+ // Create reference
+ SimpleTensor<T> src{ shape, data_type };
+
+ // Fill reference
+ fill(src, 0);
+
+ return reference::slice(src, starts, ends);
+ }
+
+ TensorType _target{};
+ SimpleTensor<T> _reference{};
+};
+
+template <typename TensorType, typename AccessorType, typename FunctionType, typename T>
class StridedSliceFixture : public framework::Fixture
{
public: