hwcomponents package

Subpackages

Submodules

hwcomponents.find_models module

hwcomponents.find_models.get_models(*paths_or_packages_or_models, include_installed=True, name_must_include='', _return_wrappers=False)[source]

Instantiate a list of model objects for later queries. Searches for models in the given paths and packages.

Parameters:
  • paths_or_packages_or_models (list) – A list of paths or packages to search for models.

  • include_installed (bool) – Whether to include models from installed packages.

  • name_must_include (str) – If provided, a model will only be returned if its name includes this string. Non-case-sensitive.

  • _return_wrappers (bool) – Whether to return ComponentModelWrapper objects or ComponentModel objects.

Return type:

Union[List[ComponentModelWrapper], List[ComponentModel]]

Returns:

A list of ComponentModelWrapper objects or ComponentModel objects.

hwcomponents.find_models.get_models_in_module(module, model_ids, _return_wrappers=False)[source]

Finds all ComponentModel subclasses in a module and returns them as ComponentModelWrapper objects. Ignores underscore-prefixed classes.

Parameters:
  • model_ids (set) – A set of model IDs to avoid duplicates.

  • _return_wrappers (bool) – Whether to return ComponentModelWrapper objects or ComponentModel objects.

Return type:

Union[List[ComponentModelWrapper], List[ComponentModel]]

Returns:

A list of ComponentModelWrapper objects.

hwcomponents.find_models.installed_models(_return_wrappers=False)[source]

Lists all Python packages installed that are prefixed with “hwcomponents_”. Finds ComponentModel subclasses in these packages and returns them as ComponentModel or ComponentModelWrapper objects.

Parameters:

_return_wrappers (bool) – Whether to return ComponentModelWrapper objects or ComponentModel objects.

Return type:

Union[List[ComponentModelWrapper], List[ComponentModel]]

Returns:

A list of ComponentModel or ComponentModelWrapper objects.

hwcomponents.hwcomponents module

hwcomponents.hwcomponents.list_components(printfunc=print)[source]

Lists all available components.

Parameters:

printfunc (Callable[[str], None]) – The function to use to print the components.

Returns:

None

hwcomponents.model module

class hwcomponents.model.ComponentModel[source]

Bases: ListLoggable, ABC

ComponentModel base class. ComponentModel class must have “name” attribute, “priority” attribute, and “get_area” method. ComponentModels may have any number of methods that are decorated with @action.

Parameters:
  • component_name (str | list[str] | None) – The name of the component. Must be a string or list/tuple of strings. Can be omitted if the component name is the same as the class name.

  • priority (float) – The priority of the model. Higher priority models are used first. Must be a number between 0 and 1.

  • leak_power (float | None) – The leakage power of the component in Watts. Must be set if subcomponents is not set.

  • area (float | None) – The area of the component in m^2. Must be set if subcomponents is not set.

  • energy_scale (float) – A scale factor for the energy. All calls to @action will be scaled by this factor.

  • area_scale (float) – A scale factor for the area. All calls to area will be scaled by this factor.

  • latency_scale (float) – A scale factor for the latency. All calls to @action will be scaled by this factor.

  • leak_power_scale (float) – A scale factor for the leakage power. All calls to leak_power will be scaled by this factor.

  • subcomponents (list[ComponentModel] | None) – A list of subcomponents. If set, the area and leak power of the subcomponents will be added to the area and leak power of the component. All calls to @action functions will be added to the energy and latency of the component if they occur during one of the component’s actions. The area, energy, latency, and leak power of subcomponents WILL NOT BE scaled by the component’s energy_scale, area_scale, or leak_power_scale; if you want to scale the subcomponents, multiply their energy_scale, area_scale, latency_scale, or leak_power_scale by the desired scale factor.

Variables:
  • component_name (The name of the component. Must be a string or list/tuple of) – strings. Can be omitted if the component name is the same as the class name.

  • priority (The priority of the model. Higher priority models are used first.) – Must be a number between 0 and 1.

  • energy_scale (A scale factor for the energy. All calls to action) – will be scaled by this factor.

  • area_scale (A scale factor for the area. All calls to area) – will be scaled by this factor.

  • latency_scale (A scale factor for the latency. All calls to @action) – will be scaled by this factor.

  • leak_power_scale (A scale factor for the leakage power. All calls to leak_power) – will be scaled by this factor.

  • subcomponents (A list of subcomponents. If set, the area and leak power of the) – subcomponents will be added to the area and leak power of the component. All calls to @action functions will be added to the energy and latency of the component if they occur during one of the component’s actions. The area, energy, latency, and leak power of subcomponents WILL NOT BE scaled by the component’s energy_scale, area_scale, or leak_power_scale; if you want to scale the subcomponents, multiply their energy_scale, area_scale, latency_scale, or leak_power_scale by the desired scale factor.

abstractmethod __init__(leak_power=None, area=None, subcomponents=None)[source]
property area: Number

Returns the area in m^2 of the component.

Return type:

The area in m^2 of the component.

assert_int(name, value)[source]

Checks that the value is an integer, and if so, returns it as an integer. Otherwise, raises a ValueError.

Parameters:
  • name (str) – The name of the attribute to check. Used for error messages.

  • value (int | float | Any) – The value to check.

Return type:

int

Returns:

int

The value as an integer.

assert_match(value_a, value_b, name_a, name_b)[source]

Checks that the two values are equal, and if so, returns the matched value. If one value is None, returns the other value. Raise an error if the two values are not equal, or if both are None.

Parameters:
  • value_a (int | float | Any) – The first value to check.

  • value_b (int | float | Any) – The second value to check.

  • name_a (str) – The name of the first value. Used for error messages.

  • name_b (str) – The name of the second value. Used for error messages.

Return type:

int

Returns:

int

The matched value.

component_name: str | List[str] | None = None

Name of the component. Must be a string or list/tuple of strings. Can be omitted if the component name is the same as the class name.

classmethod get_action_names()[source]

Returns the names of the actions supported by the model.

Returns:

The names of the actions supported by the model.

Return type:

List[str]

get_log_messages()[source]

Returns the log messages for the component.

Return type:

List[str]

Returns:

List[str]

The log messages for the component.

property leak_power: Number

Returns the leakage power of the component in Watts.

Return type:

The leakage power in Watts.

pop_log_messages()[source]

Pops the log messages for the component.

Return type:

List[str]

Returns:

List[str]

The log messages for the component.

priority: Number = None

Priority determines which model is used when multiple models are available for a given component. Higher priority models are used first. Must be a number between 0 and 1.

required_arguments(action_name=None)[source]

Returns the required arguments for the given action. If no action is given, returns the required arguments for the __init__ method.

Parameters:

action_name (str | None) – The name of the action to get the required arguments for. If None, returns the required arguments for the __init__ method.

Return type:

List[str]

Returns:

list[str]

The required arguments for the given action.

resolve_multiple_ways_to_calculate_value(name, *args)[source]

Parses multiple possible ways to set an attribute, raising errors if the values are not consistent.

Each possible argument is a tuple containing a function and a dictionary of keyword arguments. A function fails if any keyword arguments are None, if the function raises an error, or if the function returns None.

The outputs of all non-failing functions are compared, and an error is raised if they are not equal.

Parameters:
  • name (str) – The name of the attribute to set.

  • *args (tuple[str, Callable[[Any], Any], dict[str, Any]]) – The possible ways to set the attribute. Each tuple contains a name, a function that takes the current value and returns the new value, and a dictionary of keyword arguments to pass to the function.

Return type:

Any

Returns:

The value of the attribute.

scale(key, target, default, area_scale_function=None, energy_scale_function=None, latency_scale_function=None, leak_power_scale_function=None)[source]

Scales this model’s area, energy, latency, and leak power to the given target.

Parameters:
  • key (str) – The name of the parameter to scale. Used for logging.

  • target (float) – The target value of the parameter. The value is scaled to this from the default.

  • default (float) – The default value of the parameter. The value is scaled to the target from this.

  • area_scale_function (Callable[[float, float], float]) – The function to use to scale the area. None if no scaling should be done.

  • energy_scale_function (Callable[[float, float], float]) – The function to use to scale the energy. None if no scaling should be done.

  • latency_scale_function (Callable[[float, float], float]) – The function to use to scale the latency. None if no scaling should be done.

  • leak_power_scale_function (Callable[[float, float], float]) – The function to use to scale the leak power. None if no scaling should be done.

Return type:

float

try_call_arbitrary_action(action_name, _return_estimation_object=False, **kwargs)[source]

Tries to call the given action with the given arguments.

Parameters:
  • action_name (str) – The name of the action to call.

  • **kwargs (dict) – The arguments with which to call the action.

Return type:

TypeVar(T, bound= ComponentModel)

classmethod try_init_arbitrary_args(_return_estimation_object=False, **kwargs)[source]

Tries to initialize the model with the given arguments.

Parameters:
  • **kwargs (dict) – The arguments with which to initialize the model.

  • _return_estimation_object (bool) – Whether to return the Estimation object instead of the model.

Return type:

TypeVar(T, bound= ComponentModel)

Returns:

The initialized model. If the model cannot be initialized with the given arguments, an exception is raised.

class hwcomponents.model.EnergyLatency[source]

Bases: NamedTuple

EnergyLatency(energy, latency)

static __new__(_cls, energy: float, latency: float)

Create new instance of EnergyLatency(energy, latency)

energy: float

Alias for field number 0

latency: float

Alias for field number 1

hwcomponents.model.action(func=None, bits_per_action=None, pipelined_subcomponents=False)[source]

Decorator that adds an action to an energy/area model. If the component has no subcomponents, then the action is expected to return a tuple of (energy, latency) where energy is in Joules and latency is in seconds. If the component has subcomponents, then None return values are assumed to be (0, 0), and subcomponent actions that occur during the component’s action will be added to the component’s energy and latency. The energy and latency of the subcomponents will NOT be scaled by the component’s energy_scale and latency_scale; to scale these, set the subcomponents’ scaling factors directly.

Parameters:
  • func (Callable | None) – The function to decorate.

  • bits_per_action (str) – The attribute of the model that contains the number of bits per action. If this is set and a bits_per_action is passed to the function, the energy and latency will be scaled by the number of bits. For example, if bits_per_action is set to “width”, the function is called with bits_per_action=10, and the model has a width attribute of 5, then the energy and latency will be scaled by 2.

  • pipelined_subcomponents (bool) – Whether the subcomponents are pipelined. If True, then the latency of is the max of the latency returned and all subcomponent latencies. Otherwise, it is the sum. Does nothing if there are no subcomponents.

Return type:

Callable[..., EnergyLatency]

Returns:

The decorated function.

hwcomponents.select_models module

hwcomponents.select_models.get_area(component_name, component_attributes, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the area using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the area value.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The area in m^2.

hwcomponents.select_models.get_energy(component_name, component_attributes, action_name, action_arguments, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the energy using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes and a matching action with all required arguments specified in action_arguments.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • action_name (The name of the action.)

  • action_arguments (The arguments of the action.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the energy value.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The energy in Joules.

hwcomponents.select_models.get_latency(component_name, component_attributes, action_name, action_arguments, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the latency using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes and a matching action with all required arguments specified in action_arguments.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • action_name (The name of the action.)

  • action_arguments (The arguments of the action.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the latency value.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The latency in seconds.

hwcomponents.select_models.get_leak_power(component_name, component_attributes, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the leak power using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • models (The models to use.)

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The leak power in Watts.

hwcomponents.select_models.get_model(component_name, component_attributes, required_actions=(), models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the best model for the given component. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes, and has actions for all of required_actions.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • required_actions (The actions that are required for the component.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the model wrapper.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

ComponentModelWrapper

Returns:

The best model wrapper.

Module contents

class hwcomponents.ComponentModel[source]

Bases: ListLoggable, ABC

ComponentModel base class. ComponentModel class must have “name” attribute, “priority” attribute, and “get_area” method. ComponentModels may have any number of methods that are decorated with @action.

Parameters:
  • component_name (str | list[str] | None) – The name of the component. Must be a string or list/tuple of strings. Can be omitted if the component name is the same as the class name.

  • priority (float) – The priority of the model. Higher priority models are used first. Must be a number between 0 and 1.

  • leak_power (float | None) – The leakage power of the component in Watts. Must be set if subcomponents is not set.

  • area (float | None) – The area of the component in m^2. Must be set if subcomponents is not set.

  • energy_scale (float) – A scale factor for the energy. All calls to @action will be scaled by this factor.

  • area_scale (float) – A scale factor for the area. All calls to area will be scaled by this factor.

  • latency_scale (float) – A scale factor for the latency. All calls to @action will be scaled by this factor.

  • leak_power_scale (float) – A scale factor for the leakage power. All calls to leak_power will be scaled by this factor.

  • subcomponents (list[ComponentModel] | None) – A list of subcomponents. If set, the area and leak power of the subcomponents will be added to the area and leak power of the component. All calls to @action functions will be added to the energy and latency of the component if they occur during one of the component’s actions. The area, energy, latency, and leak power of subcomponents WILL NOT BE scaled by the component’s energy_scale, area_scale, or leak_power_scale; if you want to scale the subcomponents, multiply their energy_scale, area_scale, latency_scale, or leak_power_scale by the desired scale factor.

Variables:
  • component_name (The name of the component. Must be a string or list/tuple of) – strings. Can be omitted if the component name is the same as the class name.

  • priority (The priority of the model. Higher priority models are used first.) – Must be a number between 0 and 1.

  • energy_scale (A scale factor for the energy. All calls to action) – will be scaled by this factor.

  • area_scale (A scale factor for the area. All calls to area) – will be scaled by this factor.

  • latency_scale (A scale factor for the latency. All calls to @action) – will be scaled by this factor.

  • leak_power_scale (A scale factor for the leakage power. All calls to leak_power) – will be scaled by this factor.

  • subcomponents (A list of subcomponents. If set, the area and leak power of the) – subcomponents will be added to the area and leak power of the component. All calls to @action functions will be added to the energy and latency of the component if they occur during one of the component’s actions. The area, energy, latency, and leak power of subcomponents WILL NOT BE scaled by the component’s energy_scale, area_scale, or leak_power_scale; if you want to scale the subcomponents, multiply their energy_scale, area_scale, latency_scale, or leak_power_scale by the desired scale factor.

abstractmethod __init__(leak_power=None, area=None, subcomponents=None)[source]
property area: Number

Returns the area in m^2 of the component.

Return type:

The area in m^2 of the component.

area_scale: float
assert_int(name, value)[source]

Checks that the value is an integer, and if so, returns it as an integer. Otherwise, raises a ValueError.

Parameters:
  • name (str) – The name of the attribute to check. Used for error messages.

  • value (int | float | Any) – The value to check.

Return type:

int

Returns:

int

The value as an integer.

assert_match(value_a, value_b, name_a, name_b)[source]

Checks that the two values are equal, and if so, returns the matched value. If one value is None, returns the other value. Raise an error if the two values are not equal, or if both are None.

Parameters:
  • value_a (int | float | Any) – The first value to check.

  • value_b (int | float | Any) – The second value to check.

  • name_a (str) – The name of the first value. Used for error messages.

  • name_b (str) – The name of the second value. Used for error messages.

Return type:

int

Returns:

int

The matched value.

component_name: str | List[str] | None = None

Name of the component. Must be a string or list/tuple of strings. Can be omitted if the component name is the same as the class name.

energy_scale: float
classmethod get_action_names()[source]

Returns the names of the actions supported by the model.

Returns:

The names of the actions supported by the model.

Return type:

List[str]

get_log_messages()[source]

Returns the log messages for the component.

Return type:

List[str]

Returns:

List[str]

The log messages for the component.

latency_scale: float
property leak_power: Number

Returns the leakage power of the component in Watts.

Return type:

The leakage power in Watts.

leak_power_scale: float
pop_log_messages()[source]

Pops the log messages for the component.

Return type:

List[str]

Returns:

List[str]

The log messages for the component.

priority: Number = None

Priority determines which model is used when multiple models are available for a given component. Higher priority models are used first. Must be a number between 0 and 1.

required_arguments(action_name=None)[source]

Returns the required arguments for the given action. If no action is given, returns the required arguments for the __init__ method.

Parameters:

action_name (str | None) – The name of the action to get the required arguments for. If None, returns the required arguments for the __init__ method.

Return type:

List[str]

Returns:

list[str]

The required arguments for the given action.

resolve_multiple_ways_to_calculate_value(name, *args)[source]

Parses multiple possible ways to set an attribute, raising errors if the values are not consistent.

Each possible argument is a tuple containing a function and a dictionary of keyword arguments. A function fails if any keyword arguments are None, if the function raises an error, or if the function returns None.

The outputs of all non-failing functions are compared, and an error is raised if they are not equal.

Parameters:
  • name (str) – The name of the attribute to set.

  • *args (tuple[str, Callable[[Any], Any], dict[str, Any]]) – The possible ways to set the attribute. Each tuple contains a name, a function that takes the current value and returns the new value, and a dictionary of keyword arguments to pass to the function.

Return type:

Any

Returns:

The value of the attribute.

scale(key, target, default, area_scale_function=None, energy_scale_function=None, latency_scale_function=None, leak_power_scale_function=None)[source]

Scales this model’s area, energy, latency, and leak power to the given target.

Parameters:
  • key (str) – The name of the parameter to scale. Used for logging.

  • target (float) – The target value of the parameter. The value is scaled to this from the default.

  • default (float) – The default value of the parameter. The value is scaled to the target from this.

  • area_scale_function (Callable[[float, float], float]) – The function to use to scale the area. None if no scaling should be done.

  • energy_scale_function (Callable[[float, float], float]) – The function to use to scale the energy. None if no scaling should be done.

  • latency_scale_function (Callable[[float, float], float]) – The function to use to scale the latency. None if no scaling should be done.

  • leak_power_scale_function (Callable[[float, float], float]) – The function to use to scale the leak power. None if no scaling should be done.

Return type:

float

subcomponents: list[ComponentModel]
try_call_arbitrary_action(action_name, _return_estimation_object=False, **kwargs)[source]

Tries to call the given action with the given arguments.

Parameters:
  • action_name (str) – The name of the action to call.

  • **kwargs (dict) – The arguments with which to call the action.

Return type:

TypeVar(T, bound= ComponentModel)

classmethod try_init_arbitrary_args(_return_estimation_object=False, **kwargs)[source]

Tries to initialize the model with the given arguments.

Parameters:
  • **kwargs (dict) – The arguments with which to initialize the model.

  • _return_estimation_object (bool) – Whether to return the Estimation object instead of the model.

Return type:

TypeVar(T, bound= ComponentModel)

Returns:

The initialized model. If the model cannot be initialized with the given arguments, an exception is raised.

class hwcomponents.EnergyLatency[source]

Bases: NamedTuple

EnergyLatency(energy, latency)

static __new__(_cls, energy: float, latency: float)

Create new instance of EnergyLatency(energy, latency)

energy: float

Alias for field number 0

latency: float

Alias for field number 1

hwcomponents.action(func=None, bits_per_action=None, pipelined_subcomponents=False)[source]

Decorator that adds an action to an energy/area model. If the component has no subcomponents, then the action is expected to return a tuple of (energy, latency) where energy is in Joules and latency is in seconds. If the component has subcomponents, then None return values are assumed to be (0, 0), and subcomponent actions that occur during the component’s action will be added to the component’s energy and latency. The energy and latency of the subcomponents will NOT be scaled by the component’s energy_scale and latency_scale; to scale these, set the subcomponents’ scaling factors directly.

Parameters:
  • func (Callable | None) – The function to decorate.

  • bits_per_action (str) – The attribute of the model that contains the number of bits per action. If this is set and a bits_per_action is passed to the function, the energy and latency will be scaled by the number of bits. For example, if bits_per_action is set to “width”, the function is called with bits_per_action=10, and the model has a width attribute of 5, then the energy and latency will be scaled by 2.

  • pipelined_subcomponents (bool) – Whether the subcomponents are pipelined. If True, then the latency of is the max of the latency returned and all subcomponent latencies. Otherwise, it is the sum. Does nothing if there are no subcomponents.

Return type:

Callable[..., EnergyLatency]

Returns:

The decorated function.

hwcomponents.get_area(component_name, component_attributes, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the area using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the area value.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The area in m^2.

hwcomponents.get_energy(component_name, component_attributes, action_name, action_arguments, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the energy using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes and a matching action with all required arguments specified in action_arguments.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • action_name (The name of the action.)

  • action_arguments (The arguments of the action.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the energy value.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The energy in Joules.

hwcomponents.get_latency(component_name, component_attributes, action_name, action_arguments, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the latency using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes and a matching action with all required arguments specified in action_arguments.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • action_name (The name of the action.)

  • action_arguments (The arguments of the action.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the latency value.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The latency in seconds.

hwcomponents.get_leak_power(component_name, component_attributes, models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the leak power using the best-matching model. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • models (The models to use.)

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

float | Estimation

Returns:

The leak power in Watts.

hwcomponents.get_model(component_name, component_attributes, required_actions=(), models=None, _return_estimation_object=False, _relaxed_component_name_selection=False)[source]

Finds the best model for the given component. “Best” is defined as the highest-priority model that has all required attributes specified in component_attributes, and has actions for all of required_actions.

Parameters:
  • component_name (The name of the component.)

  • component_attributes (The attributes of the component.)

  • required_actions (The actions that are required for the component.)

  • models (The models to use.)

  • _return_estimation_object (Whether to return the estimation object instead of) – the model wrapper.

  • _relaxed_component_name_selection (Whether to relax the component name) – selection. Relaxed selection ignores underscores in the component name.

Return type:

ComponentModelWrapper

Returns:

The best model wrapper.

hwcomponents.get_models(*paths_or_packages_or_models, include_installed=True, name_must_include='', _return_wrappers=False)[source]

Instantiate a list of model objects for later queries. Searches for models in the given paths and packages.

Parameters:
  • paths_or_packages_or_models (list) – A list of paths or packages to search for models.

  • include_installed (bool) – Whether to include models from installed packages.

  • name_must_include (str) – If provided, a model will only be returned if its name includes this string. Non-case-sensitive.

  • _return_wrappers (bool) – Whether to return ComponentModelWrapper objects or ComponentModel objects.

Return type:

Union[List[ComponentModelWrapper], List[ComponentModel]]

Returns:

A list of ComponentModelWrapper objects or ComponentModel objects.