From 7377107378d6c26439320fce78a551e85b5ad36a Mon Sep 17 00:00:00 2001 From: Mohammed Suhail Munshi Date: Mon, 25 Mar 2024 15:55:42 +0000 Subject: Scatter GPU Kernel Implementation for 1D tensors. Resolves: [COMPMID-6891, COMPMID-6892] Change-Id: I5b094fff1bff4c4c59cc44f7d6beab0e40133d8e Signed-off-by: Mohammed Suhail Munshi Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/11394 Tested-by: Arm Jenkins Reviewed-by: Gunes Bayir Comments-Addressed: Arm Jenkins Benchmark: Arm Jenkins --- tests/validation/fixtures/ScatterLayerFixture.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'tests/validation/fixtures') diff --git a/tests/validation/fixtures/ScatterLayerFixture.h b/tests/validation/fixtures/ScatterLayerFixture.h index bda5532a51..451a1e1416 100644 --- a/tests/validation/fixtures/ScatterLayerFixture.h +++ b/tests/validation/fixtures/ScatterLayerFixture.h @@ -27,7 +27,7 @@ #include "arm_compute/core/Utils.h" #include "arm_compute/runtime/CL/CLTensorAllocator.h" #include "tests/Globals.h" -#include "tests/framework/Asserts.h" // Required for ARM_COMPUTE_ASSERT +#include "tests/framework/Asserts.h" #include "tests/framework/Fixture.h" #include "tests/validation/Validation.h" #include "tests/validation/reference/ScatterLayer.h" @@ -71,14 +71,14 @@ protected: } } - // This is used to fill indices tensor with U32 datatype. + // This is used to fill indices tensor with S32 datatype. // Used to prevent ONLY having values that are out of bounds. template void fill_indices(U &&tensor, int i, const TensorShape &shape) { - // Calculate max indices the shape should contain. Add an arbitrary constant to allow testing for some out of bounds values. - const uint32_t max = std::max({shape[0] , shape[1], shape[2]}) + 5; - library->fill_tensor_uniform(tensor, i, static_cast(0), static_cast(max)); + // Calculate max indices the shape should contain. Add an arbitrary value to allow testing for some out of bounds values (In this case min dimension) + const int32_t max = std::max({shape[0] , shape[1], shape[2]}); + library->fill_tensor_uniform(tensor, i, static_cast(-2), static_cast(max)); } TensorType compute_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, const TensorShape &out_shape, DataType data_type, const ScatterInfo info, QuantizationInfo a_qinfo, QuantizationInfo o_qinfo) @@ -88,7 +88,7 @@ protected: // In order - src, updates, indices, output. TensorType src = create_tensor(shape_a, data_type, 1, a_qinfo); TensorType updates = create_tensor(shape_b, data_type, 1, a_qinfo); - TensorType indices = create_tensor(shape_c, DataType::U32, 1, QuantizationInfo()); + TensorType indices = create_tensor(shape_c, DataType::S32, 1, QuantizationInfo()); TensorType dst = create_tensor(out_shape, data_type, 1, o_qinfo); FunctionType scatter; @@ -127,7 +127,6 @@ protected: fill_indices(AccessorType(indices), 2, out_shape); scatter.run(); - return dst; } @@ -140,7 +139,7 @@ protected: // Create reference tensors SimpleTensor src{ a_shape, data_type, 1, a_qinfo }; SimpleTensor updates{b_shape, data_type, 1, QuantizationInfo() }; - SimpleTensor indices{ c_shape, DataType::U32, 1, QuantizationInfo() }; + SimpleTensor indices{ c_shape, DataType::S32, 1, QuantizationInfo() }; // Fill reference fill(src, 0); @@ -148,9 +147,7 @@ protected: fill_indices(indices, 2, out_shape); // Calculate individual reference. - auto result = reference::scatter_layer(src, updates, indices, out_shape, info); - - return result; + return reference::scatter_layer(src, updates, indices, out_shape, info); } TensorType _target{}; -- cgit v1.2.1