diff --git a/demo/dygraph/quant/mobilenet_v3.py b/demo/dygraph/quant/mobilenet_v3.py index f9e6996283acfdebea623d395ce844ad897e71cf..64fd1a19795d2eca81cfb5236893948ed2bd2d8d 100644 --- a/demo/dygraph/quant/mobilenet_v3.py +++ b/demo/dygraph/quant/mobilenet_v3.py @@ -213,7 +213,7 @@ class ConvBNLayer(nn.Layer): if self.act == "relu": x = F.relu(x) elif self.act == "hard_swish": - x = hard_swish(x) + x = paddle.nn.functional.activation.hardswish(x) else: print("The activation function is selected incorrectly.") exit() diff --git a/paddleslim/dygraph/quant/quanter.py b/paddleslim/dygraph/quant/quanter.py index 1b800bfade34ae6571b667c1e1fc751e8cc4a02b..d62e9b3c17721f34f93ed1f83b9c0c03413f313f 100644 --- a/paddleslim/dygraph/quant/quanter.py +++ b/paddleslim/dygraph/quant/quanter.py @@ -235,6 +235,8 @@ class QAT(object): quantizable_layer_type=self.config['quantizable_layer_type']) with paddle.utils.unique_name.guard(): + if hasattr(model, "_layers"): + model = model._layers model.__init__() self.imperative_qat.quantize(model) state_dict = model.state_dict()