From c15430143e65bc45cc8d31c04c7d0a6420b78cdd Mon Sep 17 00:00:00 2001 From: Tristan Konolige Date: Thu, 4 Mar 2021 16:54:28 -0800 Subject: [PATCH] [FIX] Fix clang12 warnings --- src/relay/backend/contrib/tensorrt/codegen.cc | 3 +++ src/runtime/contrib/cublas/cublas.cc | 4 ++-- src/runtime/contrib/cublas/cublas_utils.cc | 2 +- src/runtime/contrib/json/json_runtime.h | 6 +++--- src/runtime/micro/micro_session.cc | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/relay/backend/contrib/tensorrt/codegen.cc b/src/relay/backend/contrib/tensorrt/codegen.cc index cb648333df8d..059dbc192a04 100644 --- a/src/relay/backend/contrib/tensorrt/codegen.cc +++ b/src/relay/backend/contrib/tensorrt/codegen.cc @@ -156,6 +156,9 @@ class TensorRTJSONSerializer : public backend::contrib::JSONSerializer { // with slice_mode = "size", attrs->end_value mean the size of the slice int end_value = attrs->end.value()[i].as()->value; size_value = (end_value == -1) ? ishape[i] - begin_value : end_value; + } else { + LOG(FATAL) << "Unexpected slice_mode " << attrs->slice_mode << ", expected end or size"; + throw; } ICHECK_GT(size_value, 0); size.push_back(std::to_string(size_value)); diff --git a/src/runtime/contrib/cublas/cublas.cc b/src/runtime/contrib/cublas/cublas.cc index ce69d4ca7bde..b12992f57159 100644 --- a/src/runtime/contrib/cublas/cublas.cc +++ b/src/runtime/contrib/cublas/cublas.cc @@ -167,7 +167,7 @@ inline void CallLtIgemm(TVMArgs args, TVMRetValue* ret, cublasLtHandle_t hdl) { ICHECK(CheckMixPrecisionType(A->dtype, C->dtype)) << "Unsupported data type"; int32_t alpha = args.size() > 5 ? args[5] : 1; int32_t beta = args.size() > 6 ? args[6] : 0; - cublasLtMatrixLayout_t Adesc = NULL, Bdesc = NULL, Cdesc = NULL; + cublasLtMatrixLayout_t Adesc = nullptr, Bdesc = nullptr, Cdesc = nullptr; auto A_data = reinterpret_cast(static_cast(A->data) + A->byte_offset); auto B_data = reinterpret_cast(static_cast(B->data) + B->byte_offset); auto C_data = reinterpret_cast(static_cast(C->data) + C->byte_offset); @@ -204,7 +204,7 @@ inline void CallLtIgemm(TVMArgs args, TVMRetValue* ret, cublasLtHandle_t hdl) { &order_COL32, sizeof(order_COL32))); CHECK_CUBLAS_ERROR(cublasLtMatmul(hdl, operationDesc, &alpha, B_data, Adesc, A_data, Bdesc, &beta, - C_data, Cdesc, C_data, Cdesc, NULL, NULL, 0, 0)); + C_data, Cdesc, C_data, Cdesc, nullptr, nullptr, 0, nullptr)); } #endif diff --git a/src/runtime/contrib/cublas/cublas_utils.cc b/src/runtime/contrib/cublas/cublas_utils.cc index d4ec08770723..4b4a1b755e66 100644 --- a/src/runtime/contrib/cublas/cublas_utils.cc +++ b/src/runtime/contrib/cublas/cublas_utils.cc @@ -35,7 +35,7 @@ CuBlasThreadEntry::CuBlasThreadEntry() { CHECK_CUBLAS_ERROR(cublasCreate(&handle CuBlasThreadEntry::~CuBlasThreadEntry() { if (handle) { cublasDestroy(handle); - handle = 0; + handle = nullptr; } } diff --git a/src/runtime/contrib/json/json_runtime.h b/src/runtime/contrib/json/json_runtime.h index 3ae652ccaf24..55f16635b9e6 100644 --- a/src/runtime/contrib/json/json_runtime.h +++ b/src/runtime/contrib/json/json_runtime.h @@ -55,7 +55,7 @@ class JSONRuntimeBase : public ModuleNode { LoadGraph(graph_json_); } - const char* type_key() const { return "json"; } + const char* type_key() const override { return "json"; } /*! \brief Initialize a specific json runtime. */ virtual void Init(const Array& consts) = 0; @@ -69,7 +69,7 @@ class JSONRuntimeBase : public ModuleNode { * \param sptr_to_self The pointer to the module node. * \return The packed function. */ - virtual PackedFunc GetFunction(const std::string& name, const ObjectPtr& sptr_to_self) { + PackedFunc GetFunction(const std::string& name, const ObjectPtr& sptr_to_self) override { if (name == "get_symbol") { return PackedFunc( [sptr_to_self, this](TVMArgs args, TVMRetValue* rv) { *rv = this->symbol_name_; }); @@ -98,7 +98,7 @@ class JSONRuntimeBase : public ModuleNode { } } - virtual void SaveToBinary(dmlc::Stream* stream) { + void SaveToBinary(dmlc::Stream* stream) override { // Save the symbol stream->Write(symbol_name_); // Save the graph diff --git a/src/runtime/micro/micro_session.cc b/src/runtime/micro/micro_session.cc index f26a717dae33..6c0d0c4c40fe 100644 --- a/src/runtime/micro/micro_session.cc +++ b/src/runtime/micro/micro_session.cc @@ -172,7 +172,7 @@ class MicroTransportChannel : public RPCChannel { // confusion. unsigned int seed = random_seed.load(); if (seed == 0) { - seed = (unsigned int)time(NULL); + seed = (unsigned int)time(nullptr); } uint8_t initial_nonce = 0; for (int i = 0; i < kNumRandRetries && initial_nonce == 0; ++i) {