Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
e6c68a2d
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看板
提交
e6c68a2d
编写于
2月 14, 2018
作者:
K
Kavya Srinet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed data_type.h
上级
e18bc024
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
27 deletion
+27
-27
paddle/fluid/framework/data_type.h
paddle/fluid/framework/data_type.h
+27
-27
未找到文件。
paddle/fluid/framework/data_type.h
浏览文件 @
e6c68a2d
...
@@ -20,35 +20,35 @@ limitations under the License. */
...
@@ -20,35 +20,35 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
namespace
framework
{
namespace
framework
{
inline
proto
::
Data
Type
ToDataType
(
std
::
type_index
type
)
{
inline
proto
::
VarType
::
Type
ToDataType
(
std
::
type_index
type
)
{
using
namespace
paddle
::
framework
::
proto
;
using
namespace
paddle
::
framework
::
proto
;
if
(
typeid
(
float
).
hash_code
()
==
type
.
hash_code
())
{
if
(
typeid
(
float
).
hash_code
()
==
type
.
hash_code
())
{
return
Data
Type
::
FP32
;
return
VarType
::
Type
::
FP32
;
}
else
if
(
typeid
(
double
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
double
).
hash_code
()
==
type
.
hash_code
())
{
return
Data
Type
::
FP64
;
return
VarType
::
Type
::
FP64
;
}
else
if
(
typeid
(
int
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
int
).
hash_code
()
==
type
.
hash_code
())
{
return
Data
Type
::
INT32
;
return
VarType
::
Type
::
INT32
;
}
else
if
(
typeid
(
int64_t
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
int64_t
).
hash_code
()
==
type
.
hash_code
())
{
return
Data
Type
::
INT64
;
return
VarType
::
Type
::
INT64
;
}
else
if
(
typeid
(
bool
).
hash_code
()
==
type
.
hash_code
())
{
}
else
if
(
typeid
(
bool
).
hash_code
()
==
type
.
hash_code
())
{
return
Data
Type
::
BOOL
;
return
VarType
::
Type
::
BOOL
;
}
else
{
}
else
{
PADDLE_THROW
(
"Not supported"
);
PADDLE_THROW
(
"Not supported"
);
}
}
}
}
inline
std
::
type_index
ToTypeIndex
(
proto
::
Data
Type
type
)
{
inline
std
::
type_index
ToTypeIndex
(
proto
::
VarType
::
Type
type
)
{
using
namespace
paddle
::
framework
::
proto
;
using
namespace
paddle
::
framework
::
proto
;
switch
(
type
)
{
switch
(
type
)
{
case
Data
Type
::
FP32
:
case
VarType
::
Type
::
FP32
:
return
typeid
(
float
);
return
typeid
(
float
);
case
Data
Type
::
FP64
:
case
VarType
::
Type
::
FP64
:
return
typeid
(
double
);
return
typeid
(
double
);
case
Data
Type
::
INT32
:
case
VarType
::
Type
::
INT32
:
return
typeid
(
int
);
return
typeid
(
int
);
case
Data
Type
::
INT64
:
case
VarType
::
Type
::
INT64
:
return
typeid
(
int64_t
);
return
typeid
(
int64_t
);
case
Data
Type
::
BOOL
:
case
VarType
::
Type
::
BOOL
:
return
typeid
(
bool
);
return
typeid
(
bool
);
default:
default:
PADDLE_THROW
(
"Not support type %d"
,
type
);
PADDLE_THROW
(
"Not support type %d"
,
type
);
...
@@ -56,22 +56,22 @@ inline std::type_index ToTypeIndex(proto::DataType type) {
...
@@ -56,22 +56,22 @@ inline std::type_index ToTypeIndex(proto::DataType type) {
}
}
template
<
typename
Visitor
>
template
<
typename
Visitor
>
inline
void
VisitDataType
(
proto
::
Data
Type
type
,
Visitor
visitor
)
{
inline
void
VisitDataType
(
proto
::
VarType
::
Type
type
,
Visitor
visitor
)
{
using
namespace
paddle
::
framework
::
proto
;
using
namespace
paddle
::
framework
::
proto
;
switch
(
type
)
{
switch
(
type
)
{
case
Data
Type
::
FP32
:
case
VarType
::
Type
::
FP32
:
visitor
.
template
operator
()
<
float
>();
visitor
.
template
operator
()
<
float
>();
break
;
break
;
case
Data
Type
::
FP64
:
case
VarType
::
Type
::
FP64
:
visitor
.
template
operator
()
<
double
>();
visitor
.
template
operator
()
<
double
>();
break
;
break
;
case
Data
Type
::
INT32
:
case
VarType
::
Type
::
INT32
:
visitor
.
template
operator
()
<
int
>();
visitor
.
template
operator
()
<
int
>();
break
;
break
;
case
Data
Type
::
INT64
:
case
VarType
::
Type
::
INT64
:
visitor
.
template
operator
()
<
int64_t
>();
visitor
.
template
operator
()
<
int64_t
>();
break
;
break
;
case
Data
Type
::
BOOL
:
case
VarType
::
Type
::
BOOL
:
visitor
.
template
operator
()
<
bool
>();
visitor
.
template
operator
()
<
bool
>();
break
;
break
;
default:
default:
...
@@ -79,22 +79,22 @@ inline void VisitDataType(proto::DataType type, Visitor visitor) {
...
@@ -79,22 +79,22 @@ inline void VisitDataType(proto::DataType type, Visitor visitor) {
}
}
}
}
inline
std
::
string
DataTypeToString
(
const
proto
::
Data
Type
type
)
{
inline
std
::
string
DataTypeToString
(
const
proto
::
VarType
::
Type
type
)
{
using
namespace
paddle
::
framework
::
proto
;
using
namespace
paddle
::
framework
::
proto
;
switch
(
type
)
{
switch
(
type
)
{
case
Data
Type
::
FP16
:
case
VarType
::
Type
::
FP16
:
return
"float16"
;
return
"float16"
;
case
Data
Type
::
FP32
:
case
VarType
::
Type
::
FP32
:
return
"float32"
;
return
"float32"
;
case
Data
Type
::
FP64
:
case
VarType
::
Type
::
FP64
:
return
"float64"
;
return
"float64"
;
case
Data
Type
::
INT16
:
case
VarType
::
Type
::
INT16
:
return
"int16"
;
return
"int16"
;
case
Data
Type
::
INT32
:
case
VarType
::
Type
::
INT32
:
return
"int32"
;
return
"int32"
;
case
Data
Type
::
INT64
:
case
VarType
::
Type
::
INT64
:
return
"int64"
;
return
"int64"
;
case
Data
Type
::
BOOL
:
case
VarType
::
Type
::
BOOL
:
return
"bool"
;
return
"bool"
;
default:
default:
PADDLE_THROW
(
"Not support type %d"
,
type
);
PADDLE_THROW
(
"Not support type %d"
,
type
);
...
@@ -102,7 +102,7 @@ inline std::string DataTypeToString(const proto::DataType type) {
...
@@ -102,7 +102,7 @@ inline std::string DataTypeToString(const proto::DataType type) {
}
}
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
proto
::
Data
Type
&
type
)
{
const
proto
::
VarType
::
Type
&
type
)
{
out
<<
DataTypeToString
(
type
);
out
<<
DataTypeToString
(
type
);
return
out
;
return
out
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录