Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
a0655313
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
337
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看板
提交
a0655313
编写于
7月 02, 2019
作者:
Z
zp7
提交者:
Jiaying Zhao
7月 02, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add depthwise_cov2d&relu6 gpu op (#1719)
上级
f4aabbdb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
92 addition
and
5 deletion
+92
-5
src/framework/load_ops.h
src/framework/load_ops.h
+2
-2
src/operators/activation_op.cpp
src/operators/activation_op.cpp
+1
-0
src/operators/depthwise_conv_op.cpp
src/operators/depthwise_conv_op.cpp
+3
-1
src/operators/kernel/cl/cl_kernel/relu6.cl
src/operators/kernel/cl/cl_kernel/relu6.cl
+31
-0
src/operators/kernel/cl/relu6_kernel.cpp
src/operators/kernel/cl/relu6_kernel.cpp
+47
-0
test/net/test_net.cpp
test/net/test_net.cpp
+7
-1
test/test_include.h
test/test_include.h
+1
-1
未找到文件。
src/framework/load_ops.h
浏览文件 @
a0655313
...
...
@@ -142,7 +142,7 @@ LOAD_OP2(softmax, CPU, GPU_CL);
LOAD_OP1
(
shape
,
CPU
);
#endif
#ifdef DEPTHWISECONV_OP
LOAD_OP
1
(
depthwise_conv2d
,
CPU
);
LOAD_OP
2
(
depthwise_conv2d
,
CPU
,
GPU_CL
);
#endif
#ifdef CONV_TRANSPOSE_OP
LOAD_OP1
(
conv2d_transpose
,
CPU
);
...
...
@@ -200,7 +200,7 @@ LOAD_OP1(norm, CPU);
#endif
#ifdef RELU_OP
LOAD_OP2
(
relu
,
CPU
,
GPU_CL
);
LOAD_OP
1
(
relu6
,
CPU
);
LOAD_OP
2
(
relu6
,
CPU
,
GPU_CL
);
#endif
#ifdef IM2SEQUENCE_OP
LOAD_OP1
(
im2sequence
,
CPU
);
...
...
src/operators/activation_op.cpp
浏览文件 @
a0655313
...
...
@@ -63,6 +63,7 @@ REGISTER_OPERATOR_FPGA(relu, ops::ReluOp);
#endif
#ifdef PADDLE_MOBILE_CL
REGISTER_OPERATOR_CL
(
relu
,
ops
::
ReluOp
);
REGISTER_OPERATOR_CL
(
relu6
,
ops
::
Relu6Op
);
#endif
#endif // RELU_OP
...
...
src/operators/depthwise_conv_op.cpp
浏览文件 @
a0655313
...
...
@@ -56,5 +56,7 @@ namespace ops = paddle_mobile::operators;
#ifdef PADDLE_MOBILE_CPU
REGISTER_OPERATOR_CPU
(
depthwise_conv2d
,
ops
::
DepthwiseConvOp
);
#endif
#ifdef PADDLE_MOBILE_CL
REGISTER_OPERATOR_CL
(
depthwise_conv2d
,
ops
::
DepthwiseConvOp
);
#endif
#endif
src/operators/kernel/cl/cl_kernel/relu6.cl
0 → 100644
浏览文件 @
a0655313
/*
Copyright
(
c
)
2018
PaddlePaddle
Authors.
All
Rights
Reserved.
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.
*/
#
pragma
OPENCL
EXTENSION
cl_khr_fp16
:
enable
__kernel
void
relu6
(
__read_only
image2d_t
input,
__write_only
image2d_t
output
)
{
const
int
x
=
get_global_id
(
0
)
;
const
int
y
=
get_global_id
(
1
)
;
const
sampler_t
sampler
=
CLK_NORMALIZED_COORDS_TRUE
|
CLK_ADDRESS_CLAMP |
CLK_FILTER_NEAREST
;
half4
in
=
read_imageh
(
input,
sampler,
(
int2
)(
x,
y
))
;
in
=
max
((
half4
)(
0.0f,
0.0f,
0.0f,
0.0f
)
,
in
)
;
in
=
min
((
half4
)(
6.0f,
6.0f,
6.0f,
6.0f
)
,
in
)
;
write_imageh
(
output,
(
int2
)(
x,
y
)
,
in
)
;
}
src/operators/kernel/cl/relu6_kernel.cpp
0 → 100644
浏览文件 @
a0655313
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
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. */
#ifdef RELU_OP
#include "operators/kernel/activation_kernel.h"
namespace
paddle_mobile
{
namespace
operators
{
template
<
>
bool
Relu6Kernel
<
GPU_CL
,
float
>::
Init
(
ReluParam
<
GPU_CL
>*
param
)
{
this
->
cl_helper_
.
AddKernel
(
"relu6"
,
"relu6.cl"
);
return
true
;
}
template
<
>
void
Relu6Kernel
<
GPU_CL
,
float
>::
Compute
(
const
ReluParam
<
GPU_CL
>&
param
)
{
auto
kernel
=
this
->
cl_helper_
.
KernelAt
(
0
);
const
auto
*
input
=
param
.
InputX
();
auto
*
output
=
param
.
Out
();
auto
default_work_size
=
this
->
cl_helper_
.
DefaultWorkSize
(
*
output
);
auto
inputImage
=
input
->
GetCLImage
();
auto
outputImage
=
output
->
GetCLImage
();
clSetKernelArg
(
kernel
,
0
,
sizeof
(
cl_mem
),
&
inputImage
);
clSetKernelArg
(
kernel
,
1
,
sizeof
(
cl_mem
),
&
outputImage
);
const
size_t
work_size
[
2
]
=
{
input
->
ImageWidth
(),
input
->
ImageHeight
()};
clEnqueueNDRangeKernel
(
this
->
cl_helper_
.
CLCommandQueue
(),
kernel
,
2
,
NULL
,
work_size
,
NULL
,
0
,
NULL
,
NULL
);
}
template
class
Relu6Kernel
<
GPU_CL
,
float
>;
}
// namespace operators
}
// namespace paddle_mobile
#endif
test/net/test_net.cpp
浏览文件 @
a0655313
...
...
@@ -12,9 +12,9 @@ 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 <fstream>
#include <iostream>
#include <string>
#include <fstream>
#include "../test_helper.h"
#include "../test_include.h"
...
...
@@ -44,8 +44,14 @@ void test(int argc, char *argv[]) {
// out_file.write(out_data, len);
// out_file.close();
#ifdef PADDLE_MOBILE_CL
// config.load_when_predict = true;
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
GPU_CL
>
paddle_mobile
(
config
);
paddle_mobile
.
SetCLPath
(
"/data/local/tmp/bin"
);
#else
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
>
paddle_mobile
(
config
);
paddle_mobile
.
SetThreadNum
(
1
);
#endif
int
dim_count
=
std
::
stoi
(
argv
[
arg_index
]);
arg_index
++
;
...
...
test/test_include.h
浏览文件 @
a0655313
...
...
@@ -20,8 +20,8 @@ limitations under the License. */
#include "./test_helper.h"
#include "common/enforce.h"
#include "common/util.h"
#include "common/log.h"
#include "common/util.h"
#include "executor_for_test.h"
#include "framework/ddim.h"
#include "framework/lod_tensor.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录