---
_import: ../../_global.yaml
_recentralize:
    # useful parameters to change in recentralizer
    width: 4
    mean: auto
    std: 0
    scale: 1
    offset: 0
    wsep: 2.5
    # the name of quantizer used, either `incrementer` or `recentralizer`
    name: incrementer  # or recentralizer
    # incremental interval
    interval: 0.5
    sample: true
    encode: false
    # show plots
    plot: false
    should_update: true
_overrider:
    pruner:
        type: mayo.override.DynamicNetworkSurgeryPruner
        should_update: false
        _priority: 100
    depthwise_quantizer: &depthwise_quantizer
        type: mayo.override.ShiftQuantizer
        width: $(_recentralize.width)
        bias: 14
        overflow_rate: 0.0
        _priority: 70
    quantizer: &quantizer
        type: mayo.override.ShiftQuantizer
        width: $(_recentralize.width)
        # has_zero: false
        # asymmetry: true
        bias: 14
        overflow_rate: 0.0
        _priority: 70
    encoder:
        _huffman_True: mayo.override.HuffmanEncoder
        _huffman_False: mayo.override.EmptyOverrider
        type: $(_overrider.encoder._huffman_$(_recentralize.encode))
    parameter_quantizers:
        # TODO only mean quantizer is used for now.
        mean: {<<: *quantizer}
    recentralizer: &recentralizer
        type: mayo.override.MLERecentralizer
        modes:
            # mean and std for normalization,
            # and scale and offset for trainable denormalization.
            # specify the number of parameters used, accept 0, 1 and 2.
            # MLERecentralizer accepts `mean: auto` and `std: auto`
            # to automatically determine the number of means and stds used,
            # (at least one is used for both).
            # the number of scales and offsets will adjust accordingly.
            # if all of them are set to 0,
            # the recentralizer is entirely bypassed.
            # if not specified, the default value is used.
            # defaults: {mean: auto, std: auto, scale: 0, offset: 0}
            mean: $(_recentralize.mean)
            std: $(_recentralize.std)
            scale: $(_recentralize.scale)
            offset: $(_recentralize.offset)
            # include keys to specify what you want to be channel-wise
            channel: []
        quantizer: $(_overrider.quantizer)
        sample: $(_recentralize.sample)
        parameter_quantizers: $(_overrider.parameter_quantizers)
        wasserstein_separation: $(_recentralize.wsep)
        plot: $(_recentralize.plot)
        should_update: $(_recentralize.should_update)
        huffman: $(_recentralize.encode)
        # regularization: 0.00001
        _priority: 80
    incrementer:
        type: mayo.override.IncrementalQuantizer
        interval: $(_recentralize.interval)
        count_zero: true
        quantizer: $(_overrider.recentralizer)
        _priority: 90
    weights:
        prune: $(_overrider.pruner)
        quantize: $(_overrider.$(_recentralize.name))
        encode: $(_overrider.encoder)
    depthwise_weights:
        quantize: $(_overrider.$(_recentralize.name))
        encode: $(_overrider.encoder)
    # biases:
    #     shift: $(_overrider.quantizer)
