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.
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.
__init__(id: String, settings: Dictionary)¶
For identification and also representation of approximation methods, each
ApproxMethodmust 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.
settingsdictionary 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¶
approximateVariantmethod provides the main functionality of the approximator. It takes a
Variantinstance 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 the
Variantitself 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
varianthas been generated before; otherwise, the variant can be loaded from the variant set.
applyRules(variant: Variant): Boolean¶
applyRulesmethod is used to ensure that a
Variant’s configuration of error metrics and bounds is compatible with its approximation method, represented by the
ApproxMethodinstance 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
Trueif the variant was successfully adjusted to the approximator’s set of rules, and
Falseotherwise. Typically, a
Falsemeans that the variant is not considered in the approximation process.
ApproxMethodclass 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.