xnn.common.models.constants.ExactFloat64Constants#

class xnn.common.models.constants.ExactFloat64Constants(*args, **kwargs)[source]#

Bases: object

Mixin for a model whose float64 constants stay exact through casts and loads.

List it before the torch.nn.Module base class. After every cast (.to, .double, …) and every load_state_dict of the model, or of a module that contains it, exact_float64_constants() rebuilds its float64 constants exactly.