Extensible components¶
- Approximators
- ErrorMetrics
Approximators¶
Approximators (or ApproxMethod
instances) are service providers for the Approximation component. Each class represents a specific approach to generate approximated circuits based on quality constraints, e.g., precision scaling. Each instance, however, may implement the approach differently based on the configuration options of that approach.
When the CandidateSet
is generated, ApproxMethod
instances are generated for each approximation method assigned to it. During the approximation process, the candidate’s variants are created by these instances.
Some approximation methods may be incompatible with certain error metrics or combinations of those. To compensate for this, approximators may adjust a variant’s configuration of error metrics and bounds in a way that it can be approximated without lowering its error bounds or exceeding their maximum bounds.
Functions¶
__init__(id: String, settings: Dictionary)
¶
For identification and also representation of approximation methods, each
ApproxMethod
must have a unique class-level ID. The ID should not be too long (2-5 characters) for better readability of circuit configurations and log messages.The
settings
dictionary can be used to specify the approximator’s mode of operation more precisely. You can define the parameters freely and then use the configuration file of the approximation process to specify the options to be used.
approximateVariant(variant: Variant, gen_info: GeneralInformation): None
¶
The
approximateVariant
method provides the main functionality of the approximator. It takes aVariant
instance as a parameter, generates its approximated circuit and stores it, e.g., in the Verilog and/or the Blif format. The file paths are specified in theVariant
itself and the circuit from which to start the approximation is the original variant of the candidate the new variant corresponds to.A variant is unique, i.e., this method is only called if no variant with the same error metrics and approximation method as
variant
has been generated before; otherwise, the variant can be loaded from the variant set.
applyRules(variant: Variant): Boolean
¶
The
applyRules
method is used to ensure that aVariant
’s configuration of error metrics and bounds is compatible with its approximation method, represented by theApproxMethod
instance on which this method is called. It is allowed to increase error bounds of the variant, but not to exceed the maximum bound of an error metric. Error bounds can also be ignored for certain approximation methods, but you should definitely at least generate warning messages if you do so.The method should return
True
if the variant was successfully adjusted to the approximator’s set of rules, andFalse
otherwise. Typically, aFalse
means that the variant is not considered in the approximation process.
__repr__(): String
¶
TheApproxMethod
class provides a__repr__
method for a human-readable representation of the approximation method. In most cases, the default implementation (which outputs the class name and the instance’s settings if present) should suffice.