diff --git a/include/tvm/ir/attrs.h b/include/tvm/ir/attrs.h index 1d02bf708ee3..1fc28c817cd4 100644 --- a/include/tvm/ir/attrs.h +++ b/include/tvm/ir/attrs.h @@ -222,6 +222,8 @@ class BaseAttrsNode : public Object { public: using TVMArgs = runtime::TVMArgs; using TVMRetValue = runtime::TVMRetValue; + /*! \brief virtual destructor */ + virtual ~BaseAttrsNode() {} // visit function virtual void VisitAttrs(AttrVisitor* v) {} /*! diff --git a/include/tvm/ir/op.h b/include/tvm/ir/op.h index e281c199fd47..8a6ab77427fb 100644 --- a/include/tvm/ir/op.h +++ b/include/tvm/ir/op.h @@ -192,7 +192,7 @@ class Op : public RelayExpr { * \param key The attribute key * \return bool True if the key is present */ - TVM_DLL static const bool HasGenericAttr(const std::string& key); + TVM_DLL static bool HasGenericAttr(const std::string& key); }; /*! diff --git a/include/tvm/ir/type_relation.h b/include/tvm/ir/type_relation.h index 962eea31dca7..6d4e75a23f6b 100644 --- a/include/tvm/ir/type_relation.h +++ b/include/tvm/ir/type_relation.h @@ -76,6 +76,8 @@ class TypeCall : public Type { */ class TypeReporterNode : public Object { public: + /*! \brief virtual destructor */ + virtual ~TypeReporterNode() {} /*! * \brief Create a type equality constraint. * diff --git a/include/tvm/node/container.h b/include/tvm/node/container.h index f5c71980d9b4..a541385bb575 100644 --- a/include/tvm/node/container.h +++ b/include/tvm/node/container.h @@ -150,14 +150,14 @@ class Array : public ObjectRef { * \brief move constructor * \param other source */ - Array(Array && other) { // NOLINT(*) + Array(Array && other) : ObjectRef() { // NOLINT(*) data_ = std::move(other.data_); } /*! * \brief copy constructor * \param other source */ - Array(const Array &other) { // NOLINT(*) + Array(const Array &other) : ObjectRef() { // NOLINT(*) data_ = std::move(other.data_); } /*! diff --git a/include/tvm/relay/expr.h b/include/tvm/relay/expr.h index 72523dd08dd3..64f2278c3103 100644 --- a/include/tvm/relay/expr.h +++ b/include/tvm/relay/expr.h @@ -526,6 +526,8 @@ class RefWrite : public Expr { */ class TempExprNode : public ExprNode { public: + /*! \brief virtual destructor */ + virtual ~TempExprNode() {} /*! * \brief Convert the expression to a normal(non-temp) Expr. * \return The corresponding normal(non-temp) expression. diff --git a/include/tvm/runtime/object.h b/include/tvm/runtime/object.h index ba84b5f10119..fe5e30bba2e8 100644 --- a/include/tvm/runtime/object.h +++ b/include/tvm/runtime/object.h @@ -649,13 +649,13 @@ struct ObjectEqual { */ #define TVM_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType) \ static_assert(!ParentType::_type_final, "ParentObj maked as final"); \ - static const uint32_t RuntimeTypeIndex() { \ + static uint32_t RuntimeTypeIndex() { \ if (TypeName::_type_index != ::tvm::runtime::TypeIndex::kDynamic) { \ return TypeName::_type_index; \ } \ return _GetOrAllocRuntimeTypeIndex(); \ } \ - static const uint32_t _GetOrAllocRuntimeTypeIndex() { \ + static uint32_t _GetOrAllocRuntimeTypeIndex() { \ static uint32_t tidx = Object::GetOrAllocRuntimeTypeIndex( \ TypeName::_type_key, \ TypeName::_type_index, \ diff --git a/include/tvm/tir/expr.h b/include/tvm/tir/expr.h index 93b04db7562a..756907bfef47 100644 --- a/include/tvm/tir/expr.h +++ b/include/tvm/tir/expr.h @@ -731,6 +731,8 @@ class LetNode : public PrimExprNode { /*! \brief Base node of internal functions. */ class FunctionBaseNode : public Object { public: + /*! \brief virtual destructor */ + virtual ~FunctionBaseNode() {} /*! \return the name of the function */ virtual const std::string& func_name() const = 0; /*! \return the number of outputs of this function */ diff --git a/src/ir/attr_functor.h b/src/ir/attr_functor.h index 49431407a6ee..babd08a83c6e 100644 --- a/src/ir/attr_functor.h +++ b/src/ir/attr_functor.h @@ -60,6 +60,8 @@ class AttrFunctor { public: /*! \brief the result type of this functor */ using result_type = R; + /*! \brief virtual destructor */ + virtual ~AttrFunctor() {} /*! * \brief The functor call. * \param n The expression node. diff --git a/src/ir/op.cc b/src/ir/op.cc index 558b69891ae6..b25fe999443a 100644 --- a/src/ir/op.cc +++ b/src/ir/op.cc @@ -87,7 +87,7 @@ const GenericOpMap& Op::GetGenericAttr(const std::string& key) { } // Check if a key is present in the registry. -const bool Op::HasGenericAttr(const std::string& key) { +bool Op::HasGenericAttr(const std::string& key) { OpManager* mgr = OpManager::Global(); std::lock_guard lock(mgr->mutex); auto it = mgr->attr.find(key); diff --git a/src/relay/backend/compile_engine.h b/src/relay/backend/compile_engine.h index 42142f1377a7..15ec2d6bd0f1 100644 --- a/src/relay/backend/compile_engine.h +++ b/src/relay/backend/compile_engine.h @@ -171,6 +171,8 @@ class CCacheValue : public ObjectRef { */ class CompileEngineNode : public Object { public: + /*! \brief destructor */ + virtual ~CompileEngineNode() {} /*! * \brief Get lowered result. * \param key The key to the cached function. diff --git a/src/relay/backend/contrib/codegen_c/codegen_c.h b/src/relay/backend/contrib/codegen_c/codegen_c.h index 23e07d55dac9..f473c93a2896 100644 --- a/src/relay/backend/contrib/codegen_c/codegen_c.h +++ b/src/relay/backend/contrib/codegen_c/codegen_c.h @@ -38,6 +38,7 @@ namespace contrib { class CSourceModuleCodegenBase { public: CSourceModuleCodegenBase() = default; + virtual ~CSourceModuleCodegenBase() = default; /*! * \brief Create a runtime module for the external library. For example, it @@ -69,6 +70,9 @@ class CSourceModuleCodegenBase { // The base class to generate the declaration functions in C. class CodegenCBase { + public: + virtual ~CodegenCBase() {} + protected: /*! \brief Print indents using spaces. */ void PrintIndents() { diff --git a/src/relay/pass/combine_parallel_op.h b/src/relay/pass/combine_parallel_op.h index 619a153595b7..24f3884f4b11 100644 --- a/src/relay/pass/combine_parallel_op.h +++ b/src/relay/pass/combine_parallel_op.h @@ -126,6 +126,8 @@ class BranchGroupFinder : private ExprVisitor { */ class ParallelOpCombiner { public: + /*! \brief virtual destructor */ + virtual ~ParallelOpCombiner() {} /* * \brief Constructor. * \param op_name name of op to combine diff --git a/src/relay/pass/partial_eval.cc b/src/relay/pass/partial_eval.cc index 37ce34817787..c5857c26b7a9 100644 --- a/src/relay/pass/partial_eval.cc +++ b/src/relay/pass/partial_eval.cc @@ -275,6 +275,7 @@ class Fuel : public ObjectRef { class FuelNode : public RelayNode { public: + virtual ~FuelNode() {} // Please implement one of the following function or there will be infinite loop. /*! \brief return the new Fuel, and whether progress is made. * diff --git a/src/relay/pass/transform_layout.h b/src/relay/pass/transform_layout.h index f7845242d21b..f18f5d26f248 100644 --- a/src/relay/pass/transform_layout.h +++ b/src/relay/pass/transform_layout.h @@ -70,6 +70,8 @@ class TransformMemorizer : public ObjectRef { TransformMemorizer() {} explicit TransformMemorizer(ObjectPtr n) : ObjectRef(n) {} + virtual ~TransformMemorizer() {} + TransformMemorizerNode* operator->() { return static_cast(get_mutable()); } diff --git a/src/relay/qnn/util.h b/src/relay/qnn/util.h index 6362421f051b..0bab94796299 100644 --- a/src/relay/qnn/util.h +++ b/src/relay/qnn/util.h @@ -45,7 +45,7 @@ static inline Array get_shape(const Type& type) { return input_tt->shape; } -static inline const int32_t GetQmin(const DataType& dtype) { +static inline int32_t GetQmin(const DataType& dtype) { CHECK_LE(dtype.bits(), 32) << "QNN ops support int32 or lower precision"; if (dtype.is_int() || dtype.is_uint()) { @@ -58,7 +58,7 @@ static inline const int32_t GetQmin(const DataType& dtype) { } } -static inline const int32_t GetQmax(const DataType& dtype) { +static inline int32_t GetQmax(const DataType& dtype) { CHECK_LE(dtype.bits(), 32) << "QNN ops support int32 or lower precision"; if (dtype.is_int() || dtype.is_uint()) { diff --git a/src/runtime/library_module.h b/src/runtime/library_module.h index 8e84a4b48bd3..61e62661f149 100644 --- a/src/runtime/library_module.h +++ b/src/runtime/library_module.h @@ -40,6 +40,8 @@ namespace runtime { */ class Library : public Object { public: + // destructor. + virtual ~Library() {} /*! * \brief Get the symbol address for a given name. * \param name The name of the symbol. diff --git a/src/target/source/codegen_cuda.cc b/src/target/source/codegen_cuda.cc index 5a3130f31995..0b2c54e592ce 100644 --- a/src/target/source/codegen_cuda.cc +++ b/src/target/source/codegen_cuda.cc @@ -190,6 +190,7 @@ void CodeGenCUDA::PrintType(DataType t, std::ostream& os) { // NOLINT(*) } else { // No longlong3, longlong4 LOG(FATAL) << "Cannot convert type " << t << " to CUDA type on a L32 platform"; + break; } } else { os << "long"; break; diff --git a/vta/src/runtime.cc b/vta/src/runtime.cc index aa42a4c1c0c4..6b08c6c2ebcd 100644 --- a/vta/src/runtime.cc +++ b/vta/src/runtime.cc @@ -314,7 +314,7 @@ class UopKernel { template class BaseQueue { public: - ~BaseQueue() { + virtual ~BaseQueue() { if (fpga_buff_ != nullptr) { VTAMemFree(fpga_buff_); }