Fix various coverity issues
Resolves COMPMID-6677
Signed-off-by: SiCong Li <sicong.li@arm.com>
Change-Id: I99bf2385f6edc0836faacb31f5c66ed4fb051e40
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10729
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/src/core/CL/CLMutableCommandBuffer.cpp b/src/core/CL/CLMutableCommandBuffer.cpp
index 05b351f..0e078d8 100644
--- a/src/core/CL/CLMutableCommandBuffer.cpp
+++ b/src/core/CL/CLMutableCommandBuffer.cpp
@@ -26,6 +26,7 @@
#include "arm_compute/core/Error.h"
+#include "src/common/utils/Log.h"
#include "src/core/CL/CLUtils.h"
namespace arm_compute
@@ -48,7 +49,11 @@
CLMutableCommandBuffer::~CLMutableCommandBuffer()
{
const auto status = clReleaseCommandBufferKHR(_cb);
- handle_cl_error("clReleaseCommandBufferKHR", status);
+ if (status != CL_SUCCESS)
+ {
+ const std::string error_message = "clReleaseCommandBufferKHR - Error code: " + std::to_string(status);
+ ARM_COMPUTE_LOG_ERROR_ACL(error_message);
+ }
}
void CLMutableCommandBuffer::add_kernel(cl_kernel kernel,
diff --git a/src/cpu/operators/internal/CpuGemmAssemblyDispatch.cpp b/src/cpu/operators/internal/CpuGemmAssemblyDispatch.cpp
index 82bd465..611bc76 100644
--- a/src/cpu/operators/internal/CpuGemmAssemblyDispatch.cpp
+++ b/src/cpu/operators/internal/CpuGemmAssemblyDispatch.cpp
@@ -541,6 +541,7 @@
{
auto b = tensors.get_const_tensor(TensorType::ACL_SRC_1);
auto c = tensors.get_const_tensor(TensorType::ACL_SRC_2);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(b);
// Setup up matrix bias in the assembly kernel, it's just a pointer to matrix C.
if (c && c->info()->data_type() == DataType::S32)
@@ -614,6 +615,7 @@
auto b = tensors.get_const_tensor(TensorType::ACL_SRC_1);
auto c = tensors.get_const_tensor(TensorType::ACL_SRC_2);
auto d = tensors.get_tensor(TensorType::ACL_DST);
+ ARM_COMPUTE_ERROR_ON_NULLPTR(a, d);
int lda = a->info()->strides_in_bytes().y() / a->info()->element_size();
int ldb = 0;
@@ -652,7 +654,7 @@
}
// Check if B is pre-tranposed and de-reference if not
- if (!_gemm_kernel_asm->B_is_pretransposed())
+ if (b_to_use && !_gemm_kernel_asm->B_is_pretransposed())
{
ldb = b_to_use->info()->strides_in_bytes().y() / b_to_use->info()->element_size();
multi_stride_b = b_to_use->info()->strides_in_bytes().z() / b_to_use->info()->element_size();
@@ -670,7 +672,7 @@
}
// Pretranspose B if required
- if (_B_pretranspose_required)
+ if (b_to_use && _B_pretranspose_required)
{
// Fixed format kernels need no pretranspose.
ARM_COMPUTE_ERROR_ON(arm_compute::is_fixed_format(
diff --git a/src/gpu/cl/operators/ClMatMul.cpp b/src/gpu/cl/operators/ClMatMul.cpp
index 9962ee5..4330300 100644
--- a/src/gpu/cl/operators/ClMatMul.cpp
+++ b/src/gpu/cl/operators/ClMatMul.cpp
@@ -91,8 +91,6 @@
return MatMulKernelType::NATIVE_FP;
}
-
- return is_quantized ? MatMulKernelType::NATIVE_QUANTIZED : MatMulKernelType::NATIVE_FP;
}
} // namespace
using namespace arm_compute::opencl::kernels;
diff --git a/src/runtime/CL/CLMemoryRegion.cpp b/src/runtime/CL/CLMemoryRegion.cpp
index 835958b..c9ddf9b 100644
--- a/src/runtime/CL/CLMemoryRegion.cpp
+++ b/src/runtime/CL/CLMemoryRegion.cpp
@@ -26,6 +26,8 @@
#include "arm_compute/core/Error.h"
#include "arm_compute/runtime/CL/CLScheduler.h"
+#include "src/common/utils/Log.h"
+
namespace arm_compute
{
ICLMemoryRegion::ICLMemoryRegion(size_t size)
@@ -72,7 +74,14 @@
// Flush the command queue to ensure all commands that may use this memory buffer are scheduled to be finished before
// this buffer is freed
// Do not call finish as it is a blocking call which affects the performance
- CLScheduler::get().queue().flush();
+ try
+ {
+ CLScheduler::get().queue().flush();
+ }
+ catch (const std::exception &e)
+ {
+ ARM_COMPUTE_LOG_ERROR_ACL(e.what());
+ }
}
void *CLBufferMemoryRegion::ptr()