From 2cd5bc65bb38dcf223af0a0d2ef74468a56006ab Mon Sep 17 00:00:00 2001 From: liuduanhui <103939338+DanieeelLiu@users.noreply.github.com> Date: Mon, 5 Aug 2024 16:42:19 +0800 Subject: [PATCH] [Feature](mlu-ops): remove error throw in mluops library. (#1038) --- core/util.cpp | 3 +++ kernels/utils/cnnl_helper.cpp | 1 - tools/pre-commit | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/util.cpp b/core/util.cpp index 610057cbf..e465b451e 100644 --- a/core/util.cpp +++ b/core/util.cpp @@ -32,6 +32,9 @@ void mluOpCheck(mluOpStatus_t result, char const *const func, std::string error = "\"" + std::string(mluOpGetErrorString(result)) + " in " + std::string(func) + "\""; LOG(ERROR) << error; + // TODO(liuduanhui): Remove error throwing in c library in future. + // MLUOP_CHECK should not be used in host side code. + // And now it is only used in gtest code. throw std::runtime_error(error); } } diff --git a/kernels/utils/cnnl_helper.cpp b/kernels/utils/cnnl_helper.cpp index 3bfce9d89..f814c1823 100644 --- a/kernels/utils/cnnl_helper.cpp +++ b/kernels/utils/cnnl_helper.cpp @@ -30,7 +30,6 @@ void mluOpCnnlCheck(mluOpStatus_t result, char const *const func, " in " + std::string(func) + " at " + std::string(file) + " line: " + std::to_string(line) + "\""; LOG(ERROR) << error; - throw std::runtime_error(error); } } diff --git a/tools/pre-commit b/tools/pre-commit index 8bd5a863e..f6dc15d78 100755 --- a/tools/pre-commit +++ b/tools/pre-commit @@ -68,8 +68,8 @@ for i in ${filenames} ; do check_dir=$(echo $i | grep -E "^core\/|^kernels\/") #not_in_tools=$(echo $i | sed -r "s/^tools.*//") if [[ -n "${include_mlu}" ]] && [[ -n "${check_dir}" ]]; then - printf_log=$(sed -n -e '/\/=' -e ' \ - /\<__bang_printf\>/=' -e '/\/=' -e '/assert(/=' $i) + printf_log=$(sed -n -e '/\/=' -e \ + '/\<__bang_printf\>/=' -e '/\/=' -e '/assert(/=' $i) for line in ${printf_log}; do echo $i +${line}