dmx.compressor.functional.approximate
Classes
|
An approximation operator container |
This is an abstract class of approximation algorithm. |
|
|
Mixin to equip modules with approximated forward logic through Approximator |
|
Encapsulates approximation forward logic of a module |
|
This class specifies an approximation function for a custom written torch function. |
alias of |
|
This is a dummy approximation algorithm that means no approximation. |
|
|
This class specifies an approximation function for a member of torch.nn.functional. |
- class dmx.compressor.functional.approximate.Approximate(function=NONE)
Bases:
ModuleAn approximation operator container
- extra_repr()
Return the extra representation of the module.
To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.
- forward(input, *args, **kwargs)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- set_function(function: str | ApproximationFunction) None
- class dmx.compressor.functional.approximate.ApproximationFunction
Bases:
objectThis is an abstract class of approximation algorithm. Child classes to implement execute() and from_shorthand() method.
- execute(*args, **kwargs)
- static from_shorthand(sh: str)
- class dmx.compressor.functional.approximate.ApproximationMixin(*args, **kwargs)
Bases:
objectMixin to equip modules with approximated forward logic through Approximator
- approx_forward(inputs, *args, **kwargs)
- property approximation_function
- approximator_wrapper(inputs, approx_args, approx_kwargs, **wrapper_kwargs)
Override this in the DMX modules to enable pre-processing of the inputs, and the SIMD approximator arguments before calling the SIMD reference kernels. wrapper_kwargs are arguments specific to the wrapper and should not be passed to the SIMD reference kernels.
- class dmx.compressor.functional.approximate.Approximator(function=NONE)
Bases:
ModuleEncapsulates approximation forward logic of a module
- approximation_function()
- extra_repr()
Return the extra representation of the module.
To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line strings are acceptable.
- forward(input)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class dmx.compressor.functional.approximate.CustomFunctionApproximation(func_id: None, algorithm: str = 'vsimd', wrapper_params: Dict[str, Any] = {}, extra_params: Dict[str, Any] = {})
Bases:
ApproximationFunctionThis class specifies an approximation function for a custom written torch function.
- execute(*args, **kwargs)
- classmethod from_shorthand(sh: str)
- dmx.compressor.functional.approximate.Identity
alias of
NoApproximation
- class dmx.compressor.functional.approximate.NoApproximation
Bases:
ApproximationFunctionThis is a dummy approximation algorithm that means no approximation.
- execute(*args, **kwargs)
- classmethod from_shorthand(sh: str)
- class dmx.compressor.functional.approximate.TorchFunctionApproximation(func_id: None, algorithm: str = 'vsimd', wrapper_params: Dict[str, Any] = {}, extra_params: Dict[str, Any] = {})
Bases:
ApproximationFunctionThis class specifies an approximation function for a member of torch.nn.functional.
- execute(*args, **kwargs)
- classmethod from_shorthand(sh: str)