xnn.common.models.fast.FastPathModule#

class xnn.common.models.fast.FastPathModule[source]#

Bases: object

Mixin of a module with a reference and a fast implementation.

A fast-path module subclasses its reference module (so its parameters and state_dict are the reference ones) and this mixin. It implements the fast evaluation in methods marked @torch.jit.unused and branches on fast_active, which the owning model sets before each evaluation (see select()); its __init__ sets self.fast_active = False. Under TorchScript the flag is always False.

Variables:

fast_active (bool) – Whether the next evaluation uses the fast path.

fast_supported(device, dtype)[source]#

Whether the fast path can run for inputs on device in dtype.

Parameters:
Return type:

bool