Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
7e659a0a
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7e659a0a
编写于
12月 24, 2017
作者:
Q
Qiao Longfei
提交者:
GitHub
12月 24, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6932 from dzhwinter/fix/kernelkey
"remove hash combine"
上级
37e96264
a521ace6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
23 deletion
+13
-23
paddle/framework/op_kernel_type.h
paddle/framework/op_kernel_type.h
+11
-21
paddle/platform/device_context.h
paddle/platform/device_context.h
+2
-2
未找到文件。
paddle/framework/op_kernel_type.h
浏览文件 @
7e659a0a
...
@@ -22,33 +22,23 @@ limitations under the License. */
...
@@ -22,33 +22,23 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
/*
Refer to https://stackoverflow.com/questions/35985960/
c-why-is-boosthash-combine-the-best-way-to-combine-hash-values
*/
template
<
class
T
>
inline
void
HashCombine
(
const
T
&
v
,
std
::
size_t
*
seed
)
{
std
::
hash
<
T
>
hasher
;
*
seed
^=
hasher
(
v
)
+
0x9e3779b9
+
(
*
seed
<<
6
)
+
(
*
seed
>>
2
);
}
struct
OpKernelType
{
struct
OpKernelType
{
struct
Hash
{
struct
Hash
{
size_t
operator
()(
const
OpKernelType
&
key
)
const
{
size_t
operator
()(
const
OpKernelType
&
key
)
const
{
int
place
=
key
.
place_
.
which
();
int
place
=
key
.
place_
.
which
()
+
(
1
<<
LEFT_SHIFT
);
int
data_type
=
static_cast
<
int
>
(
key
.
data_type_
);
int
data_type
=
int
data_layout
=
static_cast
<
int
>
(
key
.
data_layout_
);
static_cast
<
int
>
(
key
.
data_type_
)
+
(
1
<<
(
LEFT_SHIFT
+
1
));
int
library_type
=
static_cast
<
int
>
(
key
.
library_type_
);
int
data_layout
=
static_cast
<
int
>
(
key
.
data_layout_
)
+
(
1
<<
(
LEFT_SHIFT
+
2
));
size_t
seed
=
0
;
int
library_type
=
HashCombine
(
place
,
&
seed
);
static_cast
<
int
>
(
key
.
library_type_
)
+
(
1
<<
(
LEFT_SHIFT
+
3
));
HashCombine
(
data_type
,
&
seed
);
std
::
hash
<
int
>
hasher
;
HashCombine
(
data_layout
,
&
seed
);
return
hasher
(
place
+
data_type
+
data_layout
+
library_type
);
HashCombine
(
library_type
,
&
seed
);
return
seed
;
}
}
};
};
// place, data_type, library_type kinds less than 2^8
constexpr
static
int
LEFT_SHIFT
=
8
;
proto
::
DataType
data_type_
;
proto
::
DataType
data_type_
;
DataLayout
data_layout_
;
DataLayout
data_layout_
;
platform
::
Place
place_
;
platform
::
Place
place_
;
...
...
paddle/platform/device_context.h
浏览文件 @
7e659a0a
...
@@ -137,11 +137,11 @@ class DeviceContextPool {
...
@@ -137,11 +137,11 @@ class DeviceContextPool {
private:
private:
static
DeviceContextPool
*
pool
;
static
DeviceContextPool
*
pool
;
constexpr
static
int
LEFT_SHIFT
=
8
;
struct
Hash
{
struct
Hash
{
std
::
hash
<
int
>
hash_
;
std
::
hash
<
int
>
hash_
;
size_t
operator
()(
const
platform
::
Place
&
place
)
const
{
size_t
operator
()(
const
platform
::
Place
&
place
)
const
{
int
pre_hash
=
place
.
which
()
int
pre_hash
=
place
.
which
()
+
(
1
<<
LEFT_SHIFT
);
<<
(
sizeof
(
int
)
*
8
-
NUM_PLACE_TYPE_LIMIT_IN_BIT
);
if
(
platform
::
is_gpu_place
(
place
))
{
if
(
platform
::
is_gpu_place
(
place
))
{
pre_hash
+=
boost
::
get
<
platform
::
GPUPlace
>
(
place
).
GetDeviceId
();
pre_hash
+=
boost
::
get
<
platform
::
GPUPlace
>
(
place
).
GetDeviceId
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录