COMPMID-1332: Implement Slice for CL
Change-Id: I0dbc4fd7f640d31daa1970eb3da0e941cb771f2b
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/146145
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Giorgio Arena <giorgio.arena@arm.com>
Reviewed-by: Michalis Spyrou <michalis.spyrou@arm.com>
diff --git a/tests/validation/fixtures/StridedSliceFixture.h b/tests/validation/fixtures/SliceOperationsFixtures.h
similarity index 68%
rename from tests/validation/fixtures/StridedSliceFixture.h
rename to tests/validation/fixtures/SliceOperationsFixtures.h
index 26442ad..018bafb 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 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: