Skip to content

[MLIR][Linalg] Fix named structured ops yaml file #98865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

rengolin
Copy link
Member

Added missing reciprocal to Python file and fixed ErfOp name in yaml file. Now running the bash script yields the same output.

Added missing reciprocal to Python file and fixed ErfOp name in yaml file. Now running the bash script yields the same output.
@llvmbot
Copy link
Member

llvmbot commented Jul 15, 2024

@llvm/pr-subscribers-mlir-linalg

@llvm/pr-subscribers-mlir

Author: Renato Golin (rengolin)

Changes

Added missing reciprocal to Python file and fixed ErfOp name in yaml file. Now running the bash script yields the same output.


Full diff: https://github.com/llvm/llvm-project/pull/98865.diff

3 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml (+1-1)
  • (modified) mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py (+1)
  • (modified) mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py (+12)
diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
index c31b7c4f6c108..46b3ec0f60ebf 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
@@ -516,7 +516,7 @@ structured_op: !LinalgStructuredOpConfig
 --- !LinalgOpConfig
 metadata: !LinalgOpMetadata
   name: erf
-  cpp_class_name: erfOp
+  cpp_class_name: ErfOp
   doc: |-
     Applies erf(x) elementwise.
 
diff --git a/mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py b/mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py
index 1a198fc5ec6f9..4f81a3874650d 100644
--- a/mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py
+++ b/mlir/python/mlir/dialects/linalg/opdsl/lang/comprehension.py
@@ -292,6 +292,7 @@ class UnaryFn:
     ceil = UnaryFnType("ceil")
     floor = UnaryFnType("floor")
     negf = UnaryFnType("negf")
+    reciprocal = UnaryFnType("reciprocal")
     round = UnaryFnType("round")
     sqrt = UnaryFnType("sqrt")
     rsqrt = UnaryFnType("rsqrt")
diff --git a/mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py b/mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py
index 3ceee8e370445..67bde8f736ef4 100644
--- a/mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py
+++ b/mlir/python/mlir/dialects/linalg/opdsl/ops/core_named_ops.py
@@ -108,6 +108,18 @@ def negf(
     O[None] = UnaryFn.negf(I[None])
 
 
+@linalg_structured_op(op_class_name="ReciprocalOp")
+def reciprocal(
+    I=TensorDef(T1),
+    O=TensorDef(T1, output=True),
+):
+    """Applies reciprocal(x) elementwise.
+
+    No numeric casting is performed on the input operand.
+    """
+    O[None] = UnaryFn.reciprocal(I[None])
+
+
 @linalg_structured_op
 def round(
     I=TensorDef(T1),

@rengolin rengolin merged commit de3e9d4 into llvm:main Jul 15, 2024
9 of 10 checks passed
@rengolin rengolin deleted the linalg branch July 15, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants