[Mlir-commits] [mlir] [MLIR][Linalg] Fix named structured ops yaml file (PR #98865)
Renato Golin
llvmlistbot at llvm.org
Mon Jul 15 00:25:36 PDT 2024
https://github.com/rengolin created https://github.com/llvm/llvm-project/pull/98865
Added missing reciprocal to Python file and fixed ErfOp name in yaml file. Now running the bash script yields the same output.
>From e072771c264a22a2d433b6b57792044b279d718a Mon Sep 17 00:00:00 2001
From: Renato Golin <rengolin at systemcall.eu>
Date: Mon, 15 Jul 2024 08:24:24 +0100
Subject: [PATCH] [MLIR][Linalg] Fix named structured ops yaml file
Added missing reciprocal to Python file and fixed ErfOp name in yaml file. Now running the bash script yields the same output.
---
.../Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml | 2 +-
.../mlir/dialects/linalg/opdsl/lang/comprehension.py | 1 +
.../mlir/dialects/linalg/opdsl/ops/core_named_ops.py | 12 ++++++++++++
3 files changed, 14 insertions(+), 1 deletion(-)
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])
+ at 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),
More information about the Mlir-commits
mailing list