diff options
Diffstat (limited to 'tests/validation/fixtures/dynamic_fusion/operators/SoftmaxFixture.h')
-rw-r--r-- | tests/validation/fixtures/dynamic_fusion/operators/SoftmaxFixture.h | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/tests/validation/fixtures/dynamic_fusion/operators/SoftmaxFixture.h b/tests/validation/fixtures/dynamic_fusion/operators/SoftmaxFixture.h index 1ed133d2ef..175d4ff889 100644 --- a/tests/validation/fixtures/dynamic_fusion/operators/SoftmaxFixture.h +++ b/tests/validation/fixtures/dynamic_fusion/operators/SoftmaxFixture.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2023 Arm Limited. +* Copyright (c) 2023-2024 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -21,18 +21,18 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef TESTS_VALIDATION_FIXTURES_DYNAMIC_FUSION_OPERATORS_SOFTMAXFIXTURE -#define TESTS_VALIDATION_FIXTURES_DYNAMIC_FUSION_OPERATORS_SOFTMAXFIXTURE +#ifndef ACL_TESTS_VALIDATION_FIXTURES_DYNAMIC_FUSION_OPERATORS_SOFTMAXFIXTURE_H +#define ACL_TESTS_VALIDATION_FIXTURES_DYNAMIC_FUSION_OPERATORS_SOFTMAXFIXTURE_H #include "arm_compute/dynamic_fusion/runtime/gpu/cl/ClWorkloadRuntime.h" #include "arm_compute/dynamic_fusion/sketch/attributes/SoftmaxAttributes.h" #include "arm_compute/dynamic_fusion/sketch/gpu/GpuWorkloadSketch.h" -#include "tests/SimpleTensor.h" #include "tests/framework/Fixture.h" #include "tests/framework/Macros.h" -#include "tests/validation/Validation.h" +#include "tests/SimpleTensor.h" #include "tests/validation/reference/SoftmaxLayer.h" +#include "tests/validation/Validation.h" using namespace arm_compute::experimental::dynamic_fusion; @@ -56,17 +56,17 @@ protected: template <typename U> void fill(U &&tensor) { - if(tensor.data_type() == DataType::F32) + if (tensor.data_type() == DataType::F32) { std::uniform_real_distribution<float> distribution(-10.0f, 10.0f); library->fill(tensor, distribution, 0); } - else if(tensor.data_type() == DataType::F16) + else if (tensor.data_type() == DataType::F16) { - arm_compute::utils::uniform_real_distribution_16bit<half> distribution{ -10.0f, 10.0f }; + arm_compute::utils::uniform_real_distribution_16bit<half> distribution{-10.0f, 10.0f}; library->fill(tensor, distribution, 0); } - else if(!is_data_type_quantized(tensor.data_type())) + else if (!is_data_type_quantized(tensor.data_type())) { std::uniform_int_distribution<> distribution(0, 100); library->fill(tensor, distribution, 0); @@ -81,14 +81,14 @@ protected: { // Create a new workload sketch CLCompileContext cl_compile_ctx = CLKernelLibrary::get().get_compile_context(); - GpuWorkloadContext context = GpuWorkloadContext{ &cl_compile_ctx }; - GpuWorkloadSketch sketch{ &context }; + GpuWorkloadContext context = GpuWorkloadContext{&cl_compile_ctx}; + GpuWorkloadSketch sketch{&context}; SoftmaxAttributes softmax_attr{}; softmax_attr.axis(axis).beta(beta).is_log_softmax(is_log); - TensorInfo src_info = context.create_tensor_info(shape, 1, data_type); - TensorInfo dst_info = context.create_tensor_info(shape, 1, data_type); - FunctionType::create_op(sketch, &src_info, &dst_info, softmax_attr); + ITensorInfo *src_info = context.create_tensor_info(shape, 1, data_type); + ITensorInfo *dst_info = context.create_tensor_info(shape, 1, data_type); + FunctionType::create_op(sketch, src_info, dst_info, softmax_attr); // Configure runtime ClWorkloadRuntime runtime; @@ -96,7 +96,7 @@ protected: // (Important) Allocate auxiliary tensor memory if there are any // Instead of using ACL allocated memory, the user can choose to import memory into the tensors - for(auto &data : runtime.get_auxiliary_tensors()) + for (auto &data : runtime.get_auxiliary_tensors()) { CLTensor *tensor = std::get<0>(data); TensorInfo info = std::get<1>(data); @@ -109,8 +109,8 @@ protected: TensorType dst{}; // Initialize user tensors - src.allocator()->init(src_info); - dst.allocator()->init(dst_info); + src.allocator()->init(*src_info); + dst.allocator()->init(*dst_info); // Allocate and fill user tensors src.allocator()->allocate(); @@ -118,15 +118,16 @@ protected: fill(AccessorType(src)); // Run runtime - runtime.run({ &src, &dst }); + runtime.run({&src, &dst}); return dst; } - SimpleTensor<T> compute_reference(const TensorShape &shape, DataType data_type, float beta, int32_t axis, bool is_log) + SimpleTensor<T> + compute_reference(const TensorShape &shape, DataType data_type, float beta, int32_t axis, bool is_log) { // Create reference - SimpleTensor<T> src{ shape, data_type, 1 }; + SimpleTensor<T> src{shape, data_type, 1}; // Fill reference fill(src); @@ -139,16 +140,14 @@ protected: }; template <typename TensorType, typename AccessorType, typename FunctionType, typename T> -class DynamicFusionSoftmaxValidationFixture : public DynamicFusionSoftmaxValidationGenericFixture<TensorType, AccessorType, FunctionType, T> +class DynamicFusionSoftmaxValidationFixture + : public DynamicFusionSoftmaxValidationGenericFixture<TensorType, AccessorType, FunctionType, T> { public: void setup(TensorShape shape, DataType data_type, float beta, size_t axis, bool is_log) { - DynamicFusionSoftmaxValidationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup(shape, - data_type, - beta, - axis, - is_log); + DynamicFusionSoftmaxValidationGenericFixture<TensorType, AccessorType, FunctionType, T>::setup( + shape, data_type, beta, axis, is_log); } }; @@ -156,4 +155,4 @@ public: } // namespace test } // namespace arm_compute -#endif /* TESTS_VALIDATION_FIXTURES_DYNAMIC_FUSION_OPERATORS_SOFTMAXFIXTURE */ +#endif // ACL_TESTS_VALIDATION_FIXTURES_DYNAMIC_FUSION_OPERATORS_SOFTMAXFIXTURE_H |