diff --git a/lite/core/context.h b/lite/core/context.h index f8013ac5008e2478719b3d777a36d2bfac57ec6d..f3a6857b84478908dc8d205ec98f882c751b53a7 100644 --- a/lite/core/context.h +++ b/lite/core/context.h @@ -395,7 +395,7 @@ class KernelContext { class ContextScheduler { public: static ContextScheduler& Global() { - static auto* x = new ContextScheduler; + static auto x = std::unique_ptr(new ContextScheduler); return *x; } diff --git a/lite/core/device_info.h b/lite/core/device_info.h index f5b75039ea14f67cee9d009261b2dd1fc6b46825..01f2c0991261e58eb6cff7d6fb5eebdcd00c463e 100644 --- a/lite/core/device_info.h +++ b/lite/core/device_info.h @@ -15,6 +15,7 @@ #pragma once #include +#include #include #include #include "lite/core/tensor.h" @@ -43,7 +44,7 @@ typedef enum { class DeviceInfo { public: static DeviceInfo& Global() { - static auto* x = new DeviceInfo; + static auto x = std::unique_ptr(new DeviceInfo); return *x; } @@ -156,7 +157,7 @@ class Env { typedef TargetWrapper API; typedef std::vector> Devs; static Devs& Global() { - static Devs* devs = new Devs(); + static auto devs = std::unique_ptr(new Devs); return *devs; } static void Init(int max_stream = 6) { diff --git a/lite/core/op_registry.cc b/lite/core/op_registry.cc index 29c853c70caa80add9d47182da228a36f031cb42..4fc1b8623ac30ce368af6a2634fa29eb13e5e54e 100644 --- a/lite/core/op_registry.cc +++ b/lite/core/op_registry.cc @@ -14,6 +14,7 @@ #include "lite/core/op_registry.h" #include +#include #include namespace paddle { @@ -248,7 +249,7 @@ KernelRegistry::KernelRegistry() } KernelRegistry &KernelRegistry::Global() { - static auto *x = new KernelRegistry; + static auto x = std::unique_ptr(new KernelRegistry); return *x; } diff --git a/lite/utils/factory.h b/lite/utils/factory.h index fea8561bcf783d96753968fa20c270934fef270b..72e1c04459962ec84c7a49307cb04521856a2e2f 100644 --- a/lite/utils/factory.h +++ b/lite/utils/factory.h @@ -48,7 +48,7 @@ class Factory { using creator_t = std::function; static Factory& Global() { - static Factory* x = new self_t; + static auto x = std::unique_ptr(new self_t); return *x; }