diff options
author | SiCong Li <sicong.li@arm.com> | 2020-12-03 14:52:53 +0000 |
---|---|---|
committer | SiCong Li <sicong.li@arm.com> | 2020-12-08 15:28:37 +0000 |
commit | 98e33b97b92c912f058bfb3295adad1bcad3e80f (patch) | |
tree | 4cebd7dbfa9f79db3525d498b5ab16ff9b5e7e16 /examples/gemm_tuner | |
parent | 045d33c2e36575612662c237a30ec0a2d7d8cd3e (diff) | |
download | ComputeLibrary-98e33b97b92c912f058bfb3295adad1bcad3e80f.tar.gz |
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 <sicong.li@arm.com>
Change-Id: I14aa6648bbebdcd9b0bb77c47b46c27aa79d6253
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/4650
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'examples/gemm_tuner')
4 files changed, 26 insertions, 14 deletions
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<ToggleOption>("help")), M(parser.add_positional_option<SimpleOption<size_t>>("M", 100)), N(parser.add_positional_option<SimpleOption<size_t>>("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<EnumOption<DataType>>("type", supported_data_types, DataType::F32); + data_type = parser.add_option<EnumOption<DataType>>("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()); |