forked from PaddlePaddle/Paddle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cherry pick PaddlePaddle#42255 (fuse conv + bn in QAT) and PaddlePadd…
…le#42378 (support skip_op_list in PTQ) (PaddlePaddle#43301) * support fuse conv and bn in QAT (PaddlePaddle#42255) * support skip_op_list in PostTrainingQuantization (PaddlePaddle#42378) * fix unittest
- Loading branch information
Showing
9 changed files
with
181 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
python/paddle/fluid/contrib/slim/tests/test_imperative_qat_fuse.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 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. | ||
|
||
from __future__ import print_function | ||
|
||
import os | ||
import numpy as np | ||
import random | ||
import unittest | ||
import logging | ||
|
||
import paddle | ||
import paddle.fluid as fluid | ||
from paddle.fluid import core | ||
from paddle.fluid.log_helper import get_logger | ||
|
||
from test_imperative_qat import TestImperativeQat | ||
|
||
paddle.enable_static() | ||
|
||
os.environ["CPU_NUM"] = "1" | ||
if core.is_compiled_with_cuda(): | ||
fluid.set_flags({"FLAGS_cudnn_deterministic": True}) | ||
|
||
_logger = get_logger( | ||
__name__, logging.INFO, fmt='%(asctime)s-%(levelname)s: %(message)s') | ||
|
||
|
||
class TestImperativeQatfuseBN(TestImperativeQat): | ||
def set_vars(self): | ||
self.weight_quantize_type = 'abs_max' | ||
self.activation_quantize_type = 'moving_average_abs_max' | ||
self.diff_threshold = 0.01 | ||
self.onnx_format = False | ||
self.fuse_conv_bn = True | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters