nncf/experimental/torch/nas/bootstrapNAS/elasticity/elastic_width.py
def _width_to_mask(active_width: int, max_width: int, device: torch.device) -> PTNNCFTensor:
        """
        Encodes width to tensor filled by 1 and 0. We intentionally construct mask in a way that first N values are
        equal to 1, and the rest values are 0. The N encodes width value. The mask tensors allows to fully reuse mask
        propagation algorithm without any changes, in contrast of implementing a separate width propagation algorithm.

        :param active_width: width value to encode in the mask.
        :param max_width: maximum width value.
        :param device: device that should have a mask tensor.
        :return: encoded mask tensor
        """
        mask = torch.ones(max_width).to(device)
        mask[active_width:].fill_(0)
        return PTNNCFTensor(mask)

        Encodes width to tensor filled by 1 and 0. We intentionally construct mask in a way that first N values are
        equal to 1, and the rest values are 0. The N encodes width value. The mask tensors allows to fully reuse mask
        propagation algorithm without any changes, in contrast of implementing a separate width propagation algorithm.

        :param active_width: width value to encode in the mask.
        :param max_width: maximum width value.
        :param device: device that should have a mask tensor.
        :return: encoded mask tensor
        
Encodes width to tensor filled by 1 and 0. We intentionally construct mask in a way that first N values are
equal to 1, and the rest values are 0. The N encodes width value. The mask tensors allows to fully reuse mask
propagation algorithm without any changes, in contrast of implementing a separate width propagation algorithm.
Encodes width to tensor filled by 1 and 0 . We intentionally construct mask in a way that first N values are equal to 1 and the rest values are 0 . The N encodes width value . The mask tensors allows to fully reuse mask propagation algorithm without any changes in contrast of implementing a separate width propagation algorithm .
def _width_to_mask(active_width: int, max_width: int, device: torch.device) -> PTNNCFTensor:
        mask = torch.ones(max_width).to(device)
        mask[active_width:].fill_(0)
        return PTNNCFTensor(mask)
def _width_to_mask ( active_width : int , max_width : int , device : torch . device ) -> PTNNCFTensor : mask = torch . ones ( max_width ) . to ( device ) mask [ active_width : ] . fill_ ( 0 ) return PTNNCFTensor ( mask )
Encodes width to tensor filled by 1 and 0.
Encodes width to tensor filled by 1 and 0 .
"""
        Encodes width to tensor filled by 1 and 0. We intentionally construct mask in a way that first N values are
        equal to 1, and the rest values are 0. The N encodes width value. The mask tensors allows to fully reuse mask
        propagation algorithm without any changes, in contrast of implementing a separate width propagation algorithm.

        :param active_width: width value to encode in the mask.
        :param max_width: maximum width value.
        :param device: device that should have a mask tensor.
        :return: encoded mask tensor
        """
encoded mask tensor
encoded mask tensor
active_width
int
width value to encode in the mask.
width value to encode in the mask .
max_width
int
maximum width value.
maximum width value .
device
torch.device
device that should have a mask tensor.
device that should have a mask tensor .