Analysis#
Wrapping existing analysis utils.
- tvm_tirx.tirx.analysis.analysis.verify_memory(func: Function) bool#
Verify if func contains illegal host side direct memory access.
- Parameters:
func (tvm_tirx.tirx.Function) – The module to be verified.
- Returns:
result – The result of verification.
- Return type:
- tvm_tirx.tirx.analysis.analysis.undefined_vars(node: Stmt | Expr, defs: list[Var] | None = None) list[Var]#
Find undefined vars in a TIR statement or expression.
- tvm_tirx.tirx.analysis.analysis.check_well_formed(obj: Function | IRModule, assert_mode: bool = True) bool#
Check whether a TIRx function is well formed.
- Parameters:
obj (Union[tvm_tirx.tirx.Function, tvm_tirx.ir.IRModule]) – The function or module to be verified.
assert_mode (bool) – Whether to raise on invalid IR. Defaults to True.
- Returns:
result – True for valid IR; False for invalid IR when assert_mode is False.
- Return type:
- Raises:
RuntimeError – If the IR is invalid and assert_mode is True.
- tvm_tirx.tirx.analysis.analysis.detect_linear_equation(expr, var_list)#
Match expr = sum_{i=0}^{n-1} var[i] * coeff[i] + coeff[n]
Where coeff[i] and base are invariant of var[j] for all i and j.
- Parameters:
expr (Expr) – The expression to be matched.
var_list (List[tvm_tirx.ir.Var]) – A list of variables.
- Returns:
coeff – A list of co-efficients if the match is successful. An empty list if the match failed.
- Return type:
List[Expr]
- tvm_tirx.tirx.analysis.analysis.detect_clip_bound(expr, var_list)#
Detect if expression corresponds to clip bound of the vars
- Parameters:
expr (Expr) – The expression to be matched.
var_list (List[tvm_tirx.ir.Var]) – A list of variables.
- Returns:
coeff – concat([min_value[i], max_value[i]] for i, v in enumerate(var_list)) An empty list if the match failed.
- Return type:
List[Expr]