fd551c8611033e2c9e9f350f13fc3bce8c7fd32e,src/sdk/pynni/nni/compression/torch/builtin_pruners.py,AGP_Pruner,calc_mask,#AGP_Pruner#,51

Before Change


        self.now_epoch = 1

    def calc_mask(self, weight, config, op_name, **kwargs):
        mask = self.mask_list.get(op_name, torch.ones(weight.shape))
        target_sparsity = self.compute_target_sparsity(config)
        k = int(weight.numel() * target_sparsity)
        if k == 0 or target_sparsity >= 1 or target_sparsity <= 0:
            return mask
        // if we want to generate new mask, we should update weigth first 
        w_abs = weight.abs()*mask
        threshold = torch.topk(w_abs.view(-1), k, largest = False).values.max()
        new_mask = torch.gt(w_abs, threshold).type(weight.type())
        self.mask_list[op_name] = new_mask
        return new_mask

After Change


        self.now_epoch = 1

    def calc_mask(self, weight, config, op_name, **kwargs):
        mask = self.mask_list.get(op_name, torch.ones(weight.shape).type_as(weight))
        target_sparsity = self.compute_target_sparsity(config)
        k = int(weight.numel() * target_sparsity)
        if k == 0 or target_sparsity >= 1 or target_sparsity <= 0:
            return mask
        // if we want to generate new mask, we should update weigth first 
        w_abs = weight.abs() * mask
        threshold = torch.topk(w_abs.view(-1), k, largest=False).values.max()
        new_mask = torch.gt(w_abs, threshold).type_as(weight)
        self.mask_list[op_name] = new_mask
        return new_mask
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 5

Non-data size: 2

Instances


Project Name: microsoft/nni
Commit Name: fd551c8611033e2c9e9f350f13fc3bce8c7fd32e
Time: 2019-10-16
Author: lanny@mail.hfut.edu.cn
File Name: src/sdk/pynni/nni/compression/torch/builtin_pruners.py
Class Name: AGP_Pruner
Method Name: calc_mask


Project Name: microsoft/nni
Commit Name: fd551c8611033e2c9e9f350f13fc3bce8c7fd32e
Time: 2019-10-16
Author: lanny@mail.hfut.edu.cn
File Name: src/sdk/pynni/nni/compression/torch/builtin_pruners.py
Class Name: SensitivityPruner
Method Name: calc_mask


Project Name: chainer/chainercv
Commit Name: 24a617a6547b48b633bab79669d571e0ee3c7e97
Time: 2019-05-16
Author: yuyuniitani@gmail.com
File Name: tests/extensions_tests/evaluator_tests/test_instance_segmentation_coco_evaluator.py
Class Name: TestInstanceSegmentationCOCOEvaluator
Method Name: _set_up


Project Name: NervanaSystems/coach
Commit Name: 79b05a81057762739ef0f2faf00dd3b5a1b526c6
Time: 2020-01-14
Author: gal.novik@intel.com
File Name: rl_coach/filters/action/box_discretization.py
Class Name: BoxDiscretization
Method Name: get_unfiltered_action_space


Project Name: NifTK/NiftyNet
Commit Name: f4ed926c2a8a7f0fc30c171d83907134dafd54eb
Time: 2018-07-21
Author: wenqi.li@ucl.ac.uk
File Name: niftynet/layer/crf.py
Class Name: CRFAsRNNLayer
Method Name: layer_op