5 from __future__
import annotations
7 from ._om_ops_gen
import *
8 from .._mlir_libs._circt._om
import AnyType, Evaluator
as BaseEvaluator, Object
as BaseObject, List
as BaseList, Tuple
as BaseTuple, Map
as BaseMap, BasePath
as BaseBasePath, BasePathType, Path, PathType, ClassType, ReferenceAttr, ListAttr, ListType, MapAttr, OMIntegerAttr
10 from ..ir
import Attribute, Diagnostic, DiagnosticSeverity, Module, StringAttr, IntegerAttr, IntegerType
11 from ..support
import attribute_to_var, var_to_attribute
15 from dataclasses
import fields
16 from typing
import TYPE_CHECKING, Any, Sequence, TypeVar
19 from _typeshed.stdlib.dataclass
import DataclassInstance
25 if isinstance(value, (int, float, str, bool, tuple, list, dict)):
28 if isinstance(value, BaseList):
31 if isinstance(value, BaseTuple):
34 if isinstance(value, BaseMap):
37 if isinstance(value, BaseBasePath):
40 if isinstance(value, Path):
44 assert isinstance(value, BaseObject)
49 if isinstance(obj, int):
50 return OMIntegerAttr.get(IntegerAttr.get(IntegerType.get_signless(64), obj))
56 if isinstance(value, List):
59 if isinstance(value, Tuple):
62 if isinstance(value, Map):
65 if isinstance(value, BasePath):
68 if isinstance(value, Path):
71 if isinstance(value, Object):
89 for i
in range(0, self.__len__()):
104 for i
in range(0, self.__len__()):
130 for i
in super().
keys():
138 return BasePath(BaseBasePath.get_empty(context))
159 for name
in self.field_names:
160 yield (name, getattr(self, name))
167 """Instantiate an Evaluator with a Module."""
174 format=
"[%(asctime)s] %(name)s (%(levelname)s) %(message)s",
175 datefmt=
"%Y-%m-%d %H:%M:%S",
179 self.
_logger_logger = logging.getLogger(
"Evaluator")
185 """Instantiate an Object with a class name and actual parameters."""
189 with self.module.context:
191 class_name = StringAttr.get(cls)
198 obj = super().
instantiate(class_name, actual_params)
204 """Handle MLIR Diagnostics by logging them."""
207 if diagnostic.severity == DiagnosticSeverity.ERROR:
208 self.
_logger_logger.error(diagnostic.message)
209 elif diagnostic.severity == DiagnosticSeverity.WARNING:
210 self.
_logger_logger.warning(diagnostic.message)
212 self.
_logger_logger.info(diagnostic.message)
215 for note
in diagnostic.notes:
216 self.
_logger_logger.info(str(note))
"BasePath" get_empty(context=None)
None __init__(self, Module mod)
bool _handle_diagnostic(self, Diagnostic diagnostic)
Object instantiate(self, str cls, *Any args)
None __init__(self, BaseList obj)
None __init__(self, BaseMap obj)
def __getitem__(self, key)
None __init__(self, BaseObject obj)
def __getattr__(self, str name)
def get_field_loc(self, str name)
None __init__(self, BaseTuple obj)
ir.Attribute var_to_attribute(obj, bool none_on_fail=False)
def wrap_mlir_object(value)
def unwrap_python_object(value)
ir.Attrbute om_var_to_attribute(obj, bool none_on_fail=False)