[MLIR][Python] fix class name of powf and negf in linalg (#97696)

The following logic can lead to a class name mismatch when using
`linalg.powf` in Python. This PR fixed the issue and also renamed
`NegfOp` to `NegFOp` in linalg to adhere to the naming convention, as
exemplified by `arith::NegFOp`.


173514d58e/mlir/python/mlir/dialects/linalg/opdsl/lang/dsl.py (L140-L143)
```
# linalg.powf(arg0, arg1, outs=[init_result.result])
NotImplementedError: Unknown named op_name / op_class_name: powf / PowfOp
```
This commit is contained in:
Bimo 2024-07-05 09:23:12 +08:00 committed by GitHub
parent 4762f3bab0
commit bfa762a5a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View File

@ -271,7 +271,7 @@ structured_op: !LinalgStructuredOpConfig
--- !LinalgOpConfig
metadata: !LinalgOpMetadata
name: negf
cpp_class_name: NegfOp
cpp_class_name: NegFOp
doc: |-
Applies negf(x) elementwise.

View File

@ -96,7 +96,7 @@ def floor(
O[None] = UnaryFn.floor(I[None])
@linalg_structured_op
@linalg_structured_op(op_class_name="NegFOp")
def negf(
I=TensorDef(T1),
O=TensorDef(T1, output=True),
@ -330,7 +330,7 @@ def min(
O[None] = BinaryFn.min_signed(lhs[None], rhs[None])
@linalg_structured_op
@linalg_structured_op(op_class_name="PowFOp")
def powf(
lhs=TensorDef(T1),
rhs=TensorDef(T1),

View File

@ -2,3 +2,7 @@
# Just verify that at least one known op is generated.
# CHECK: name: matmul
# verify some special cases: negf->NegFOp, powf->PowFOp
# CHECK cpp_class_name: NegFOp
# CHECK cpp_class_name: PowFOp