Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
6006a87c
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
6006a87c
编写于
9月 10, 2019
作者:
L
lijianshe02
提交者:
GitHub
9月 10, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add x86 softmax kernel and fix jit compute bugs test=develop (#2007)
上级
192320c4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
23 addition
and
18 deletion
+23
-18
lite/backends/x86/jit/more/CMakeLists.txt
lite/backends/x86/jit/more/CMakeLists.txt
+3
-3
lite/backends/x86/math/softmax_impl.h
lite/backends/x86/math/softmax_impl.h
+1
-0
lite/kernels/x86/CMakeLists.txt
lite/kernels/x86/CMakeLists.txt
+2
-0
lite/kernels/x86/softmax_compute.h
lite/kernels/x86/softmax_compute.h
+4
-12
lite/kernels/x86/softmax_compute_test.cc
lite/kernels/x86/softmax_compute_test.cc
+13
-3
未找到文件。
lite/backends/x86/jit/more/CMakeLists.txt
浏览文件 @
6006a87c
...
...
@@ -4,9 +4,9 @@ function(USE_JITKERNEL_MORE TARGET TYPE)
endfunction
()
# enable it latter
#
if(WITH_MKLML)
#
add_subdirectory(mkl)
#
endif()
if
(
WITH_MKLML
)
add_subdirectory
(
mkl
)
endif
()
if
(
WITH_AVX
)
add_subdirectory
(
intrinsic
)
...
...
lite/backends/x86/math/softmax_impl.h
浏览文件 @
6006a87c
...
...
@@ -17,6 +17,7 @@ limitations under the License. */
#include "lite/backends/x86/cpu_info.h"
#include "lite/backends/x86/jit/helper.h"
#include "lite/backends/x86/jit/kernel_base.h"
#include "lite/backends/x86/jit/kernels.h"
#include "lite/backends/x86/math/cpu_vec.h"
#include "lite/core/tensor.h"
#include "lite/fluid/eigen.h"
...
...
lite/kernels/x86/CMakeLists.txt
浏览文件 @
6006a87c
...
...
@@ -33,8 +33,10 @@ add_kernel(mul_compute_x86 X86 basic SRCS mul_compute.cc DEPS ${lite_kernel_deps
add_kernel
(
concat_compute_x86 X86 basic SRCS concat_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
shape_compute_x86 X86 basic SRCS shape_compute.cc DEPS
${
lite_kernel_deps
}
)
add_kernel
(
sequence_pool_compute_x86 X86 basic SRCS sequence_pool_compute.cc DEPS
${
lite_kernel_deps
}
sequence_pooling
)
add_kernel
(
softmax_compute_x86 X86 basic SRCS softmax_compute.cc DEPS
${
lite_kernel_deps
}
softmax
)
lite_cc_test
(
test_mul_compute_x86 SRCS mul_compute_test.cc DEPS mul_compute_x86
)
lite_cc_test
(
test_concat_compute_x86 SRCS concat_compute_test.cc DEPS concat_compute_x86
)
lite_cc_test
(
test_sequence_pool_compute_x86 SRCS sequence_pool_compute_test.cc DEPS sequence_pool_compute_x86
)
lite_cc_test
(
test_shape_compute_x86 SRCS shape_compute_test.cc DEPS shape_compute_x86
)
lite_cc_test
(
test_softmax_compute_x86 SRCS softmax_compute_test.cc DEPS softmax_compute_x86
)
lite/kernels/x86/softmax_compute.h
浏览文件 @
6006a87c
...
...
@@ -14,12 +14,9 @@
#pragma once
#include <vector>
#include "lite/backends/x86/math/softmax.h"
#include "lite/core/kernel.h"
#include "lite/core/op_registry.h"
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/lod_tensor.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/operators/math/softmax.h"
namespace
paddle
{
namespace
lite
{
namespace
kernels
{
...
...
@@ -55,7 +52,7 @@ class SoftmaxCompute : public KernelLite<TARGET(kX86), PRECISION(kFloat)> {
void
Run
()
override
{
auto
&
param
=
*
param_
.
get_mutable
<
operators
::
SoftmaxParam
>
();
// auto& context = context
_->As<X86Context>();
auto
&
context
=
ctx
_
->
As
<
X86Context
>
();
CHECK
(
param
.
output
);
CHECK
(
param
.
x
);
param
.
output
->
mutable_data
<
T
>
();
...
...
@@ -72,13 +69,8 @@ class SoftmaxCompute : public KernelLite<TARGET(kX86), PRECISION(kFloat)> {
out_2d
.
ShareDataWith
(
*
param
.
output
);
out_2d
.
Resize
(
lite
::
DDim
(
shape
));
paddle
::
operators
::
math
::
SoftmaxFunctor
<
platform
::
CPUDeviceContext
,
T
,
true
>
()(
platform
::
CPUDeviceContext
(),
axis_dim
,
&
input_2d
.
raw_tensor
(),
&
out_2d
.
raw_tensor
());
lite
::
x86
::
math
::
SoftmaxFunctor
<
lite
::
TargetType
::
kX86
,
T
,
true
>
()(
context
,
axis_dim
,
&
input_2d
,
&
out_2d
);
}
virtual
~
SoftmaxCompute
()
=
default
;
...
...
lite/kernels/x86/softmax_compute_test.cc
浏览文件 @
6006a87c
...
...
@@ -14,7 +14,8 @@
#include "lite/kernels/x86/softmax_compute.h"
#include <gtest/gtest.h>
#include <iostream>
#include <memory>
#include <utility>
#include <vector>
#include "lite/core/op_registry.h"
...
...
@@ -54,15 +55,24 @@ TEST(softmax_x86, run_test) {
SoftmaxCompute
<
float
>
softmax
;
operators
::
SoftmaxParam
param
;
std
::
unique_ptr
<
KernelContext
>
ctx
(
new
KernelContext
);
ctx
->
As
<
X86Context
>
();
softmax
.
SetContext
(
std
::
move
(
ctx
));
param
.
x
=
&
x
;
param
.
output
=
&
out
;
softmax
.
SetParam
(
param
);
softmax
.
Run
();
LOG
(
INFO
)
<<
"output: "
;
std
::
vector
<
float
>
ref_results
=
{
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
,
0.0900306
,
0.244728
,
0.665241
};
for
(
int
i
=
0
;
i
<
out
.
dims
().
production
();
i
++
)
{
LOG
(
INFO
)
<<
out_data
[
i
]
;
EXPECT_NEAR
(
out_data
[
i
],
ref_results
[
i
],
1e-3
)
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录