(module, dtype)
Quantizes module to given data type (inplace).

    :param module: PyTorch module.
    :type module: `torch.nn.Module`
    :param dtype: Target data type.
Quantizes module to given data type (inplace).
Quantizes module to given data type ( inplace ) .
def quantize(module, dtype):
    """
    Quantizes module to given data type (inplace).

    :param module: PyTorch module.
    :type module: `torch.nn.Module`
    :param dtype: Target data type.
    """
    __precheck(module)

    parameters = ['weight']
    #parameters = [name for name, _ in module.named_parameters()]
    if hasattr(module, 'condense'): module.condense |= set(parameters)
    else: module.condense = set(parameters)

    if not cfg.__CONDENSA_RECORD_MODE__:
        if dtype.as_dtype_enum == dtypes.DT_FLOAT16:
            module.half()
        elif dtype.as_dtype_enum == dtypes.DT_FLOAT32:
            module.float()
        else:
            raise TypeError('Unknown data type specified for quantization')
def quantize ( module , dtype ) : __precheck ( module ) parameters = [ 'weight' ] #parameters = [name for name, _ in module.named_parameters()] if hasattr ( module , 'condense' ) : module . condense |= set ( parameters ) else : module . condense = set ( parameters ) if not cfg . __CONDENSA_RECORD_MODE__ : if dtype . as_dtype_enum == dtypes . DT_FLOAT16 : module . half ( ) elif dtype . as_dtype_enum == dtypes . DT_FLOAT32 : module . float ( ) else : raise TypeError ( 'Unknown data type specified for quantization' )