mirror of
https://github.com/intel/llvm.git
synced 2026-02-05 22:17:23 +08:00
[mlir][transform][structured][python] Allow str arg in match_op_names.
Allow the `names` argument in `MatchOp.match_op_names` to be of type `str` in addition to `Sequence[str]`. In this case, the argument is treated as a list with one name, i.e., it is possible to write `MatchOp.match_op_names(..., "test.dummy")` instead of `MatchOp.match_op_names(..., ["test.dummy"])`. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D155807
This commit is contained in:
@@ -195,7 +195,7 @@ class MatchOp:
|
||||
def match_op_names(
|
||||
cls,
|
||||
target: Union[Operation, Value],
|
||||
names: Sequence[str],
|
||||
names: Union[str, Sequence[str]],
|
||||
*,
|
||||
loc=None,
|
||||
ip=None,
|
||||
@@ -208,7 +208,7 @@ class MatchOp:
|
||||
cls,
|
||||
result_type: Type,
|
||||
target: Union[Operation, Value],
|
||||
names: Sequence[str],
|
||||
names: Union[str, Sequence[str]],
|
||||
*,
|
||||
loc=None,
|
||||
ip=None,
|
||||
@@ -219,8 +219,8 @@ class MatchOp:
|
||||
def match_op_names(
|
||||
cls,
|
||||
result_type_or_target: Union[Type, Operation, Value],
|
||||
target_or_names: Union[Operation, Value, Sequence[str]],
|
||||
names_or_none: Optional[Sequence[str]] = None,
|
||||
target_or_names: Union[Operation, Value, Sequence[str], str],
|
||||
names_or_none: Optional[Union[Sequence[str], str]] = None,
|
||||
*,
|
||||
loc=None,
|
||||
ip=None,
|
||||
@@ -234,6 +234,9 @@ class MatchOp:
|
||||
target = result_type_or_target
|
||||
names = target_or_names
|
||||
|
||||
if isinstance(names, str):
|
||||
names = [names]
|
||||
|
||||
return cls(
|
||||
result_type,
|
||||
_get_op_result_or_value(target),
|
||||
|
||||
Reference in New Issue
Block a user