hespas.mlir_parser.mlir_parser
Classes
|
A class for parsing MLIR (Multi-Level Intermediate Representation) code. |
- class hespas.mlir_parser.mlir_parser.MLIRParser(*, mlir_string=None, mlir_path=None, mlir_module=None, input_sensitive=False)
Bases:
objectA class for parsing MLIR (Multi-Level Intermediate Representation) code.
- ir_context = None
- conv_dim_number_re = re.compile('stablehlo\\.conv\\s*<\\s*(\\[\\s*([fb01])\\s*,\\s*([fb01])\\s*,\\s*([fb01])\\s*,\\s*([fb01])\\s*\\])\\s*x\\s*(\\[\\s*([io01])\\s*,\\s*([io01])\\s*,\\s*([io01])\\s*,\\s*([io01])\\s*\\])\\s*->\\s*(\\[\)
- window_attr_re = re.compile('window\\s*=\\s*{([^}]*)\\s*}')
- window_sub_attr_re = re.compile('([a-zA-Z_\\-0-9]+)\\s*=\\s*(\\[[^=]+\\])')
- static get_ir_context()
- static get_module(mlir_string, context=None)
- __init__(*, mlir_string=None, mlir_path=None, mlir_module=None, input_sensitive=False)
Initializes the MLIRParser with an MLIR string or file path.
- Args:
mlir_input (str): The MLIR code as a string or the path to an MLIR file. input_sensitive (bool): Consider the inputs as part of the operator while considering uniqueness
- property mlir_string
- property operations
- Extracts operators from the MLIR code using regular expressions.
operation_input: True includes operator inputs in the categorization
- Returns:
list: A list of extracted operators.
- property main_function
Returns the main function in the MLIR module.
- property main_index: int
Returns the index of the main function in the MLIR module. Raises an error if the main function is not found.
- property private_functions: list[Operation]
Returns a list of private functions in the MLIR module.
- get_private_functions_map(funcs=None) dict
- get_private_functions_nx_tree(functions)
- get_private_functions_ops(function)
Returns a list of operations in a private function, including nested calls.
- parse_operation(operation)
- property ops_list
Reads a mlir file or mlir_str, returns a list of <operator_name, inputs and output> tuples
- get_mlir_function_inputs()
Reads an MLIR file and returns a list of function input types.
- get_mlir_function_outputs()
Reads an MLIR file and returns a list of function output types.