hespas.estimator.result
Classes
|
Class representing the final result of estimation for the entire MLIR module, including statistics. |
|
Class representing the result of estimation for the entire MLIR module, whether per-operator or using the whole module behaviour. |
|
Class representing a per-operator estimation result. |
|
Base class for all results. |
- class hespas.estimator.result.Result(success: bool, runtime_estimate: float | None, metadata: dict[str, Any] | None)
Bases:
SerialisableBase class for all results. Contains common fields that all Results classes share, as well as adding the serialisation/deserialisation functionality through Serialisable.
Result classes define the common container classes for the Estimators to use for the results of estimation runs. These are all serialisable, and can be loaded from JSON. This is used in the implementation of estimator caching. These classes are important to the user as depending on the type of Estimator behaviour used, either OpResult or ModuleResult should be returned from the implemention. If the whole module behaviour is used, with no op handlers registered, the new _get_whole_module_result() method should return a ModuleResult. If the per-op behaviour is used, each registered op handler should return an OpResult. This is also the container class passed into any registered post-op hooks. EstimatorResult is returned from the public ‘get_estimate()’ Estimator interface, as well as passed into any registered post_run and post_estimate hooks. Users should not have to constructor EstimatorResults themselves, as they are generated within the base class from the returned ModuleResult or OpResult objects in the descended implementation.
- Parameters:
success – A bool representing if this estimation has completed successfully or not.
runtime_estimate – A time representing the estimated runtime for this estimate if successful, otherwise None.
metadata – A (possibly empty) dict containing metadata specific to this estimation.
- success: bool
- runtime_estimate: float | None
- metadata: dict[str, Any] | None
- __init__(success: bool, runtime_estimate: float | None, metadata: dict[str, Any] | None) None
- class hespas.estimator.result.OpResult(success: bool, runtime_estimate: float | None, metadata: dict[str, Any] | None, op_info: OpInfo)
Bases:
ResultClass representing a per-operator estimation result. Contains the op_info that represents the operator that this estimation was created for, as well as the basic Result fields.
- Parameters:
success – A bool representing if this estimation has completed successfully or not.
runtime_estimate – A time representing the estimated runtime for this estimate if successful, otherwise None.
metadata – A (possibly empty) dict containing metadata specific to this estimation.
op_info – An OpInfo object representing the operator this estimation was produced for
- class hespas.estimator.result.ModuleResult(success: bool, runtime_estimate: float | None, metadata: dict[str, Any] | None, module: MLIRModule)
Bases:
ResultClass representing the result of estimation for the entire MLIR module, whether per-operator or using the whole module behaviour. When using the whole module behaviour, an object of this class should be directly returned from the new _get_whole_module_result() method. If using the per-op behaviour, an object of this class is instantiated by the Estimator base class using the from_op_results() class method and a list of returned OpResults. Contains the base Result fields, as well as the module this estimation was produced for.
- Parameters:
success – A bool representing if this estimation has completed successfully or not.
runtime_estimate – A time representing the estimated runtime for this estimate if successful, otherwise None.
metadata – A (possibly empty) dict containing metadata specific to this estimation.
module – An MLIRModule object representing the MLIR module this estimation was produced for
- module: MLIRModule
- classmethod from_op_results(op_results: [<class 'hespas.estimator.result.OpResult'>], module: ~hespas.mlir_parser.mlir_module.MLIRModule, strict: bool = False) ModuleResult
This class method is used by the base Estimator class to generate a ModuleResult from a list of OpResults when using the per-op behaviour. It should not be called by users, rather if using the per-op behaviour, op handler methods should be registered as detailed in the Estimator documentation.
- Parameters:
op_results – List of OpResult objects to sum together to get the result for this module
module – The module the OpResult estimations were generated for
strict – If true, set that the entire module estimation failed if some of the operator estimations, rather than all.
- Returns:
ModuleResult representing the estimation of the whole module from the list the per-op estimations
- __init__(success: bool, runtime_estimate: float | None, metadata: dict[str, Any] | None, module: MLIRModule) None
- class hespas.estimator.result.EstimatorResult(success: bool, runtime_estimate: float | None, metadata: dict[str, Any] | None, module_file: str | Path, module_idx: int, statistics: dict[str, Any] | None)
Bases:
ResultClass representing the final result of estimation for the entire MLIR module, including statistics. This class should not be instantiated directly, but rather will be generated from the ModuleResult that is either returned from the _get_whole_module_result() method if the whole module behaviour is used, or the ModuleResult that is creating using from_op_results() and the list of OpResults returned from the registed op handlers. Objects of this class are passed into the post-run and post-estimate hooks, allowing inspection of the results of an estimation after it occurs. It is also the type of the object used in the cache to store cached estimation results, and the type of object that the public ‘get_estimate()’ returns when called on an Estimator. Contains the base Result fields, as well as the module_file and module_idx for the module this estimation was produced for. It also contains a dict for holding the statistics of this specific estimation. When the EstimatorResult is produced from a ModuleResult in an Estimator, the module_statistics and module_metadata hooks are called to directly populate the statistics and metadata fields respectively.
- Parameters:
success – A bool representing if this estimation has completed successfully or not.
runtime_estimate – A time representing the estimated runtime for this estimate if successful, otherwise None.
metadata – A (possibly empty) dict containing metadata specific to this estimation.
module_file – The MLIR module file this estimation was produced for
module_idx – The id of the MLIR module this estimation was produced for
- module_file: str | Path
- module_idx: int
- statistics: dict[str, Any] | None
- classmethod from_module_result(module_result: ModuleResult, metadata: dict[str, Any] | None, statistics: dict[str, Any] | None) EstimatorResult
This class method is used within the Estimator class to generate an EstimatorResult from a ModuleResult that is returned either by the _get_whole_module_result() method when using the whole module Estimator behaviour, or by ModuleResult.from_op_results() when using the per-op behaviour. In gerneral, this should not be called by users; rather the standard Estimator behaviours should be used.
- Parameters:
module_result – A ModuleResult representing the estimation for this module
metadata – A possibly empty dict containing metadata specific to this estimation
statistics – A possibly empty dict containing statistics specific to this estimation
- Returns:
An EstimatorResult representing the produced estimation, its metadata, and its statistics.
- __init__(success: bool, runtime_estimate: float | None, metadata: dict[str, Any] | None, module_file: str | Path, module_idx: int, statistics: dict[str, Any] | None) None