diff --git a/paddleslim/core/dygraph.py b/paddleslim/core/dygraph.py index 900bfddd7a766b8ef3f62b6c2c44a2fde0753e14..128509321099da86af03c1ccab0e2b442c59a6f5 100644 --- a/paddleslim/core/dygraph.py +++ b/paddleslim/core/dygraph.py @@ -61,13 +61,13 @@ def extract_vars(inputs): vars.append(_value) else: _logger.warn( - f"Variable is excepted, but get an element with type({type(_value)}) from inputs whose type is dict. And the key of element is {_key}." + "Variable is excepted, but get an element with type({}) from inputs whose type is dict. And the key of element is {}.".format(type(_value), _key) ) elif isinstance(inputs, (tuple, list)): for _value in inputs: vars.extend(extract_vars(_value)) if len(vars) == 0: - _logger.warn(f"Extract none variables from inputs.") + _logger.warn("Extract none variables from inputs.") return vars diff --git a/paddleslim/dygraph/prune/filter_pruner.py b/paddleslim/dygraph/prune/filter_pruner.py index 1a90e2516a4240ff705013b9fbae1ddfe5ce9786..8c4b5b3114b7499a6f15ef6fe31e4f3fe97d971a 100644 --- a/paddleslim/dygraph/prune/filter_pruner.py +++ b/paddleslim/dygraph/prune/filter_pruner.py @@ -320,7 +320,7 @@ class FilterPruner(Pruner): """ if var_name in self.skip_vars: _logger.warn( - f"{var_name} is skiped beacause it is not support for pruning derectly." + "{} is skiped beacause it is not support for pruning derectly.".format(var_name) ) return if isinstance(pruned_dims, int): @@ -340,7 +340,7 @@ class FilterPruner(Pruner): 'var': param, 'value': np.array(param.value().get_tensor()) }) - _logger.debug(f"set value of {param.name} into group") + _logger.debug("set value of {} into group".format(param.name)) mask = self.cal_mask(var_name, pruned_ratio, group_dict) for _name in group_dict: @@ -356,7 +356,7 @@ class FilterPruner(Pruner): src_mask = self._transform_mask(src_mask, trans) current_mask = src_mask assert len(current_mask) == var_shape[dims[ - 0]], f"The length of current_mask must be equal to the size of dimension to be pruned on. But get: len(current_mask): {len(current_mask)}; var_shape: {var_shape}; dims: {dims}; var name: {_name}; len(mask): {len(mask)}" + 0]], "The length of current_mask must be equal to the size of dimension to be pruned on. But get: len(current_mask): {}; var_shape: {}; dims: {}; var name: {}; len(mask): {}".format(len(current_mask), var_shape, dims, _name, len(mask)) plan.add(_name, PruningMask(dims, current_mask, pruned_ratio)) if apply == "lazy": plan.apply(self.model, lazy=True) diff --git a/paddleslim/prune/group_param.py b/paddleslim/prune/group_param.py index 9a406e31a75c2e0cf0eb5d3c581af96c3f9e3aac..5e0d583b2d873aeb05644add825864d4f40bf723 100644 --- a/paddleslim/prune/group_param.py +++ b/paddleslim/prune/group_param.py @@ -60,7 +60,7 @@ def collect_convs(params, graph, visited={}): param = graph.var(_param) if param is None: _logger.warning( - f"Cann't found relative variables of {_param} because {_param} is not in target program or model. Please make sure {_param} is in your program if you are using static API of PaddlePaddle. And make sure your model in correctly mode and contains {_param} if you are using dynamic API of PaddlePaddle." + "Cann't found relative variables of {} because {} is not in target program or model. Please make sure {} is in your program if you are using static API of PaddlePaddle. And make sure your model in correctly mode and contains {} if you are using dynamic API of PaddlePaddle.".format(_param, _param, _param, _param) ) groups.append([]) continue diff --git a/paddleslim/prune/prune_walker.py b/paddleslim/prune/prune_walker.py index 85439a494c19346cd1313e910c0addb2f0ab7eb9..0edd1ecd463b83a8aec288a9efdc1e1997cca2ec 100644 --- a/paddleslim/prune/prune_walker.py +++ b/paddleslim/prune/prune_walker.py @@ -95,7 +95,7 @@ class PruneWorker(object): _logger.debug("\nfrom: {}\nto: {}\npruned_axis: {}; var: {}".format( self.op, op, pruned_axis, var.name())) _logger.debug( - f"visit {op.type()} by var [{var.name()}] on axis [{pruned_axis}];\t visited={self.visited}\n" + "visit {} by var [{}] on axis [{}];\t visited={}\n".format(op.type(), var.name(), pruned_axis, self.visited) ) walker = cls(op, pruned_params=self.pruned_params, visited=self.visited) walker.prune(var, pruned_axis, pruned_idx) @@ -123,7 +123,7 @@ class conv2d(PruneWorker): def _prune(self, var, pruned_axis, pruned_idx): if self._is_depthwise_conv(self.op): - _logger.debug(f"Meet conv2d who is depthwise conv2d actually.") + _logger.debug("Meet conv2d who is depthwise conv2d actually.") walker = depthwise_conv2d( self.op, self.pruned_params, visited=self.visited) walker._prune(var, pruned_axis, pruned_idx) diff --git a/paddleslim/prune/pruner.py b/paddleslim/prune/pruner.py index 60fd885e676a2b2585b44ce65147f14a989f0c66..557ec615567ed6d74806a8b70b6e2d5001f69f9a 100644 --- a/paddleslim/prune/pruner.py +++ b/paddleslim/prune/pruner.py @@ -144,7 +144,7 @@ class Pruner(): op.attr("groups") * new_shape[pruned_axis] / origin_shape[pruned_axis]) _logger.debug( - f"change groups of conv({param.name()}) from {op.attr('groups')} to {new_groups}; origin_shape: {origin_shape}; new_shape: {new_shape}" + "change groups of conv({}) from {} to {}; origin_shape: {}; new_shape: {}".format(param.name(), op.attr('groups'), new_groups, origin_shape, new_shape) ) op.set_attr("groups", new_groups)