MCPcopy Create free account
hub / github.com/THUDM/GLM / FP16_Module

Class FP16_Module

fp16/fp16.py:67–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67class FP16_Module(nn.Module):
68 def __init__(self, module):
69 super(FP16_Module, self).__init__()
70 self.add_module('module', module.half())
71
72 def forward(self, *inputs, **kwargs):
73 return fp16_to_fp32(self.module(*(fp32_to_fp16(inputs)), **kwargs))
74
75 def named_parameters(self, prefix: str = '', recurse: bool = True):
76 return self.module.named_parameters(prefix=prefix, recurse=recurse)
77
78 def state_dict(self, destination=None, prefix='', keep_vars=False):
79 return self.module.state_dict(destination, prefix, keep_vars)
80
81 def load_state_dict(self, state_dict, strict=True):
82 return self.module.load_state_dict(state_dict, strict=strict)
83
84
85# TODO: Update overflow check + downscale to use Carl's fused kernel.

Callers 1

get_modelFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected