Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
313afc9c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
313afc9c
编写于
12月 25, 2017
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add op_kernel_type_test
上级
7e659a0a
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
101 addition
and
9 deletion
+101
-9
paddle/framework/CMakeLists.txt
paddle/framework/CMakeLists.txt
+2
-0
paddle/framework/data_layout.h
paddle/framework/data_layout.h
+21
-0
paddle/framework/library_type.h
paddle/framework/library_type.h
+18
-0
paddle/framework/op_kernel_type.h
paddle/framework/op_kernel_type.h
+9
-0
paddle/framework/op_kernel_type_test.cc
paddle/framework/op_kernel_type_test.cc
+51
-0
paddle/framework/operator.cc
paddle/framework/operator.cc
+0
-7
paddle/framework/operator.h
paddle/framework/operator.h
+0
-2
未找到文件。
paddle/framework/CMakeLists.txt
浏览文件 @
313afc9c
...
...
@@ -61,3 +61,5 @@ cc_test(selected_rows_test SRCS selected_rows_test.cc DEPS selected_rows)
cc_library
(
init SRCS init.cc DEPS gflags device_context place stringpiece
)
cc_test
(
init_test SRCS init_test.cc DEPS init
)
cc_test
(
op_kernel_type_test SRCS op_kernel_type_test.cc DEPS place device_context
)
paddle/framework/data_layout.h
浏览文件 @
313afc9c
...
...
@@ -14,6 +14,9 @@ limitations under the License. */
#pragma once
#include <iostream>
#include "paddle/platform/enforce.h"
namespace
paddle
{
namespace
framework
{
...
...
@@ -33,5 +36,23 @@ inline DataLayout StringToDataLayout(const std::string& str) {
}
}
inline
std
::
string
DataLayoutToString
(
const
DataLayout
&
data_layout
)
{
switch
(
data_layout
)
{
case
kNHWC
:
return
"NHWC"
;
case
kNCHW
:
return
"NCHW"
;
case
kAnyLayout
:
return
"ANY_LAYOUT"
;
default:
PADDLE_THROW
(
"unknown DataLayou %d"
,
data_layout
);
}
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
DataLayout
l
)
{
out
<<
DataLayoutToString
(
l
);
return
out
;
}
}
// namespace framework
}
// namespace paddle
paddle/framework/library_type.h
浏览文件 @
313afc9c
...
...
@@ -22,5 +22,23 @@ namespace framework {
enum
LibraryType
{
kPlain
=
0
,
kMKLDNN
=
1
,
kCUDNN
=
2
};
inline
std
::
string
LibraryTypeToString
(
const
LibraryType
&
library_type
)
{
switch
(
library_type
)
{
case
kPlain
:
return
"PLAIN"
;
case
kMKLDNN
:
return
"MKLDNN"
;
case
kCUDNN
:
return
"CUDNN"
;
default:
PADDLE_THROW
(
"unknown LibraryType %d"
,
library_type
);
}
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
LibraryType
l
)
{
out
<<
LibraryTypeToString
(
l
);
return
out
;
}
}
// namespace
}
// framework
paddle/framework/op_kernel_type.h
浏览文件 @
313afc9c
...
...
@@ -17,6 +17,7 @@ limitations under the License. */
#include "paddle/framework/data_layout.h"
#include "paddle/framework/data_type.h"
#include "paddle/framework/library_type.h"
#include "paddle/platform/device_context.h"
#include "paddle/platform/place.h"
namespace
paddle
{
...
...
@@ -68,5 +69,13 @@ struct OpKernelType {
}
};
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
OpKernelType
&
kernel_key
)
{
os
<<
"data_type["
<<
kernel_key
.
data_type_
<<
"]:data_layout["
<<
kernel_key
.
data_layout_
<<
"]:place["
<<
kernel_key
.
place_
<<
"]:library_type["
<<
kernel_key
.
library_type_
<<
"]"
;
return
os
;
}
}
// namespace framework
}
// namespace paddle
paddle/framework/op_kernel_type_test.cc
0 → 100644
浏览文件 @
313afc9c
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/framework/op_kernel_type.h"
#include <gtest/gtest.h>
#include <iostream>
TEST
(
OpKernelType
,
ToString
)
{
using
OpKernelType
=
paddle
::
framework
::
OpKernelType
;
using
DataType
=
paddle
::
framework
::
proto
::
DataType
;
using
CPUPlace
=
paddle
::
platform
::
CPUPlace
;
using
DataLayout
=
paddle
::
framework
::
DataLayout
;
using
LibraryType
=
paddle
::
framework
::
LibraryType
;
OpKernelType
op_kernel_type
(
DataType
::
FP32
,
CPUPlace
(),
DataLayout
::
kNCHW
,
LibraryType
::
kCUDNN
);
std
::
ostringstream
stream
;
stream
<<
op_kernel_type
;
ASSERT_EQ
(
stream
.
str
(),
"data_type[5]:data_layout[NCHW]:place[CPUPlace]:library_type[CUDNN]"
);
}
TEST
(
OpKernelType
,
Hash
)
{
using
OpKernelType
=
paddle
::
framework
::
OpKernelType
;
using
DataType
=
paddle
::
framework
::
proto
::
DataType
;
using
CPUPlace
=
paddle
::
platform
::
CPUPlace
;
using
GPUPlace
=
paddle
::
platform
::
GPUPlace
;
using
DataLayout
=
paddle
::
framework
::
DataLayout
;
using
LibraryType
=
paddle
::
framework
::
LibraryType
;
OpKernelType
op_kernel_type_1
(
DataType
::
FP32
,
CPUPlace
(),
DataLayout
::
kNCHW
,
LibraryType
::
kCUDNN
);
OpKernelType
op_kernel_type_2
(
DataType
::
FP32
,
GPUPlace
(
0
),
DataLayout
::
kNCHW
,
LibraryType
::
kCUDNN
);
OpKernelType
::
Hash
hasher
;
ASSERT_NE
(
hasher
(
op_kernel_type_1
),
hasher
(
op_kernel_type_2
));
}
\ No newline at end of file
paddle/framework/operator.cc
浏览文件 @
313afc9c
...
...
@@ -242,13 +242,6 @@ std::vector<Tensor*> ExecutionContext::MultiOutput<Tensor>(
return
res
;
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
OpKernelType
&
kernel_key
)
{
os
<<
"data_type["
<<
kernel_key
.
data_type_
<<
"]:data_layout["
<<
kernel_key
.
data_layout_
<<
"]:place["
<<
kernel_key
.
place_
<<
"]:library_type["
<<
kernel_key
.
library_type_
<<
"]"
;
return
os
;
}
bool
OpSupportGPU
(
const
std
::
string
&
op_type
)
{
auto
&
all_kernels
=
OperatorWithKernel
::
AllOpKernels
();
auto
it
=
all_kernels
.
find
(
op_type
);
...
...
paddle/framework/operator.h
浏览文件 @
313afc9c
...
...
@@ -381,8 +381,6 @@ class OperatorWithKernel : public OperatorBase {
proto
::
DataType
IndicateDataType
(
const
ExecutionContext
&
ctx
)
const
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
OpKernelType
&
kernel_key
);
extern
bool
OpSupportGPU
(
const
std
::
string
&
op_type
);
}
// namespace framework
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录