diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-08-24 11:25:32 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:54:54 +0000 |
commit | c1a72451273ec019e3e74c4b53ea847afe8ddf7c (patch) | |
tree | b4bd62a7ccd22a2c60070d7fa23ceba794dcac5c /tests/validation/fixtures | |
parent | 6a8d3b6db13042a859972c33cf40cfeb6d7cfcda (diff) | |
download | ComputeLibrary-c1a72451273ec019e3e74c4b53ea847afe8ddf7c.tar.gz |
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>
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: |