quantnn/models/pytorch/common.py
def _has_channels_last_tensor(parameters):
    """
    Determine whether any of the tensors in the models parameters is
    in channels last format.
    """
    for p in parameters:
        if isinstance(p.data, torch.Tensor):
            t = p.data
            if (
                t.is_contiguous(memory_format=torch.channels_last)
                and not t.is_contiguous()
            ):
                return True
            elif isinstance(t, list) or isinstance(t, tuple):
                if _has_channels_last_tensor(list(t)):
                    return True
    return False

    Determine whether any of the tensors in the models parameters is
    in channels last format.
    
Determine whether any of the tensors in the models parameters is
in channels last format.
Determine whether any of the tensors in the models parameters is in channels last format .
def _has_channels_last_tensor(parameters):
    for p in parameters:
        if isinstance(p.data, torch.Tensor):
            t = p.data
            if (
                t.is_contiguous(memory_format=torch.channels_last)
                and not t.is_contiguous()
            ):
                return True
            elif isinstance(t, list) or isinstance(t, tuple):
                if _has_channels_last_tensor(list(t)):
                    return True
    return False
def _has_channels_last_tensor ( parameters ) : for p in parameters : if isinstance ( p . data , torch . Tensor ) : t = p . data if ( t . is_contiguous ( memory_format = torch . channels_last ) and not t . is_contiguous ( ) ) : return True elif isinstance ( t , list ) or isinstance ( t , tuple ) : if _has_channels_last_tensor ( list ( t ) ) : return True return False
Determine whether any of the tensors in the models parameters is
in channels last format.
Determine whether any of the tensors in the models parameters is in channels last format .
"""
    Determine whether any of the tensors in the models parameters is
    in channels last format.
    """
parameters