diff options
Diffstat (limited to 'tests/validate_examples/cl_gemm.cpp')
-rw-r--r-- | tests/validate_examples/cl_gemm.cpp | 74 |
1 files changed, 32 insertions, 42 deletions
diff --git a/tests/validate_examples/cl_gemm.cpp b/tests/validate_examples/cl_gemm.cpp index cdf60cd65b..8189b228c2 100644 --- a/tests/validate_examples/cl_gemm.cpp +++ b/tests/validate_examples/cl_gemm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019 ARM Limited. + * Copyright (c) 2017-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -26,10 +26,25 @@ #endif /* ARM_COMPUTE_CL */ #include "arm_compute/core/Types.h" +#include "arm_compute/core/Utils.h" #include "arm_compute/core/utils/quantization/AsymmHelpers.h" -#include "arm_compute/runtime/CL/CLFunctions.h" #include "arm_compute/runtime/CL/CLScheduler.h" - +#include "arm_compute/runtime/CL/functions/CLGEMM.h" +#include "arm_compute/runtime/CL/functions/CLGEMMLowpMatrixMultiplyCore.h" +#include "arm_compute/runtime/CL/functions/CLGEMMLowpOutputStage.h" +#include "src/core/CL/kernels/CLFillBorderKernel.h" +#include "src/gpu/cl/kernels/ClCastKernel.h" +#include "src/gpu/cl/kernels/ClGemmLowpMatrixMultiplyNativeKernel.h" +#include "src/gpu/cl/kernels/ClGemmLowpMatrixMultiplyReshapedOnlyRhsKernel.h" +#include "src/gpu/cl/kernels/ClGemmLowpOffsetContributionKernel.h" +#include "src/gpu/cl/kernels/ClGemmLowpOffsetContributionOutputStageKernel.h" +#include "src/gpu/cl/kernels/ClGemmLowpReductionKernel.h" +#include "src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedKernel.h" +#include "src/gpu/cl/kernels/ClGemmMatrixMultiplyReshapedOnlyRhsKernel.h" +#include "src/gpu/cl/kernels/ClGemmReshapeLhsMatrixKernel.h" +#include "src/gpu/cl/kernels/ClGemmReshapeRhsMatrixKernel.h" +#include "src/gpu/cl/kernels/ClIm2ColKernel.h" +#include "src/gpu/cl/kernels/ClWeightsReshapeKernel.h" #include "tests/AssetsLibrary.h" #include "tests/CL/CLAccessor.h" #include "tests/Globals.h" @@ -59,40 +74,6 @@ RelativeTolerance<float> tolerance_f32(0.001f); /**< F32 Toleran RelativeTolerance<half_float::half> tolerance_f16(half(0.2)); /**< F16 Tolerance value for comparing reference's output against implementation's output for floating point data types */ constexpr float tolerance_num_f16 = 0.02f; /**< F16 Tolerance number */ -namespace arm_compute -{ -DataType data_type_from_name(const std::string &name) -{ - static const std::map<std::string, DataType> data_types = - { - { "f16", DataType::F16 }, - { "f32", DataType::F32 }, - { "qasymm8", DataType::QASYMM8 }, - }; - -#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED - try - { -#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */ - return data_types.at(utility::tolower(name)); - -#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED - } - catch(const std::out_of_range &) - { - throw std::invalid_argument(name); - } -#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */ -} - -inline ::std::istream &operator>>(::std::istream &stream, DataType &data_type) -{ - std::string value; - stream >> value; - data_type = data_type_from_name(value); - return stream; -} -} // namespace arm_compute namespace { class GEMMCommandLineOptions final @@ -223,7 +204,11 @@ public: mm_gemmlowp.configure(&src0, &src1, nullptr, &tmp_dst); // Configure GEMMlowp output stage - mm_gemmlowp_output_stage.configure(&tmp_dst, add_bias ? &biases : nullptr, &dst, dst_multiplier, dst_shift, offset_dst); + GEMMLowpOutputStageInfo gemm_info{}; + gemm_info.gemmlowp_multiplier = dst_multiplier; + gemm_info.gemmlowp_shift = dst_shift; + gemm_info.gemmlowp_offset = offset_dst; + mm_gemmlowp_output_stage.configure(&tmp_dst, add_bias ? &biases : nullptr, &dst, gemm_info); tmp_dst.allocator()->allocate(); biases.allocator()->allocate(); fill(CLAccessor(biases), 3); @@ -363,9 +348,14 @@ private: switch(tensor.data_type()) { case DataType::F16: + { + arm_compute::utils::uniform_real_distribution_16bit<half> distribution{ -1.0f, 1.0f }; + library->fill(tensor, distribution, i); + break; + } case DataType::F32: { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); + std::uniform_real_distribution<float> distribution(-1.0f, 1.0f); library->fill(tensor, distribution, i); break; } @@ -406,9 +396,9 @@ private: CLTensor src0{}, src1{}, src2{}, dst{}; CLTensor tmp_dst{}, biases{}; - CLGEMM mm_gemm{}; - CLGEMMLowpMatrixMultiplyCore mm_gemmlowp{}; - CLGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint mm_gemmlowp_output_stage{}; + CLGEMM mm_gemm{}; + CLGEMMLowpMatrixMultiplyCore mm_gemmlowp{}; + CLGEMMLowpOutputStage mm_gemmlowp_output_stage{}; size_t M{ 7 }, N{ 3 }, K{ 5 }, B{ 1 }; DataType data_type{ DataType::F32 }; |