From 98e33b97b92c912f058bfb3295adad1bcad3e80f Mon Sep 17 00:00:00 2001 From: SiCong Li Date: Thu, 3 Dec 2020 14:52:53 +0000 Subject: Fix invalid arguments error for cl_gemmlowp* examples without arguments * Pass QASYMM8 as default argument for cl_gemmlowp examples * Fix the (arbitrary) quantization info to be the same across tensors to avoid quantization information mismatch issue Resolves COMPMID-4044 Signed-off-by: SiCong Li Change-Id: I14aa6648bbebdcd9b0bb77c47b46c27aa79d6253 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4650 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- examples/gemm_tuner/CommonGemmExampleOptions.cpp | 5 +++-- examples/gemm_tuner/CommonGemmExampleOptions.h | 5 +++-- examples/gemm_tuner/cl_gemmlowp_reshaped.cpp | 15 ++++++++++----- ...wp_reshaped_rhs_only_fused_output_stage_fixedpoint.cpp | 15 ++++++++++----- 4 files changed, 26 insertions(+), 14 deletions(-) (limited to 'examples') diff --git a/examples/gemm_tuner/CommonGemmExampleOptions.cpp b/examples/gemm_tuner/CommonGemmExampleOptions.cpp index f50fc63562..440973737c 100644 --- a/examples/gemm_tuner/CommonGemmExampleOptions.cpp +++ b/examples/gemm_tuner/CommonGemmExampleOptions.cpp @@ -38,7 +38,7 @@ using namespace utils; return os; } -CommonGemmExampleOptions::CommonGemmExampleOptions(CommandLineParser &parser) +CommonGemmExampleOptions::CommonGemmExampleOptions(CommandLineParser &parser, DataType default_data_type) : help(parser.add_option("help")), M(parser.add_positional_option>("M", 100)), N(parser.add_positional_option>("N", 100)), @@ -52,8 +52,9 @@ CommonGemmExampleOptions::CommonGemmExampleOptions(CommandLineParser &parser) DataType::F32, DataType::QASYMM8, }; + ARM_COMPUTE_ERROR_ON_MSG(supported_data_types.find(default_data_type) == supported_data_types.end(), "Default data type unsupported"); - data_type = parser.add_option>("type", supported_data_types, DataType::F32); + data_type = parser.add_option>("type", supported_data_types, default_data_type); help->set_help("Show this help message."); M->set_help("Number of lhs matrix rows."); diff --git a/examples/gemm_tuner/CommonGemmExampleOptions.h b/examples/gemm_tuner/CommonGemmExampleOptions.h index 5c4be286d6..633e9252bd 100644 --- a/examples/gemm_tuner/CommonGemmExampleOptions.h +++ b/examples/gemm_tuner/CommonGemmExampleOptions.h @@ -65,9 +65,10 @@ class CommonGemmExampleOptions public: /** Constructor * - * @param[in,out] parser A parser on which "parse()" hasn't been called yet. + * @param[in,out] parser A parser on which "parse()" hasn't been called yet. + * @param[in] default_data_type Default data type if unspecified. */ - CommonGemmExampleOptions(arm_compute::utils::CommandLineParser &parser); + CommonGemmExampleOptions(arm_compute::utils::CommandLineParser &parser, arm_compute::DataType default_data_type = arm_compute::DataType::F32); /** Prevent instances of this class from being copied (As this class contains pointers) */ CommonGemmExampleOptions(const CommonGemmExampleOptions &) = delete; /** Prevent instances of this class from being copied (As this class contains pointers) */ diff --git a/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp b/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp index c45c38411f..8d100f613a 100644 --- a/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp +++ b/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp @@ -181,7 +181,7 @@ public: // Parse command line options CommandLineParser parser; - CommonGemmExampleOptions param_options(parser); + CommonGemmExampleOptions param_options(parser, DataType::QASYMM8); GemmConfigOptions config_options(parser); parser.parse(argc, argv); @@ -214,9 +214,13 @@ public: rhs.allocator()->init(TensorInfo(TensorShape(params.N, params.K, params.B), 1, params.data_type)); // Set arbitrary quantization information - lhs.info()->set_quantization_info({ 0.012, 3 }); - rhs.info()->set_quantization_info({ 0.012, 3 }); - dst.info()->set_quantization_info({ 0.012, 3 }); + const QuantizationInfo q_info + { + 0.012, 3 + }; + lhs.info()->set_quantization_info(q_info); + rhs.info()->set_quantization_info(q_info); + dst.info()->set_quantization_info(q_info); GEMMLHSMatrixInfo lhs_info; lhs_info.m0 = configs.m0; @@ -234,8 +238,9 @@ public: rhs_info.export_to_cl_image = false; // CL image not supported for quantized cases yet lhs_reshaped.allocator()->init(TensorInfo(compute_lhs_reshaped_shape(*lhs.info(), lhs_info), 1, params.data_type)); - rhs_reshaped.allocator()->init(TensorInfo(compute_rhs_reshaped_shape(*rhs.info(), rhs_info), 1, params.data_type)); + lhs_reshaped.info()->set_quantization_info(q_info); + rhs_reshaped.info()->set_quantization_info(q_info); if(rhs_info.export_to_cl_image) { diff --git a/examples/gemm_tuner/cl_gemmlowp_reshaped_rhs_only_fused_output_stage_fixedpoint.cpp b/examples/gemm_tuner/cl_gemmlowp_reshaped_rhs_only_fused_output_stage_fixedpoint.cpp index 8323bbd971..a990ef1dee 100644 --- a/examples/gemm_tuner/cl_gemmlowp_reshaped_rhs_only_fused_output_stage_fixedpoint.cpp +++ b/examples/gemm_tuner/cl_gemmlowp_reshaped_rhs_only_fused_output_stage_fixedpoint.cpp @@ -160,7 +160,7 @@ public: // Parse command line options CommandLineParser parser; - CommonGemmExampleOptions param_options(parser); + CommonGemmExampleOptions param_options(parser, DataType::QASYMM8); GemmConfigOptions config_options(parser); parser.parse(argc, argv); @@ -196,10 +196,14 @@ public: // Set arbitrary quantization information (non-zero offset to ensure offset contribution stage is included) // Could be extended in the future to include a user-controlled option for offset == 0 - lhs.info()->set_quantization_info({ 0.012, 3 }); - rhs.info()->set_quantization_info({ 0.012, 3 }); - bias.info()->set_quantization_info({ 0.012, 3 }); - dst.info()->set_quantization_info({ 0.012, 3 }); + const QuantizationInfo q_info + { + 0.012, 3 + }; + lhs.info()->set_quantization_info(q_info); + rhs.info()->set_quantization_info(q_info); + bias.info()->set_quantization_info(q_info); + dst.info()->set_quantization_info(q_info); GEMMLHSMatrixInfo lhs_info; lhs_info.m0 = configs.m0; @@ -214,6 +218,7 @@ public: rhs_info.export_to_cl_image = false; // CL image not supported for quantized cases yet rhs_reshaped.allocator()->init(TensorInfo(compute_rhs_reshaped_shape(*rhs.info(), rhs_info), 1, params.data_type)); + rhs_reshaped.info()->set_quantization_info(q_info); if(rhs_info.export_to_cl_image) { examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info()); -- cgit v1.2.1