Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
e8b9ae20
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e8b9ae20
编写于
9月 25, 2022
作者:
S
sneaxiy
提交者:
GitHub
9月 25, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move some singleton to cc file (#46470)
上级
991ec7d3
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
42 addition
and
24 deletion
+42
-24
paddle/fluid/framework/op_version_registry.cc
paddle/fluid/framework/op_version_registry.cc
+10
-0
paddle/fluid/framework/op_version_registry.h
paddle/fluid/framework/op_version_registry.h
+4
-8
paddle/fluid/platform/device_context.cc
paddle/fluid/platform/device_context.cc
+24
-1
paddle/fluid/platform/device_context.h
paddle/fluid/platform/device_context.h
+4
-15
未找到文件。
paddle/fluid/framework/op_version_registry.cc
浏览文件 @
e8b9ae20
...
...
@@ -70,6 +70,11 @@ OpVersionDesc&& OpVersionDesc::DeleteOutput(const std::string& name,
return
std
::
move
(
*
this
);
}
OpVersionRegistrar
&
OpVersionRegistrar
::
GetInstance
()
{
static
OpVersionRegistrar
instance
;
return
instance
;
}
OpVersion
&
OpVersionRegistrar
::
Register
(
const
std
::
string
&
op_type
)
{
PADDLE_ENFORCE_EQ
(
op_version_map_
.
find
(
op_type
),
...
...
@@ -89,6 +94,11 @@ uint32_t OpVersionRegistrar::version_id(const std::string& op_type) const {
return
op_version_map_
.
find
(
op_type
)
->
second
.
version_id
();
}
PassVersionCheckerRegistrar
&
PassVersionCheckerRegistrar
::
GetInstance
()
{
static
PassVersionCheckerRegistrar
instance
;
return
instance
;
}
// Provide a fake registration item for pybind testing.
#include "paddle/fluid/framework/op_version_registry.inl"
...
...
paddle/fluid/framework/op_version_registry.h
浏览文件 @
e8b9ae20
...
...
@@ -230,10 +230,8 @@ class OpVersion {
class
OpVersionRegistrar
{
public:
static
OpVersionRegistrar
&
GetInstance
()
{
static
OpVersionRegistrar
instance
;
return
instance
;
}
static
OpVersionRegistrar
&
GetInstance
();
OpVersion
&
Register
(
const
std
::
string
&
op_type
);
const
std
::
unordered_map
<
std
::
string
,
OpVersion
>&
GetVersionMap
()
{
return
op_version_map_
;
...
...
@@ -365,10 +363,8 @@ class PassVersionCheckers {
class
PassVersionCheckerRegistrar
{
public:
static
PassVersionCheckerRegistrar
&
GetInstance
()
{
static
PassVersionCheckerRegistrar
instance
;
return
instance
;
}
static
PassVersionCheckerRegistrar
&
GetInstance
();
PassVersionCheckers
&
Register
(
const
std
::
string
&
pass_name
)
{
PADDLE_ENFORCE_EQ
(
pass_version_checkers_map_
.
find
(
pass_name
),
pass_version_checkers_map_
.
end
(),
...
...
paddle/fluid/platform/device_context.cc
浏览文件 @
e8b9ae20
...
...
@@ -73,7 +73,30 @@ DeviceType Place2DeviceType(const platform::Place& place) {
}
}
DeviceContextPool
*
DeviceContextPool
::
pool
=
nullptr
;
static
DeviceContextPool
*
pool
=
nullptr
;
DeviceContextPool
&
DeviceContextPool
::
Instance
()
{
PADDLE_ENFORCE_NOT_NULL
(
pool
,
phi
::
errors
::
PreconditionNotMet
(
"Need to Create DeviceContextPool firstly!"
));
return
*
pool
;
}
/*! \brief Create should only called by Init function */
DeviceContextPool
&
DeviceContextPool
::
Init
(
const
std
::
vector
<
platform
::
Place
>&
places
)
{
if
(
pool
==
nullptr
)
{
pool
=
new
DeviceContextPool
(
places
);
}
return
*
pool
;
}
bool
DeviceContextPool
::
IsInitialized
()
{
return
pool
!=
nullptr
;
}
void
DeviceContextPool
::
SetPool
(
DeviceContextPool
*
dev_pool
)
{
pool
=
dev_pool
;
}
thread_local
const
std
::
map
<
Place
,
std
::
shared_future
<
std
::
unique_ptr
<
DeviceContext
>>>*
DeviceContextPool
::
external_device_contexts_
=
nullptr
;
...
...
paddle/fluid/platform/device_context.h
浏览文件 @
e8b9ae20
...
...
@@ -339,24 +339,14 @@ void EmplaceDeviceContexts(
/*! \brief device context pool singleton */
class
DeviceContextPool
{
public:
static
DeviceContextPool
&
Instance
()
{
PADDLE_ENFORCE_NOT_NULL
(
pool
,
platform
::
errors
::
PreconditionNotMet
(
"Need to Create DeviceContextPool firstly!"
));
return
*
pool
;
}
static
DeviceContextPool
&
Instance
();
/*! \brief Create should only called by Init function */
static
DeviceContextPool
&
Init
(
const
std
::
vector
<
platform
::
Place
>&
places
)
{
if
(
pool
==
nullptr
)
{
pool
=
new
DeviceContextPool
(
places
);
}
return
*
pool
;
}
static
DeviceContextPool
&
Init
(
const
std
::
vector
<
platform
::
Place
>&
places
);
static
bool
IsInitialized
()
{
return
pool
!=
nullptr
;
}
static
bool
IsInitialized
()
;
static
void
SetPool
(
DeviceContextPool
*
dev_pool
)
{
pool
=
dev_pool
;
}
static
void
SetPool
(
DeviceContextPool
*
dev_pool
)
;
/*! \brief Return handle of single device context. */
platform
::
DeviceContext
*
Get
(
const
platform
::
Place
&
place
);
...
...
@@ -380,7 +370,6 @@ class DeviceContextPool {
private:
explicit
DeviceContextPool
(
const
std
::
vector
<
platform
::
Place
>&
places
);
static
DeviceContextPool
*
pool
;
std
::
map
<
Place
,
std
::
shared_future
<
std
::
unique_ptr
<
DeviceContext
>>>
device_contexts_
;
static
thread_local
const
std
::
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录