dmx.compressor.functional.approximate

Classes

Approximate([function])

An approximation operator container

ApproximationFunction()

This is an abstract class of approximation algorithm.

ApproximationMixin(*args, **kwargs)

Mixin to equip modules with approximated forward logic through Approximator

Approximator([function])

Encapsulates approximation forward logic of a module

CustomFunctionApproximation(func_id[, ...])

This class specifies an approximation function for a custom written torch function.

Identity

alias of NoApproximation

NoApproximation()

This is a dummy approximation algorithm that means no approximation.

TorchFunctionApproximation(func_id[, ...])

This class specifies an approximation function for a member of torch.nn.functional.

class dmx.compressor.functional.approximate.Approximate(function=NONE)

Bases: Module

An 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 Module instance 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: object

This 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: object

Mixin 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: Module

Encapsulates 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 Module instance 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: ApproximationFunction

This 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: ApproximationFunction

This 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: ApproximationFunction

This class specifies an approximation function for a member of torch.nn.functional.

execute(*args, **kwargs)
classmethod from_shorthand(sh: str)