Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
fd2b4b47
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看板
提交
fd2b4b47
编写于
5月 16, 2018
作者:
Y
yuyang18
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make tensor support uint8
上级
9707aa6b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
25 addition
and
6 deletion
+25
-6
paddle/fluid/framework/data_type.cc
paddle/fluid/framework/data_type.cc
+1
-0
paddle/fluid/framework/data_type.h
paddle/fluid/framework/data_type.h
+7
-1
paddle/fluid/framework/framework.proto
paddle/fluid/framework/framework.proto
+1
-0
paddle/fluid/framework/lod_tensor_test.cc
paddle/fluid/framework/lod_tensor_test.cc
+13
-4
paddle/fluid/operators/math/math_function.cc
paddle/fluid/operators/math/math_function.cc
+3
-1
未找到文件。
paddle/fluid/framework/data_type.cc
浏览文件 @
fd2b4b47
...
...
@@ -58,6 +58,7 @@ static DataTypeMap* InitDataTypeMap() {
RegType
(
bool
,
proto
::
VarType
::
BOOL
);
RegType
(
size_t
,
proto
::
VarType
::
SIZE_T
);
RegType
(
int16_t
,
proto
::
VarType
::
INT16
);
RegType
(
uint8_t
,
proto
::
VarType
::
UINT8
);
#undef RegType
return
retv
;
...
...
paddle/fluid/framework/data_type.h
浏览文件 @
fd2b4b47
...
...
@@ -47,8 +47,14 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) {
case
proto
::
VarType
::
BOOL
:
visitor
.
template
operator
()
<
bool
>();
break
;
case
proto
::
VarType
::
UINT8
:
visitor
.
template
operator
()
<
uint8_t
>();
break
;
case
proto
::
VarType
::
INT16
:
visitor
.
template
operator
()
<
int16_t
>();
break
;
default:
PADDLE_THROW
(
"Not supported
"
);
PADDLE_THROW
(
"Not supported
%d"
,
type
);
}
}
...
...
paddle/fluid/framework/framework.proto
浏览文件 @
fd2b4b47
...
...
@@ -103,6 +103,7 @@ message VarType {
FP64
=
6
;
// Tensor<size_t> is used in C++.
SIZE_T
=
19
;
UINT8
=
20
;
// Other types that may need additional descriptions
LOD_TENSOR
=
7
;
...
...
paddle/fluid/framework/lod_tensor_test.cc
浏览文件 @
fd2b4b47
...
...
@@ -228,11 +228,12 @@ TEST(LoD, CheckAbsLoD) {
ASSERT_FALSE
(
CheckAbsLoD
(
abs_lod0
));
}
TEST
(
LoDTensor
,
RecordIO
)
{
template
<
typename
T
>
static
void
TestRecordIO
()
{
LoDTensor
tensor
;
int
*
tmp
=
tensor
.
mutable_data
<
int
>
(
make_ddim
({
4
,
5
}),
platform
::
CPUPlace
());
T
*
tmp
=
tensor
.
mutable_data
<
T
>
(
make_ddim
({
4
,
5
}),
platform
::
CPUPlace
());
for
(
int
i
=
0
;
i
<
20
;
++
i
)
{
tmp
[
i
]
=
i
;
tmp
[
i
]
=
static_cast
<
T
>
(
i
)
;
}
std
::
stringstream
*
stream
=
new
std
::
stringstream
();
...
...
@@ -247,7 +248,7 @@ TEST(LoDTensor, RecordIO) {
auto
assert_tensor_ok
=
[](
const
LoDTensor
&
tensor
)
{
for
(
int
i
=
0
;
i
<
20
;
++
i
)
{
ASSERT_EQ
(
tensor
.
data
<
int
>
()[
i
],
i
);
ASSERT_EQ
(
tensor
.
data
<
T
>
()[
i
],
static_cast
<
T
>
(
i
)
);
}
};
...
...
@@ -265,5 +266,13 @@ TEST(LoDTensor, RecordIO) {
}
}
TEST
(
LoDTensor
,
RecordIO
)
{
TestRecordIO
<
int
>
();
TestRecordIO
<
int16_t
>
();
TestRecordIO
<
uint8_t
>
();
TestRecordIO
<
float
>
();
TestRecordIO
<
double
>
();
}
}
// namespace framework
}
// namespace paddle
paddle/fluid/operators/math/math_function.cc
浏览文件 @
fd2b4b47
...
...
@@ -38,7 +38,9 @@ template struct SetConstant<platform::CPUDeviceContext, bool>;
template struct Transpose<platform::CPUDeviceContext, double, RANK>; \
template struct Transpose<platform::CPUDeviceContext, int, RANK>; \
template struct Transpose<platform::CPUDeviceContext, int64_t, RANK>; \
template struct Transpose<platform::CPUDeviceContext, bool, RANK>;
template struct Transpose<platform::CPUDeviceContext, bool, RANK>; \
template struct Transpose<platform::CPUDeviceContext, int16_t, RANK>; \
template struct Transpose<platform::CPUDeviceContext, uint8_t, RANK>;
DEFINE_CPU_TRANS
(
1
);
DEFINE_CPU_TRANS
(
2
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录