[Mlir-commits] [mlir] [mlir][spirv][nfc] Add missing tests for GL Tanh Op (PR #143538)
Igor Wodiany
llvmlistbot at llvm.org
Tue Jun 10 07:03:26 PDT 2025
https://github.com/IgWod-IMG created https://github.com/llvm/llvm-project/pull/143538
The problem was noticed when adding Log2 operation.
>From 6c57b2a55293eea3c0a82c338548b8ebb40b6881 Mon Sep 17 00:00:00 2001
From: Igor Wodiany <igor.wodiany at imgtec.com>
Date: Tue, 10 Jun 2025 14:13:42 +0100
Subject: [PATCH] [mlir][spirv] Add missing tests for GL Tanh Op
The problem was noticed when adding Log2 operation.
---
mlir/test/Dialect/SPIRV/IR/gl-ops.mlir | 26 ++++++++++++++++++++++++++
mlir/test/Target/SPIRV/gl-ops.mlir | 2 ++
2 files changed, 28 insertions(+)
diff --git a/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir
index f238336f14a4d..50cf1b26d42ab 100644
--- a/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir
@@ -763,3 +763,29 @@ func.func @log2_invalid_type(%arg0 : i32) -> () {
%0 = spirv.GL.Log2 %arg0 : i32
return
}
+
+// -----
+
+//===----------------------------------------------------------------------===//
+// spirv.GL.Tanh
+//===----------------------------------------------------------------------===//
+
+func.func @tanh(%arg0 : f32) -> () {
+ // CHECK: spirv.GL.Tanh {{%.*}} : f32
+ %0 = spirv.GL.Tanh %arg0 : f32
+ return
+}
+
+func.func @tanhvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spirv.GL.Tanh {{%.*}} : vector<3xf16>
+ %0 = spirv.GL.Tanh %arg0 : vector<3xf16>
+ return
+}
+
+// -----
+
+func.func @tanh_invalid_type(%arg0 : i32) -> () {
+ // expected-error @+1 {{op operand #0 must be 16/32-bit float or vector of 16/32-bit float values}}
+ %0 = spirv.GL.Tanh %arg0 : i32
+ return
+}
diff --git a/mlir/test/Target/SPIRV/gl-ops.mlir b/mlir/test/Target/SPIRV/gl-ops.mlir
index 64592a4d5079b..368f60e102dc1 100644
--- a/mlir/test/Target/SPIRV/gl-ops.mlir
+++ b/mlir/test/Target/SPIRV/gl-ops.mlir
@@ -42,6 +42,8 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
%19 = spirv.GL.Atanh %arg0 : f32
// CHECK: {{%.*}} = spirv.GL.Log2 {{%.*}} : f32
%20 = spirv.GL.Log2 %arg0 : f32
+ // CHECK: {{%.*}} = spirv.GL.Tanh {{%.*}} : f32
+ %21 = spirv.GL.Tanh %arg0 : f32
spirv.Return
}
More information about the Mlir-commits
mailing list