Skip to content

Commit de3e9d4

Browse files
authored
[MLIR][Linalg] Fix named structured ops yaml file (llvm#98865)
Added missing reciprocal to Python file and fixed ErfOp name in yaml file. Now running the bash script yields the same output.
1 parent 94279ae commit de3e9d4

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ structured_op: !LinalgStructuredOpConfig
516516
--- !LinalgOpConfig
517517
metadata: !LinalgOpMetadata
518518
name: erf
519-
cpp_class_name: erfOp
519+
cpp_class_name: ErfOp
520520
doc: |-
521521
Applies erf(x) elementwise.
522522

mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ class UnaryFn:
292292
ceil = UnaryFnType("ceil")
293293
floor = UnaryFnType("floor")
294294
negf = UnaryFnType("negf")
295+
reciprocal = UnaryFnType("reciprocal")
295296
round = UnaryFnType("round")
296297
sqrt = UnaryFnType("sqrt")
297298
rsqrt = UnaryFnType("rsqrt")

mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ def negf(
108108
O[None] = UnaryFn.negf(I[None])
109109

110110

111+
@linalg_structured_op(op_class_name="ReciprocalOp")
112+
def reciprocal(
113+
I=TensorDef(T1),
114+
O=TensorDef(T1, output=True),
115+
):
116+
"""Applies reciprocal(x) elementwise.
117+
118+
No numeric casting is performed on the input operand.
119+
"""
120+
O[None] = UnaryFn.reciprocal(I[None])
121+
122+
111123
@linalg_structured_op
112124
def round(
113125
I=TensorDef(T1),

0 commit comments

Comments
 (0)