Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
d9754c28
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d9754c28
编写于
10月 15, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update feed
上级
a3e4c8de
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
27 addition
and
11 deletion
+27
-11
src/framework/cl/cl_half.cpp
src/framework/cl/cl_half.cpp
+4
-4
src/framework/cl/cl_half.h
src/framework/cl/cl_half.h
+2
-2
src/framework/cl/cl_image.cpp
src/framework/cl/cl_image.cpp
+2
-2
src/framework/cl/cl_image.h
src/framework/cl/cl_image.h
+1
-2
src/operators/kernel/cl/feed_kernel.cpp
src/operators/kernel/cl/feed_kernel.cpp
+18
-1
未找到文件。
src/framework/cl/cl_half.cpp
浏览文件 @
d9754c28
...
...
@@ -487,13 +487,13 @@ static const uint8_t shifttable[512] = {
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x18
,
0x0d
};
half_t
float2h
alf
(
float
f
)
{
half_t
Float2H
alf
(
float
f
)
{
uint32_t
v
=
*
reinterpret_cast
<
uint32_t
*>
(
&
f
);
return
basetable
[(
v
>>
23
)
&
0x1ff
]
+
((
v
&
0x007fffff
)
>>
shifttable
[(
v
>>
23
)
&
0x1ff
]);
}
float
half2f
loat
(
half_t
h
)
{
float
Half2F
loat
(
half_t
h
)
{
uint32_t
v
=
mantissatable
[
offsettable
[
h
>>
10
]
+
(
h
&
0x3ff
)]
+
exponenttable
[
h
>>
10
];
return
*
reinterpret_cast
<
float
*>
(
&
v
);
...
...
@@ -501,12 +501,12 @@ float half2float(half_t h) {
void
FloatArray2HalfArray
(
float
*
f_array
,
half_t
*
h_array
,
int
count
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
h_array
[
i
]
=
float2h
alf
(
f_array
[
i
]);
h_array
[
i
]
=
Float2H
alf
(
f_array
[
i
]);
}
}
void
HalfArray2FloatArray
(
half_t
*
h_array
,
float
*
f_array
,
int
count
)
{
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
f_array
[
i
]
=
float2half
(
h_array
[
i
]);
f_array
[
i
]
=
Half2Float
(
h_array
[
i
]);
}
}
src/framework/cl/cl_half.h
浏览文件 @
d9754c28
...
...
@@ -17,9 +17,9 @@ limitations under the License. */
typedef
uint16_t
half_t
;
half_t
float2h
alf
(
float
f
);
half_t
Float2H
alf
(
float
f
);
float
half2f
loat
(
half_t
h
);
float
Half2F
loat
(
half_t
h
);
void
FloatArray2HalfArray
(
float
*
f_array
,
half_t
*
h_array
,
int
count
);
...
...
src/framework/cl/cl_image.cpp
浏览文件 @
d9754c28
...
...
@@ -52,7 +52,7 @@ void CLImageToTensor(CLImage *cl_image, Tensor *tensor,
for
(
int
h
=
0
;
h
<
H
;
h
++
)
{
size_t
i2
=
(
i1
<<
2
)
+
c
%
4
;
for
(
int
w
=
0
;
w
<
W
;
w
++
)
{
*
p
=
half2f
loat
(
imageData
[
i2
]);
*
p
=
Half2F
loat
(
imageData
[
i2
]);
i2
+=
4
;
p
++
;
}
...
...
@@ -106,7 +106,7 @@ void TensorToCLImage(const Tensor *tensor, CLImage *cl_image,
for
(
int
h
=
0
;
h
<
H
;
h
++
)
{
size_t
i2
=
(
i1
<<
2
)
+
c
%
4
;
for
(
int
w
=
0
;
w
<
W
;
w
++
)
{
imageData
[
i2
]
=
float2h
alf
(
*
p
);
imageData
[
i2
]
=
Float2H
alf
(
*
p
);
i2
+=
4
;
p
++
;
}
...
...
src/framework/cl/cl_image.h
浏览文件 @
d9754c28
...
...
@@ -179,7 +179,7 @@ class CLImage {
}
assert
(
i2
<
width
*
height
*
4
);
imageData
[
i2
]
=
float2h
alf
(
*
p
);
imageData
[
i2
]
=
Float2H
alf
(
*
p
);
i2
+=
4
;
p
++
;
// count++;
...
...
@@ -206,7 +206,6 @@ class CLImage {
&
err
);
if
(
err
!=
CL_SUCCESS
)
{
// TODO(HaiPeng): error handling
CL_CHECK_ERRORS
(
err
);
PADDLE_MOBILE_THROW_EXCEPTION
(
" create image 2d error "
);
}
...
...
src/operators/kernel/cl/feed_kernel.cpp
浏览文件 @
d9754c28
...
...
@@ -29,23 +29,40 @@ template <>
void
FeedKernel
<
GPU_CL
,
float
>::
Compute
(
const
FeedParam
<
GPU_CL
>
&
param
)
{
auto
kernel
=
this
->
cl_helper_
.
KernelAt
(
0
);
cl_int
status
;
DLOG
<<
" feed 0"
;
auto
output
=
param
.
Out
();
DLOG
<<
" feed 1"
;
const
Tensor
*
input
=
param
.
InputX
();
DLOG
<<
" feed 2"
;
const
float
*
input_data
=
nullptr
;
DLOG
<<
" feed 3"
;
input_data
=
input
->
data
<
float
>
();
DLOG
<<
" feed 4"
;
cl_mem
cl_image
=
output
->
GetCLImage
();
DLOG
<<
" feed 5"
;
int
height
=
output
->
dims
()[
2
];
int
width
=
output
->
dims
()[
3
];
DLOG
<<
output
->
dims
();
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
input_data
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
cl_image
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
width
);
CL_CHECK_ERRORS
(
status
);
status
=
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
height
);
CL_CHECK_ERRORS
(
status
);
size_t
global_work_size
[
2
]
=
{
height
,
width
};
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
NULL
,
status
=
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
NULL
,
global_work_size
,
NULL
,
0
,
NULL
,
NULL
);
CL_CHECK_ERRORS
(
status
);
}
template
class
FeedKernel
<
GPU_CL
,
float
>;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录