Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
cbe2dbf0
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看板
提交
cbe2dbf0
编写于
3月 21, 2019
作者:
W
Wojciech Uss
提交者:
Tao Luo
3月 21, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add enabling quantization (#16326)
* Add enabling quantization test=develop * remove unused (here) function
上级
9a058591
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
0 deletion
+40
-0
paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass.h
paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass.h
+4
-0
paddle/fluid/inference/analysis/argument.h
paddle/fluid/inference/analysis/argument.h
+9
-0
paddle/fluid/inference/analysis/ir_pass_manager.cc
paddle/fluid/inference/analysis/ir_pass_manager.cc
+8
-0
paddle/fluid/inference/api/paddle_pass_builder.cc
paddle/fluid/inference/api/paddle_pass_builder.cc
+4
-0
paddle/fluid/inference/api/paddle_pass_builder.h
paddle/fluid/inference/api/paddle_pass_builder.h
+15
-0
未找到文件。
paddle/fluid/framework/ir/mkldnn/mkldnn_placement_pass.h
浏览文件 @
cbe2dbf0
...
...
@@ -14,12 +14,16 @@ limitations under the License. */
#pragma once
#include <memory>
#include "paddle/fluid/framework/ir/pass.h"
namespace
paddle
{
namespace
framework
{
namespace
ir
{
/*
* Specifies which operators should use MKLDNN.
*/
class
MKLDNNPlacementPass
:
public
Pass
{
protected:
std
::
unique_ptr
<
ir
::
Graph
>
ApplyImpl
(
...
...
paddle/fluid/inference/analysis/argument.h
浏览文件 @
cbe2dbf0
...
...
@@ -131,6 +131,15 @@ struct Argument {
// Pass a set of op types to enable its mkldnn kernel
DECL_ARGUMENT_FIELD
(
mkldnn_enabled_op_types
,
MKLDNNEnabledOpTypes
,
std
::
unordered_set
<
std
::
string
>
);
// A set of op types to enable their quantized kernels
DECL_ARGUMENT_FIELD
(
quantize_enabled_op_types
,
QuantizeEnabledOpTypes
,
std
::
unordered_set
<
std
::
string
>
);
// A set of op IDs to exclude from enabling their quantized kernels
DECL_ARGUMENT_FIELD
(
quantize_excluded_op_ids
,
QuantizeExcludedOpIds
,
std
::
unordered_set
<
int
>
);
// Scales for variables to be quantized
DECL_ARGUMENT_FIELD
(
quant_var_scales
,
QuantVarScales
,
VarQuantScale
);
...
...
paddle/fluid/inference/analysis/ir_pass_manager.cc
浏览文件 @
cbe2dbf0
...
...
@@ -15,6 +15,7 @@
#include "paddle/fluid/inference/analysis/ir_pass_manager.h"
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include "paddle/fluid/framework/ir/fuse_pass_base.h"
#include "paddle/fluid/framework/ir/graph.h"
...
...
@@ -60,6 +61,13 @@ void IRPassManager::CreatePasses(Argument *argument,
pass
->
Set
(
"mkldnn_enabled_op_types"
,
new
std
::
unordered_set
<
std
::
string
>
(
argument
->
mkldnn_enabled_op_types
()));
}
else
if
(
pass_name
==
"cpu_quantize_placement_pass"
)
{
pass
->
Set
(
"quantize_enabled_op_types"
,
new
std
::
unordered_set
<
std
::
string
>
(
argument
->
quantize_enabled_op_types
()));
pass
->
Set
(
"quantize_excluded_op_ids"
,
new
std
::
unordered_set
<
int
>
(
argument
->
quantize_excluded_op_ids
()));
}
else
if
(
pass_name
==
"cpu_quantize_pass"
)
{
pass
->
Set
(
"quant_var_scales"
,
new
VarQuantScale
(
argument
->
quant_var_scales
()));
...
...
paddle/fluid/inference/api/paddle_pass_builder.cc
浏览文件 @
cbe2dbf0
...
...
@@ -91,6 +91,10 @@ GpuPassStrategy::GpuPassStrategy() : PassStrategy({}) {
use_gpu_
=
true
;
}
void
GpuPassStrategy
::
EnableQuantizer
()
{
LOG
(
ERROR
)
<<
"GPU not support quantization yet"
;
}
void
PaddlePassBuilder
::
AppendAnalysisPass
(
const
std
::
string
&
pass
)
{
analysis_passes_
.
push_back
(
pass
);
}
...
...
paddle/fluid/inference/api/paddle_pass_builder.h
浏览文件 @
cbe2dbf0
...
...
@@ -84,6 +84,10 @@ class PassStrategy : public PaddlePassBuilder {
*/
virtual
void
EnableMKLDNN
()
{}
/** Enable quantize optimization
*/
virtual
void
EnableQuantizer
()
{}
bool
use_gpu
()
const
{
return
use_gpu_
;
}
virtual
~
PassStrategy
()
=
default
;
...
...
@@ -124,6 +128,16 @@ class CpuPassStrategy : public PassStrategy {
use_mkldnn_
=
false
;
#endif
}
void
EnableQuantizer
()
override
{
if
(
!
use_quantizer_
)
{
passes_
.
push_back
(
"cpu_quantize_placement_pass"
);
}
use_quantizer_
=
true
;
}
protected:
bool
use_quantizer_
{
false
};
};
/** The GPU passes strategy, it is used in AnalysisPredictor with GPU mode.
...
...
@@ -138,6 +152,7 @@ class GpuPassStrategy : public PassStrategy {
}
void
EnableMKLDNN
()
override
;
void
EnableQuantizer
()
override
;
virtual
~
GpuPassStrategy
()
=
default
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录