Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
61a1f688
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2297
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
61a1f688
编写于
12月 05, 2022
作者:
G
Guanghua Yu
提交者:
GitHub
12月 05, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support matmul in QAT and loading quantized models in PTQ (#47892)
上级
cb812f40
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
1 deletion
+29
-1
python/paddle/fluid/contrib/slim/quantization/imperative/utils.py
...addle/fluid/contrib/slim/quantization/imperative/utils.py
+1
-0
python/paddle/fluid/contrib/slim/quantization/quantization_pass.py
...ddle/fluid/contrib/slim/quantization/quantization_pass.py
+18
-0
python/paddle/nn/quant/__init__.py
python/paddle/nn/quant/__init__.py
+1
-0
python/paddle/nn/quant/functional_layers.py
python/paddle/nn/quant/functional_layers.py
+9
-1
未找到文件。
python/paddle/fluid/contrib/slim/quantization/imperative/utils.py
浏览文件 @
61a1f688
...
...
@@ -63,6 +63,7 @@ fake_quant_output_layers = [
paddle
.
nn
.
quant
.
subtract
,
paddle
.
nn
.
quant
.
multiply
,
paddle
.
nn
.
quant
.
divide
,
paddle
.
nn
.
quant
.
matmul
,
]
fake_quant_leaf_layers
=
[
...
...
python/paddle/fluid/contrib/slim/quantization/quantization_pass.py
浏览文件 @
61a1f688
...
...
@@ -1939,6 +1939,15 @@ class AddQuantDequantPass:
op_node
.
op
().
_set_attr
(
"activation_bits"
,
self
.
_quant_bits
)
op_node
.
op
().
_set_attr
(
"with_quant_attr"
,
True
)
arg_names
=
utils
.
_get_op_input_var_names
(
op_node
)
# If already quanted, skip it.
skip_quant
=
False
for
arg_name
in
arg_names
:
if
"quantized.dequantized"
in
arg_name
:
skip_quant
=
True
break
if
skip_quant
:
continue
for
arg_name
in
arg_names
:
in_node
=
graph
.
_find_node_by_name
(
op_node
.
inputs
,
arg_name
...
...
@@ -2797,6 +2806,15 @@ class AddQuantDequantPassV2:
continue
arg_names
=
utils
.
_get_op_input_var_names
(
op_node
)
# If already quanted, skip it.
skip_quant
=
False
for
arg_name
in
arg_names
:
if
"quantized.dequantized"
in
arg_name
:
skip_quant
=
True
break
if
skip_quant
:
continue
for
arg_name
in
arg_names
:
in_node
=
graph
.
_find_node_by_name
(
op_node
.
inputs
,
arg_name
...
...
python/paddle/nn/quant/__init__.py
浏览文件 @
61a1f688
...
...
@@ -21,6 +21,7 @@ from .functional_layers import reshape # noqa: F401
from
.functional_layers
import
transpose
# noqa: F401
from
.functional_layers
import
concat
# noqa: F401
from
.functional_layers
import
flatten
# noqa: F401
from
.functional_layers
import
matmul
# noqa: F401
from
.quant_layers
import
QuantStub
# noqa: F401
__all__
=
[]
python/paddle/nn/quant/functional_layers.py
浏览文件 @
61a1f688
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from
...tensor
import
manipulation
,
math
from
...tensor
import
linalg
,
manipulation
,
math
from
..
import
Layer
__all__
=
[]
...
...
@@ -85,3 +85,11 @@ class flatten(FloatFunctionalLayer):
def
forward
(
self
,
x
,
start_axis
=
0
,
stop_axis
=-
1
,
name
=
None
):
return
manipulation
.
flatten
(
x
,
start_axis
,
stop_axis
,
name
)
class
matmul
(
FloatFunctionalLayer
):
def
__init__
(
self
):
super
().
__init__
()
def
forward
(
self
,
x
,
y
,
transpose_x
=
False
,
transpose_y
=
False
,
name
=
None
):
return
linalg
.
matmul
(
x
,
y
,
transpose_x
,
transpose_y
,
name
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录