b0c0eb7b1f2ac9a983c550ee971cea275463d8fc,src/sdk/pynni/nni/compression/torch/builtin_pruners.py,RankFilterPruner,calc_mask,#RankFilterPruner#Any#Any#,256

Before Change


        if op_name in self.mask_calculated_ops:
            assert op_name in self.mask_dict
            return self.mask_dict.get(op_name)
        mask = torch.ones(weight.size()).type_as(weight)
        try:
            filters = weight.size(0)
            num_prune = int(filters * config.get("sparsity"))
            if filters < 2 or num_prune < 1:
                return mask
            mask = self._get_mask(mask, weight, num_prune)
        finally:
            self.mask_dict.update({op_name: mask})
            self.mask_calculated_ops.add(op_name)
        return mask.detach()


class L1FilterPruner(RankFilterPruner):
    

After Change


        if op_name in self.mask_calculated_ops:
            assert op_name in self.mask_dict
            return self.mask_dict.get(op_name)
        mask_weight = torch.ones(weight.size()).type_as(weight).detach()
        if hasattr(layer.module, "bias") and layer.module.bias is not None:
            mask_bias = torch.ones(layer.module.bias.size()).type_as(layer.module.bias).detach()
        else:
            mask_bias = None
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: microsoft/nni
Commit Name: b0c0eb7b1f2ac9a983c550ee971cea275463d8fc
Time: 2019-12-23
Author: lanny@mail.hfut.edu.cn
File Name: src/sdk/pynni/nni/compression/torch/builtin_pruners.py
Class Name: RankFilterPruner
Method Name: calc_mask


Project Name: microsoft/nni
Commit Name: 5eb95c2d8a5af8a16fba64b58684ed3e3a7d1ec8
Time: 2020-03-17
Author: 38930155+chicm-ms@users.noreply.github.com
File Name: src/sdk/pynni/nni/compression/torch/weight_rank_filter_pruners.py
Class Name: L2FilterPruner
Method Name: get_mask


Project Name: microsoft/nni
Commit Name: 5eb95c2d8a5af8a16fba64b58684ed3e3a7d1ec8
Time: 2020-03-17
Author: 38930155+chicm-ms@users.noreply.github.com
File Name: src/sdk/pynni/nni/compression/torch/weight_rank_filter_pruners.py
Class Name: L1FilterPruner
Method Name: get_mask