get_cost_cache#
View source on GitHub
|
Build a cache of cost values for the bloq and its callees.
qualtran.resource_counting.get_cost_cache(
bloq: 'Bloq',
cost_key: CostKey[CostValT],
costs_cache: Optional[Dict['Bloq', CostValT]] = None,
generalizer: Optional[Union['GeneralizerT', Sequence['GeneralizerT']]] = None
) -> Dict['Bloq', CostValT]
This can be useful to inspect how callees’ costs flow upwards in a given cost computation.
Args
bloqThe bloq to seed the cost computation.
cost_keyA CostKey that specifies which cost to compute.
costs_cacheIf provided, use this dictionary for initial cached cost values. Values in this dictionary will be preferred over computed values (even if they disagree). This dictionary will be mutated by the function. This dictionary will be returned by the function.
generalizerIf provided, run this function on each bloq in the call graph to dynamically modify attributes. If the function returns
None, the bloq is ignored in the cost computation. If a sequence of generalizers is provided, each generalizer will be run in order.
View source on GitHub