MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / backward

Method backward

diffsynth/models/kolors_text_encoder.py:92–98  ·  view source on GitHub ↗
(ctx, grad_output: torch.Tensor)

Source from the content-addressed store, hash-verified

90
91 @staticmethod
92 def backward(ctx, grad_output: torch.Tensor):
93 inp, quant_w, scale_w = ctx.saved_tensors
94 weight = extract_weight_to_half(quant_w, scale_w, ctx.weight_bit_width)
95 grad_output = grad_output.contiguous().view(-1, weight.size(0))
96 grad_input = grad_output.mm(weight)
97 grad_weight = grad_output.t().mm(inp)
98 return grad_input.view(ctx.inp_shape), grad_weight.view(ctx.weight_shape), None, None
99
100
101def compress_int4_weight(weight: torch.Tensor): # (n, m)

Callers

nothing calls this directly

Calls 1

extract_weight_to_halfFunction · 0.85

Tested by

no test coverage detected