diff options
5 files changed, 31 insertions, 10 deletions
diff --git a/examples/gemm_tuner/GemmTunerHelpers.h b/examples/gemm_tuner/GemmTunerHelpers.h index 23cf14cf18..ae5cfbb19e 100644 --- a/examples/gemm_tuner/GemmTunerHelpers.h +++ b/examples/gemm_tuner/GemmTunerHelpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -31,19 +31,24 @@ namespace examples { namespace gemm_tuner_helpers { -void update_padding_for_cl_image(arm_compute::ITensorInfo *tensor) +bool update_padding_for_cl_image(arm_compute::ITensorInfo *tensor) { constexpr unsigned int num_floats_per_pixel = 4; const unsigned int stride_y_in_elements = tensor->strides_in_bytes()[1] / tensor->element_size(); const unsigned int pixel_aligment = arm_compute::get_cl_image_pitch_alignment( arm_compute::CLKernelLibrary::get().get_device()); + if(pixel_aligment == 0) + { + return false; + } const unsigned int row_pitch_alignment = pixel_aligment * num_floats_per_pixel; const unsigned int round_up_width = ((stride_y_in_elements + row_pitch_alignment - 1) / row_pitch_alignment) * row_pitch_alignment; const unsigned int padding = round_up_width - stride_y_in_elements; tensor->extend_padding(arm_compute::PaddingSize(0, padding, 0, 0)); + return true; } } // namespace gemm_tuner_helpers } // namespace examples diff --git a/examples/gemm_tuner/cl_gemm_reshaped.cpp b/examples/gemm_tuner/cl_gemm_reshaped.cpp index e518b86b4e..2ea4769dd3 100644 --- a/examples/gemm_tuner/cl_gemm_reshaped.cpp +++ b/examples/gemm_tuner/cl_gemm_reshaped.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -260,7 +260,11 @@ public: if(rhs_info.export_to_cl_image) { - examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info()); + if(!examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info())) + { + std::cerr << "cl_image is not supported on the device, disable export_to_cl_image" << std::endl; + return false; + } } // Validate argments diff --git a/examples/gemm_tuner/cl_gemm_reshaped_rhs_only.cpp b/examples/gemm_tuner/cl_gemm_reshaped_rhs_only.cpp index 08bd5d2bd3..10fd2984cf 100644 --- a/examples/gemm_tuner/cl_gemm_reshaped_rhs_only.cpp +++ b/examples/gemm_tuner/cl_gemm_reshaped_rhs_only.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2020 Arm Limited. + * Copyright (c) 2019-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -227,7 +227,11 @@ public: if(rhs_info.export_to_cl_image) { - examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info()); + if(!examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info())) + { + std::cerr << "cl_image is not supported on the device, disable export_to_cl_image" << std::endl; + return false; + } } // Validate argments diff --git a/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp b/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp index 8d100f613a..7c26e0f389 100644 --- a/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp +++ b/examples/gemm_tuner/cl_gemmlowp_reshaped.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -244,7 +244,11 @@ public: if(rhs_info.export_to_cl_image) { - examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info()); + if(!examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info())) + { + std::cerr << "cl_image is not supported on the device, disable export_to_cl_image" << std::endl; + return false; + } } GEMMReshapeInfo gemm_info 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 a990ef1dee..f25341ce25 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Arm Limited. + * Copyright (c) 2020-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -221,7 +221,11 @@ public: 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()); + if(!examples::gemm_tuner_helpers::update_padding_for_cl_image(rhs_reshaped.info())) + { + std::cerr << "cl_image is not supported on the device, disable export_to_cl_image" << std::endl; + return false; + } } // Configure output stage for quantized case |