approximation.approx_method_aig module

class approximation.approx_method_aig.ApproximatorAIG(settings=None)

Bases: circa.stages.approximation.approx_method.ApproxMethod

static methodId()

Returns this ApproxMethod’s unique ID string.

approximateVariant(variant, gen_info)

Generates approximated variant and stores it in a file.

  • variant (Variant) – The Variant instance to be approximated.
  • gen_info (GeneralInformation) – The framework’s GeneralInformation instance.

Checks if the given Variant’s error bounds are consistent with this ApproxMethod’s set of rules and adjusts them accordingly if not. Error bounds must not be decreased in order to avoid infinite loops and redundant steps in Variant generation.

Parameters:variant (Variant) – The Variant to apply the rules to.
Returns:True if the rules have been applied correctly and the Variant has a valid configuration afterwards, False if the rules could not be applied.
Return type:bool

Exchanges regexes by information gathered from candidate.

_prepareWcQc(msb_0, lsb_1, msb_1, error_wc, is_signed, mod_suffix='')

Loads template for worst-case QC and parses regexes.

_prepareRelErrQc(msb_0, lsb_1, msb_1, lower_bound, upper_bound, mod_suffix='')

Loads template for relative error QC and parses regexes.

_prepareBitFlipErrQc(msb_0, lsb_1, msb_1, max_bit_flip, mod_suffix='')

Loads template for bit flip error QC and parses regexes.

_findAndReplace(file, repl_pairs)

Replaces all occurrences of key with repl for every (key, repl) pair in repl_pairs in each line of the given file and returns lines as string.

  • file (file handle) – The file in which to find and replace the
  • pairs of strings. (given) –
  • repl_pairs (list of tuple (str, str)) – A list of string tuples
  • replace) specifying which strings ((find,) –
  • which other strings (with) –

A string containing the content of the given file after all replacements.

Return type: