MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / backward

Method backward

codegeex/quantization/quantize.py:23–29  ·  view source on GitHub ↗
(ctx, grad_output: torch.Tensor)

Source from the content-addressed store, hash-verified

21
22 @staticmethod
23 def backward(ctx, grad_output: torch.Tensor):
24 inp, quant_w, scale_w = ctx.saved_tensors
25 weight = extract_weight_to_half(quant_w, scale_w, ctx.weight_bit_width)
26 grad_output = grad_output.contiguous().view(-1, weight.size(0))
27 grad_input = grad_output.mm(weight)
28 grad_weight = grad_output.t().mm(inp)
29 return grad_input.view(ctx.inp_shape), grad_weight.view(ctx.weight_shape), None
30
31
32class QuantizedLinear(torch.nn.Module):

Callers

nothing calls this directly

Calls 2

extract_weight_to_halfFunction · 0.90
sizeMethod · 0.80

Tested by

no test coverage detected