Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
a3c67b2f
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看板
提交
a3c67b2f
编写于
1月 02, 2020
作者:
石
石晓伟
提交者:
GitHub
1月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Jit macro definition ambiguity fix, test=develop (#2713)
上级
ff13e3af
变更
21
显示空白变更内容
内联
并排
Showing
21 changed file
with
178 addition
and
178 deletion
+178
-178
lite/backends/x86/jit/README.en.md
lite/backends/x86/jit/README.en.md
+1
-1
lite/backends/x86/jit/README.md
lite/backends/x86/jit/README.md
+1
-1
lite/backends/x86/jit/gen/CMakeLists.txt
lite/backends/x86/jit/gen/CMakeLists.txt
+27
-27
lite/backends/x86/jit/gen/act.cc
lite/backends/x86/jit/gen/act.cc
+6
-6
lite/backends/x86/jit/gen/blas.cc
lite/backends/x86/jit/gen/blas.cc
+7
-7
lite/backends/x86/jit/gen/embseqpool.cc
lite/backends/x86/jit/gen/embseqpool.cc
+1
-1
lite/backends/x86/jit/gen/gru.cc
lite/backends/x86/jit/gen/gru.cc
+3
-3
lite/backends/x86/jit/gen/hopv.cc
lite/backends/x86/jit/gen/hopv.cc
+2
-2
lite/backends/x86/jit/gen/lstm.cc
lite/backends/x86/jit/gen/lstm.cc
+2
-2
lite/backends/x86/jit/gen/matmul.cc
lite/backends/x86/jit/gen/matmul.cc
+1
-1
lite/backends/x86/jit/gen/seqpool.cc
lite/backends/x86/jit/gen/seqpool.cc
+1
-1
lite/backends/x86/jit/gen/sgd.cc
lite/backends/x86/jit/gen/sgd.cc
+1
-1
lite/backends/x86/jit/gen/vbroadcast.cc
lite/backends/x86/jit/gen/vbroadcast.cc
+1
-1
lite/backends/x86/jit/more/CMakeLists.txt
lite/backends/x86/jit/more/CMakeLists.txt
+2
-2
lite/backends/x86/jit/more/intrinsic/CMakeLists.txt
lite/backends/x86/jit/more/intrinsic/CMakeLists.txt
+2
-2
lite/backends/x86/jit/more/mix/CMakeLists.txt
lite/backends/x86/jit/more/mix/CMakeLists.txt
+8
-8
lite/backends/x86/jit/more/mkl/CMakeLists.txt
lite/backends/x86/jit/more/mkl/CMakeLists.txt
+15
-15
lite/backends/x86/jit/refer/CMakeLists.txt
lite/backends/x86/jit/refer/CMakeLists.txt
+33
-33
lite/backends/x86/jit/refer/refer.cc
lite/backends/x86/jit/refer/refer.cc
+1
-1
lite/backends/x86/jit/registry.h
lite/backends/x86/jit/registry.h
+61
-61
lite/kernels/npu/bridges/registry.h
lite/kernels/npu/bridges/registry.h
+2
-2
未找到文件。
lite/backends/x86/jit/README.en.md
浏览文件 @
a3c67b2f
...
...
@@ -89,7 +89,7 @@ All kernels are inlcuded in `lite/backends/x86/jit/kernels.h`, which is automati
3.
Add reference function of
`your_key`
.
Note:
-
this should be run on CPU and do not depend on any third-party.
-
Add
`USE_JITKERNEL_REFER(your_key)`
in
`refer/CmakeLists.txt`
to make sure this code can be used.
-
Add
`USE_JITKERNEL_REFER
_LITE
(your_key)`
in
`refer/CmakeLists.txt`
to make sure this code can be used.
4.
Add unit test in
`test.cc`
, and verfiy at least
`float`
and
`double`
.
Test more data type for some special functions if necessary, for example
`int8`
.
5.
Add functions in
`benchmark.cc`
to test all function of same
`KernelType`
. Make sure
`GetDefaultBestFunc`
always get the best one.
...
...
lite/backends/x86/jit/README.md
浏览文件 @
a3c67b2f
...
...
@@ -79,7 +79,7 @@ PaddlePaddle/Paddle/paddle/fluid/
# 如何添加新的算子
1.
在
`KernelType`
中添加
`your_key`
。
2.
实现Reference 的逻辑,这个是必须是在CPU上的实现,并且不能依赖任何第三方库。实现后在
`refer/CmakeLists.txt`
中添加
`USE_JITKERNEL_REFER(your_key)`
来使用该kernel。
2.
实现Reference 的逻辑,这个是必须是在CPU上的实现,并且不能依赖任何第三方库。实现后在
`refer/CmakeLists.txt`
中添加
`USE_JITKERNEL_REFER
_LITE
(your_key)`
来使用该kernel。
3.
(optional) 实现更多的算法在
`more`
目录下,可以依赖mkl,intrinsic或者mkldnn等第三方库。
4.
(optional) 实现基于Xbyak的生成code,在
`gen`
目下。 jitcode需要实现自己的
`JitCodeCreator`
,并注册在与refer相同的
`KernelType`
上。
5.
添加新的
`KernelTuple`
,需要与
`KernelType`
一一对应,是所有类型的一个打包,包括数据类型,属性的类型,以及返回的函数类型。可以参考
`SeqPoolTuple`
,新加的Attr类型需要特例化
`JitCodeKey`
方法。
...
...
lite/backends/x86/jit/gen/CMakeLists.txt
浏览文件 @
a3c67b2f
...
...
@@ -4,33 +4,33 @@ file(GLOB jitcode_cc_srcs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.cc")
cc_library
(
jit_kernel_jitcode SRCS
${
jitcode_cc_srcs
}
DEPS jit_kernel_base xbyak
)
set
(
JIT_KERNEL_DEPS
${
JIT_KERNEL_DEPS
}
xbyak jit_kernel_jitcode PARENT_SCOPE
)
function
(
USE_JITKERNEL_GEN TARGET
)
file
(
APPEND
${
jit_file
}
"USE_JITKERNEL_GEN(
${
TARGET
}
);
\n
"
)
function
(
USE_JITKERNEL_GEN
_LITE
TARGET
)
file
(
APPEND
${
jit_file
}
"USE_JITKERNEL_GEN
_LITE
(
${
TARGET
}
);
\n
"
)
endfunction
()
# use gen jitcode kernel by name
USE_JITKERNEL_GEN
(
kMatMul
)
USE_JITKERNEL_GEN
(
kVMul
)
USE_JITKERNEL_GEN
(
kVAdd
)
USE_JITKERNEL_GEN
(
kVSub
)
USE_JITKERNEL_GEN
(
kVAddRelu
)
USE_JITKERNEL_GEN
(
kVScal
)
USE_JITKERNEL_GEN
(
kVAddBias
)
USE_JITKERNEL_GEN
(
kVRelu
)
USE_JITKERNEL_GEN
(
kVSquare
)
USE_JITKERNEL_GEN
(
kVIdentity
)
USE_JITKERNEL_GEN
(
kVExp
)
USE_JITKERNEL_GEN
(
kVSigmoid
)
USE_JITKERNEL_GEN
(
kVTanh
)
USE_JITKERNEL_GEN
(
kLSTMCtHt
)
USE_JITKERNEL_GEN
(
kLSTMC1H1
)
USE_JITKERNEL_GEN
(
kGRUH1
)
USE_JITKERNEL_GEN
(
kGRUHtPart1
)
USE_JITKERNEL_GEN
(
kGRUHtPart2
)
USE_JITKERNEL_GEN
(
kNCHW16CMulNC
)
USE_JITKERNEL_GEN
(
kSeqPool
)
USE_JITKERNEL_GEN
(
kHMax
)
USE_JITKERNEL_GEN
(
kHSum
)
USE_JITKERNEL_GEN
(
kEmbSeqPool
)
USE_JITKERNEL_GEN
(
kSgd
)
USE_JITKERNEL_GEN
(
kVBroadcast
)
USE_JITKERNEL_GEN
_LITE
(
kMatMul
)
USE_JITKERNEL_GEN
_LITE
(
kVMul
)
USE_JITKERNEL_GEN
_LITE
(
kVAdd
)
USE_JITKERNEL_GEN
_LITE
(
kVSub
)
USE_JITKERNEL_GEN
_LITE
(
kVAddRelu
)
USE_JITKERNEL_GEN
_LITE
(
kVScal
)
USE_JITKERNEL_GEN
_LITE
(
kVAddBias
)
USE_JITKERNEL_GEN
_LITE
(
kVRelu
)
USE_JITKERNEL_GEN
_LITE
(
kVSquare
)
USE_JITKERNEL_GEN
_LITE
(
kVIdentity
)
USE_JITKERNEL_GEN
_LITE
(
kVExp
)
USE_JITKERNEL_GEN
_LITE
(
kVSigmoid
)
USE_JITKERNEL_GEN
_LITE
(
kVTanh
)
USE_JITKERNEL_GEN
_LITE
(
kLSTMCtHt
)
USE_JITKERNEL_GEN
_LITE
(
kLSTMC1H1
)
USE_JITKERNEL_GEN
_LITE
(
kGRUH1
)
USE_JITKERNEL_GEN
_LITE
(
kGRUHtPart1
)
USE_JITKERNEL_GEN
_LITE
(
kGRUHtPart2
)
USE_JITKERNEL_GEN
_LITE
(
kNCHW16CMulNC
)
USE_JITKERNEL_GEN
_LITE
(
kSeqPool
)
USE_JITKERNEL_GEN
_LITE
(
kHMax
)
USE_JITKERNEL_GEN
_LITE
(
kHSum
)
USE_JITKERNEL_GEN
_LITE
(
kEmbSeqPool
)
USE_JITKERNEL_GEN
_LITE
(
kSgd
)
USE_JITKERNEL_GEN
_LITE
(
kVBroadcast
)
lite/backends/x86/jit/gen/act.cc
浏览文件 @
a3c67b2f
...
...
@@ -156,9 +156,9 @@ size_t VTanhCreator::CodeSize(const int& d) const {
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kVRelu
,
gen
::
VReluCreator
);
REGISTER_JITKERNEL_GEN
(
kVSquare
,
gen
::
VSquareCreator
);
REGISTER_JITKERNEL_GEN
(
kVIdentity
,
gen
::
VIdentityCreator
);
REGISTER_JITKERNEL_GEN
(
kVExp
,
gen
::
VExpCreator
);
REGISTER_JITKERNEL_GEN
(
kVSigmoid
,
gen
::
VSigmoidCreator
);
REGISTER_JITKERNEL_GEN
(
kVTanh
,
gen
::
VTanhCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVRelu
,
gen
::
VReluCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVSquare
,
gen
::
VSquareCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVIdentity
,
gen
::
VIdentityCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVExp
,
gen
::
VExpCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVSigmoid
,
gen
::
VSigmoidCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVTanh
,
gen
::
VTanhCreator
);
lite/backends/x86/jit/gen/blas.cc
浏览文件 @
a3c67b2f
...
...
@@ -181,10 +181,10 @@ DECLARE_BLAS_CREATOR(VAddBias);
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kVMul
,
gen
::
VMulCreator
);
REGISTER_JITKERNEL_GEN
(
kVAdd
,
gen
::
VAddCreator
);
REGISTER_JITKERNEL_GEN
(
kVSub
,
gen
::
VSubCreator
);
REGISTER_JITKERNEL_GEN
(
kVAddRelu
,
gen
::
VAddReluCreator
);
REGISTER_JITKERNEL_GEN
(
kVScal
,
gen
::
VScalCreator
);
REGISTER_JITKERNEL_GEN
(
kVAddBias
,
gen
::
VAddBiasCreator
);
REGISTER_JITKERNEL_GEN
(
kNCHW16CMulNC
,
gen
::
NCHW16CMulNCCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVMul
,
gen
::
VMulCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVAdd
,
gen
::
VAddCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVSub
,
gen
::
VSubCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVAddRelu
,
gen
::
VAddReluCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVScal
,
gen
::
VScalCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVAddBias
,
gen
::
VAddBiasCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kNCHW16CMulNC
,
gen
::
NCHW16CMulNCCreator
);
lite/backends/x86/jit/gen/embseqpool.cc
浏览文件 @
a3c67b2f
...
...
@@ -145,4 +145,4 @@ class EmbSeqPoolCreator : public JitCodeCreator<emb_seq_pool_attr_t> {
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kEmbSeqPool
,
gen
::
EmbSeqPoolCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kEmbSeqPool
,
gen
::
EmbSeqPoolCreator
);
lite/backends/x86/jit/gen/gru.cc
浏览文件 @
a3c67b2f
...
...
@@ -111,6 +111,6 @@ DECLARE_GRU_CREATOR(GRUHtPart2);
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kGRUH1
,
gen
::
GRUH1Creator
);
REGISTER_JITKERNEL_GEN
(
kGRUHtPart1
,
gen
::
GRUHtPart1Creator
);
REGISTER_JITKERNEL_GEN
(
kGRUHtPart2
,
gen
::
GRUHtPart2Creator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kGRUH1
,
gen
::
GRUH1Creator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kGRUHtPart1
,
gen
::
GRUHtPart1Creator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kGRUHtPart2
,
gen
::
GRUHtPart2Creator
);
lite/backends/x86/jit/gen/hopv.cc
浏览文件 @
a3c67b2f
...
...
@@ -99,5 +99,5 @@ DECLARE_HOP_CREATOR(HSum);
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kHMax
,
gen
::
HMaxCreator
);
REGISTER_JITKERNEL_GEN
(
kHSum
,
gen
::
HSumCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kHMax
,
gen
::
HMaxCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kHSum
,
gen
::
HSumCreator
);
lite/backends/x86/jit/gen/lstm.cc
浏览文件 @
a3c67b2f
...
...
@@ -138,5 +138,5 @@ DECLARE_LSTM_CREATOR(LSTMC1H1);
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kLSTMCtHt
,
gen
::
LSTMCtHtCreator
);
REGISTER_JITKERNEL_GEN
(
kLSTMC1H1
,
gen
::
LSTMC1H1Creator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kLSTMCtHt
,
gen
::
LSTMCtHtCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kLSTMC1H1
,
gen
::
LSTMC1H1Creator
);
lite/backends/x86/jit/gen/matmul.cc
浏览文件 @
a3c67b2f
...
...
@@ -130,4 +130,4 @@ class MatMulCreator : public JitCodeCreator<matmul_attr_t> {
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kMatMul
,
gen
::
MatMulCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kMatMul
,
gen
::
MatMulCreator
);
lite/backends/x86/jit/gen/seqpool.cc
浏览文件 @
a3c67b2f
...
...
@@ -82,4 +82,4 @@ class SeqPoolCreator : public JitCodeCreator<seq_pool_attr_t> {
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kSeqPool
,
gen
::
SeqPoolCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kSeqPool
,
gen
::
SeqPoolCreator
);
lite/backends/x86/jit/gen/sgd.cc
浏览文件 @
a3c67b2f
...
...
@@ -127,4 +127,4 @@ class SgdCreator : public JitCodeCreator<sgd_attr_t> {
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kSgd
,
gen
::
SgdCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kSgd
,
gen
::
SgdCreator
);
lite/backends/x86/jit/gen/vbroadcast.cc
浏览文件 @
a3c67b2f
...
...
@@ -88,4 +88,4 @@ class VBroadcastCreator : public JitCodeCreator<int64_t> {
namespace
gen
=
paddle
::
lite
::
jit
::
gen
;
REGISTER_JITKERNEL_GEN
(
kVBroadcast
,
gen
::
VBroadcastCreator
);
REGISTER_JITKERNEL_GEN
_LITE
(
kVBroadcast
,
gen
::
VBroadcastCreator
);
lite/backends/x86/jit/more/CMakeLists.txt
浏览文件 @
a3c67b2f
function
(
USE_JITKERNEL_MORE TARGET TYPE
)
file
(
APPEND
${
jit_file
}
"USE_JITKERNEL_MORE(
${
TARGET
}
${
TYPE
}
);
\n
"
)
function
(
USE_JITKERNEL_MORE
_LITE
TARGET TYPE
)
file
(
APPEND
${
jit_file
}
"USE_JITKERNEL_MORE
_LITE
(
${
TARGET
}
${
TYPE
}
);
\n
"
)
endfunction
()
# enable it latter
...
...
lite/backends/x86/jit/more/intrinsic/CMakeLists.txt
浏览文件 @
a3c67b2f
...
...
@@ -5,5 +5,5 @@ cc_library(jit_kernel_intrinsic SRCS ${jit_kernel_cc_intrinsic} DEPS jit_kernel_
set
(
JIT_KERNEL_DEPS
${
JIT_KERNEL_DEPS
}
jit_kernel_intrinsic PARENT_SCOPE
)
# use mkl kernels by name and type
USE_JITKERNEL_MORE
(
kCRFDecoding, intrinsic
)
USE_JITKERNEL_MORE
(
kLayerNorm, intrinsic
)
USE_JITKERNEL_MORE
_LITE
(
kCRFDecoding, intrinsic
)
USE_JITKERNEL_MORE
_LITE
(
kLayerNorm, intrinsic
)
lite/backends/x86/jit/more/mix/CMakeLists.txt
浏览文件 @
a3c67b2f
...
...
@@ -5,11 +5,11 @@ cc_library(jit_kernel_mix SRCS ${jit_kernel_mix_cc} DEPS jit_kernel_base)
set
(
JIT_KERNEL_DEPS
${
JIT_KERNEL_DEPS
}
jit_kernel_mix PARENT_SCOPE
)
USE_JITKERNEL_MORE
(
kVSigmoid, mix
)
USE_JITKERNEL_MORE
(
kVTanh, mix
)
USE_JITKERNEL_MORE
(
kLSTMCtHt, mix
)
USE_JITKERNEL_MORE
(
kLSTMC1H1, mix
)
USE_JITKERNEL_MORE
(
kGRUH1, mix
)
USE_JITKERNEL_MORE
(
kGRUHtPart1, mix
)
USE_JITKERNEL_MORE
(
kGRUHtPart2, mix
)
USE_JITKERNEL_MORE
(
kSoftmax, mix
)
USE_JITKERNEL_MORE
_LITE
(
kVSigmoid, mix
)
USE_JITKERNEL_MORE
_LITE
(
kVTanh, mix
)
USE_JITKERNEL_MORE
_LITE
(
kLSTMCtHt, mix
)
USE_JITKERNEL_MORE
_LITE
(
kLSTMC1H1, mix
)
USE_JITKERNEL_MORE
_LITE
(
kGRUH1, mix
)
USE_JITKERNEL_MORE
_LITE
(
kGRUHtPart1, mix
)
USE_JITKERNEL_MORE
_LITE
(
kGRUHtPart2, mix
)
USE_JITKERNEL_MORE
_LITE
(
kSoftmax, mix
)
lite/backends/x86/jit/more/mkl/CMakeLists.txt
浏览文件 @
a3c67b2f
...
...
@@ -3,18 +3,18 @@ cc_library(jit_kernel_mkl SRCS mkl.cc DEPS jit_kernel_base dynload_mklml)
set
(
JIT_KERNEL_DEPS
${
JIT_KERNEL_DEPS
}
dynload_mklml jit_kernel_mkl PARENT_SCOPE
)
# use mkl kernels by name and type
USE_JITKERNEL_MORE
(
kMatMul, mkl
)
USE_JITKERNEL_MORE
(
kVMul, mkl
)
USE_JITKERNEL_MORE
(
kVAdd, mkl
)
USE_JITKERNEL_MORE
(
kVScal, mkl
)
USE_JITKERNEL_MORE
(
kStrideScal, mkl
)
USE_JITKERNEL_MORE
(
kVExp, mkl
)
USE_JITKERNEL_MORE
(
kVSquare, mkl
)
USE_JITKERNEL_MORE
(
kVCopy, mkl
)
USE_JITKERNEL_MORE
(
kVSigmoid, mkl
)
USE_JITKERNEL_MORE
(
kVTanh, mkl
)
USE_JITKERNEL_MORE
(
kSeqPool, mkl
)
USE_JITKERNEL_MORE
(
kSoftmax, mkl
)
USE_JITKERNEL_MORE
(
kEmbSeqPool, mkl
)
USE_JITKERNEL_MORE
(
kSgd, mkl
)
USE_JITKERNEL_MORE
(
kVBroadcast, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kMatMul, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVMul, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVAdd, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVScal, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kStrideScal, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVExp, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVSquare, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVCopy, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVSigmoid, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVTanh, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kSeqPool, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kSoftmax, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kEmbSeqPool, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kSgd, mkl
)
USE_JITKERNEL_MORE
_LITE
(
kVBroadcast, mkl
)
lite/backends/x86/jit/refer/CMakeLists.txt
浏览文件 @
a3c67b2f
...
...
@@ -2,39 +2,39 @@
cc_library
(
jit_kernel_refer SRCS refer.cc DEPS jit_kernel_base
)
set
(
JIT_KERNEL_DEPS
${
JIT_KERNEL_DEPS
}
jit_kernel_refer PARENT_SCOPE
)
function
(
USE_JITKERNEL_REFER TARGET
)
file
(
APPEND
${
jit_file
}
"USE_JITKERNEL_REFER(
${
TARGET
}
);
\n
"
)
function
(
USE_JITKERNEL_REFER
_LITE
TARGET
)
file
(
APPEND
${
jit_file
}
"USE_JITKERNEL_REFER
_LITE
(
${
TARGET
}
);
\n
"
)
endfunction
()
# use refer kernel by name
USE_JITKERNEL_REFER
(
kVMul
)
USE_JITKERNEL_REFER
(
kVAdd
)
USE_JITKERNEL_REFER
(
kVAddRelu
)
USE_JITKERNEL_REFER
(
kVSub
)
USE_JITKERNEL_REFER
(
kVScal
)
USE_JITKERNEL_REFER
(
kStrideScal
)
USE_JITKERNEL_REFER
(
kVAddBias
)
USE_JITKERNEL_REFER
(
kVCopy
)
USE_JITKERNEL_REFER
(
kVRelu
)
USE_JITKERNEL_REFER
(
kVIdentity
)
USE_JITKERNEL_REFER
(
kVExp
)
USE_JITKERNEL_REFER
(
kVSigmoid
)
USE_JITKERNEL_REFER
(
kVTanh
)
USE_JITKERNEL_REFER
(
kLSTMCtHt
)
USE_JITKERNEL_REFER
(
kLSTMC1H1
)
USE_JITKERNEL_REFER
(
kGRUH1
)
USE_JITKERNEL_REFER
(
kGRUHtPart1
)
USE_JITKERNEL_REFER
(
kGRUHtPart2
)
USE_JITKERNEL_REFER
(
kCRFDecoding
)
USE_JITKERNEL_REFER
(
kLayerNorm
)
USE_JITKERNEL_REFER
(
kNCHW16CMulNC
)
USE_JITKERNEL_REFER
(
kSeqPool
)
USE_JITKERNEL_REFER
(
kMatMul
)
USE_JITKERNEL_REFER
(
kVSquare
)
USE_JITKERNEL_REFER
(
kHSum
)
USE_JITKERNEL_REFER
(
kHMax
)
USE_JITKERNEL_REFER
(
kStrideASum
)
USE_JITKERNEL_REFER
(
kSoftmax
)
USE_JITKERNEL_REFER
(
kEmbSeqPool
)
USE_JITKERNEL_REFER
(
kSgd
)
USE_JITKERNEL_REFER
(
kVBroadcast
)
USE_JITKERNEL_REFER
_LITE
(
kVMul
)
USE_JITKERNEL_REFER
_LITE
(
kVAdd
)
USE_JITKERNEL_REFER
_LITE
(
kVAddRelu
)
USE_JITKERNEL_REFER
_LITE
(
kVSub
)
USE_JITKERNEL_REFER
_LITE
(
kVScal
)
USE_JITKERNEL_REFER
_LITE
(
kStrideScal
)
USE_JITKERNEL_REFER
_LITE
(
kVAddBias
)
USE_JITKERNEL_REFER
_LITE
(
kVCopy
)
USE_JITKERNEL_REFER
_LITE
(
kVRelu
)
USE_JITKERNEL_REFER
_LITE
(
kVIdentity
)
USE_JITKERNEL_REFER
_LITE
(
kVExp
)
USE_JITKERNEL_REFER
_LITE
(
kVSigmoid
)
USE_JITKERNEL_REFER
_LITE
(
kVTanh
)
USE_JITKERNEL_REFER
_LITE
(
kLSTMCtHt
)
USE_JITKERNEL_REFER
_LITE
(
kLSTMC1H1
)
USE_JITKERNEL_REFER
_LITE
(
kGRUH1
)
USE_JITKERNEL_REFER
_LITE
(
kGRUHtPart1
)
USE_JITKERNEL_REFER
_LITE
(
kGRUHtPart2
)
USE_JITKERNEL_REFER
_LITE
(
kCRFDecoding
)
USE_JITKERNEL_REFER
_LITE
(
kLayerNorm
)
USE_JITKERNEL_REFER
_LITE
(
kNCHW16CMulNC
)
USE_JITKERNEL_REFER
_LITE
(
kSeqPool
)
USE_JITKERNEL_REFER
_LITE
(
kMatMul
)
USE_JITKERNEL_REFER
_LITE
(
kVSquare
)
USE_JITKERNEL_REFER
_LITE
(
kHSum
)
USE_JITKERNEL_REFER
_LITE
(
kHMax
)
USE_JITKERNEL_REFER
_LITE
(
kStrideASum
)
USE_JITKERNEL_REFER
_LITE
(
kSoftmax
)
USE_JITKERNEL_REFER
_LITE
(
kEmbSeqPool
)
USE_JITKERNEL_REFER
_LITE
(
kSgd
)
USE_JITKERNEL_REFER
_LITE
(
kVBroadcast
)
lite/backends/x86/jit/refer/refer.cc
浏览文件 @
a3c67b2f
...
...
@@ -18,7 +18,7 @@
namespace
refer
=
paddle
::
lite
::
jit
::
refer
;
#define REGISTER_REFER_KERNEL(func) \
REGISTER_JITKERNEL_REFER
(
\
REGISTER_JITKERNEL_REFER
_LITE(
\
k##func, refer::func##Kernel<float>, refer::func##Kernel<double>)
REGISTER_REFER_KERNEL
(
VMul
);
...
...
lite/backends/x86/jit/registry.h
浏览文件 @
a3c67b2f
...
...
@@ -77,16 +77,16 @@ class JitKernelRegistrar {
void
Touch
()
{}
};
#define STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(uniq_name, msg)
\
#define STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(uniq_name, msg)
\
struct __test_global_namespace_##uniq_name##__ {}; \
static_assert(std::is_same<::__test_global_namespace_##uniq_name##__, \
__test_global_namespace_##uniq_name##__>::value, \
msg)
// Refer always on CPUPlace
#define REGISTER_JITKERNEL_REFER
(kernel_type, ...)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(
\
__reg_
jitkernel_##kernel_type##_refer_CPUPlace,
\
#define REGISTER_JITKERNEL_REFER
_LITE(kernel_type, ...)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(
\
__reg_
litejitkernel_##kernel_type##_refer_CPUPlace,
\
"REGISTER_KERNEL_REFER must be called in global namespace"); \
static ::paddle::lite::jit::JitKernelRegistrar< \
::paddle::lite::jit::ReferKernelPool, \
...
...
@@ -94,84 +94,84 @@ class JitKernelRegistrar {
__VA_ARGS__> \
__jit_kernel_registrar_##kernel_type##_refer_CPUPlace_( \
::paddle::lite::jit::KernelType::kernel_type); \
int
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_() {
\
int
LiteTouchJitKernelReg_##kernel_type##_refer_CPUPlace_() {
\
__jit_kernel_registrar_##kernel_type##_refer_CPUPlace_.Touch(); \
return 0; \
}
// kernel_type: should be in paddle::lite::jit::KernelType
// place_type: should be one of CPUPlace and GPUPlace in paddle::platform
#define REGISTER_KERNEL_MORE
(kernel_type, impl_type, place_type, ...)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(
\
__reg_
jitkernel_##kernel_type##_##impl_type##_##place_type,
\
"REGISTER_KERNEL_MORE
must be called in global namespace");
\
extern int
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
#define REGISTER_KERNEL_MORE
_LITE(kernel_type, impl_type, place_type, ...)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(
\
__reg_
litejitkernel_##kernel_type##_##impl_type##_##place_type,
\
"REGISTER_KERNEL_MORE
_LITE must be called in global namespace");
\
extern int
LiteTouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
static int __assert_##kernel_type##_##impl_type##_##place_type##_has_refer_ \
UNUSED =
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
UNUSED =
LiteTouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
static ::paddle::lite::jit::JitKernelRegistrar< \
::paddle::lite::jit::KernelPool, \
::paddle::lite::fluid::place_type, \
__VA_ARGS__> \
__jit_kernel_registrar_##kernel_type##_##impl_type##_##place_type##_( \
::paddle::lite::jit::KernelType::kernel_type); \
int
TouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_() {
\
int
LiteTouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_() {
\
__jit_kernel_registrar_##kernel_type##_##impl_type##_##place_type##_ \
.Touch(); \
return 0; \
}
#define REGISTER_JITKERNEL_MORE(kernel_type, impl_type, ...) \
REGISTER_KERNEL_MORE(kernel_type, impl_type, CPUPlace, __VA_ARGS__)
REGISTER_KERNEL_MORE
_LITE
(kernel_type, impl_type, CPUPlace, __VA_ARGS__)
#define REGISTER_GPUKERNEL_MORE(kernel_type, impl_type, ...) \
REGISTER_KERNEL_MORE(kernel_type, impl_type, GPUPlace, __VA_ARGS__)
#define REGISTER_GPUKERNEL_MORE
_LITE
(kernel_type, impl_type, ...) \
REGISTER_KERNEL_MORE
_LITE
(kernel_type, impl_type, GPUPlace, __VA_ARGS__)
#define REGISTER_JITKERNEL_GEN(kernel_type, ...) \
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE( \
__reg_
jitkernel_gen_##kernel_type##_CPUPlace_,
\
"REGISTER_JITKERNEL_GEN must be called in global namespace"); \
extern int
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
#define REGISTER_JITKERNEL_GEN
_LITE
(kernel_type, ...) \
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE
( \
__reg_
litejitkernel_gen_##kernel_type##_CPUPlace_,
\
"REGISTER_JITKERNEL_GEN
_LITE
must be called in global namespace"); \
extern int
LiteTouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
static int __assert_gen_##kernel_type##_has_refer_ UNUSED = \
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
LiteTouchJitKernelReg_##kernel_type##_refer_CPUPlace_();
\
static ::paddle::lite::jit::JitKernelRegistrar< \
::paddle::lite::jit::JitCodeCreatorPool, \
::paddle::lite::fluid::CPUPlace, \
__VA_ARGS__> \
__jit_kernel_registrar_gen_##kernel_type##_CPUPlace_( \
::paddle::lite::jit::KernelType::kernel_type); \
int
TouchJitKernelReg_gen_##kernel_type##_CPUPlace_() {
\
int
LiteTouchJitKernelReg_gen_##kernel_type##_CPUPlace_() {
\
__jit_kernel_registrar_gen_##kernel_type##_CPUPlace_.Touch(); \
return 0; \
}
#define USE_JITKERNEL_GEN
(kernel_type)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(
\
__reg_jitkernel_gen_##kernel_type##_CPUPlace_, \
"USE_JITKERNEL_GEN
must be called in global namespace");
\
extern int TouchJitKernelReg_gen_##kernel_type##_CPUPlace_(); \
static int use_jitkernel_gen_##kernel_type##_CPUPlace_ UNUSED = \
TouchJitKernelReg_gen_##kernel_type##_CPUPlace_()
#define USE_JITKERNEL_REFER
(kernel_type)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(
\
__reg_jitkernel_##kernel_type##_refer_CPUPlace_, \
"USE_JITKERNEL_REFER
must be called in global namespace");
\
extern int TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \
static int use_jitkernel_##kernel_type##_refer_CPUPlace_ UNUSED = \
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_()
#define USE_KERNEL_MORE
(kernel_type, impl_type, place_type)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(
\
__reg_jitkernel_##kernel_type##_##impl_type##_##place_type##_, \
"USE_JITKERNEL_MORE
must be called in global namespace");
\
#define USE_JITKERNEL_GEN
_LITE(kernel_type)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(
\
__reg_
lite
jitkernel_gen_##kernel_type##_CPUPlace_, \
"USE_JITKERNEL_GEN
_LITE must be called in global namespace");
\
extern int
Lite
TouchJitKernelReg_gen_##kernel_type##_CPUPlace_(); \
static int use_
lite
jitkernel_gen_##kernel_type##_CPUPlace_ UNUSED = \
Lite
TouchJitKernelReg_gen_##kernel_type##_CPUPlace_()
#define USE_JITKERNEL_REFER
_LITE(kernel_type)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(
\
__reg_
lite
jitkernel_##kernel_type##_refer_CPUPlace_, \
"USE_JITKERNEL_REFER
_LITE must be called in global namespace");
\
extern int
Lite
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_(); \
static int use_
lite
jitkernel_##kernel_type##_refer_CPUPlace_ UNUSED = \
Lite
TouchJitKernelReg_##kernel_type##_refer_CPUPlace_()
#define USE_KERNEL_MORE
_LITE(kernel_type, impl_type, place_type)
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(
\
__reg_
lite
jitkernel_##kernel_type##_##impl_type##_##place_type##_, \
"USE_JITKERNEL_MORE
_LITE must be called in global namespace");
\
extern int \
TouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_(); \
static int use_jitkernel_##kernel_type##_##impl_type##_##place_type##_ \
Lite
TouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_(); \
static int use_
lite
jitkernel_##kernel_type##_##impl_type##_##place_type##_ \
UNUSED = \
TouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_()
Lite
TouchJitKernelReg_##kernel_type##_##impl_type##_##place_type##_()
#define USE_JITKERNEL_MORE(kernel_type, impl_type) \
USE_KERNEL_MORE(kernel_type, impl_type, CPUPlace)
#define USE_JITKERNEL_MORE
_LITE
(kernel_type, impl_type) \
USE_KERNEL_MORE
_LITE
(kernel_type, impl_type, CPUPlace)
}
// namespace jit
}
// namespace lite
...
...
lite/kernels/npu/bridges/registry.h
浏览文件 @
a3c67b2f
...
...
@@ -67,14 +67,14 @@ class Registry {
#define UNUSED __attribute__((unused))
#endif
#define STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(uniq_name, msg)
\
#define STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(uniq_name, msg)
\
struct __test_global_namespace_##uniq_name##__ {}; \
static_assert(std::is_same<::__test_global_namespace_##uniq_name##__, \
__test_global_namespace_##uniq_name##__>::value, \
msg)
#define REGISTER_SUBGRAPH_BRIDGE(op_type__, target__, cvt_func_name) \
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
(
\
STATIC_ASSERT_JITKERNEL_GLOBAL_NAMESPACE
_LITE(
\
__reg_subgraph_bridge_##op_type__##_##target__##__, \
"REGISTER_SUBGRAPH_BRIDGE must be called in global namespace only " \
"once!"); \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录