INNER CODE UNIT · Python

exists

Extraltodeus/ComfyUI-AutomaticCFG · experimental_temperature.py:10

def exists(val):
    return val is not None

# better than a division by 0 hey
abs_mean = lambda x: torch.where(torch.isnan(x) | torch.isinf(x), torch.zeros_like(x), x).abs().mean()

class temperature_patcher():
    def __init__(self, temperature, layer_name="None"):
        self.temperature = temperature
        self.layer_name  = layer_name
    
    # taken from comfy.ldm.modules
    def attention_basic_with_temperature(self, q, k, v, extra_options, mask=None, attn_precision=None):
        if isinstance(extra_options, int):
            heads = extra_options
        else:
            heads = extra_options['n_heads']

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…