-
Notifications
You must be signed in to change notification settings - Fork 14k
[mlir][spirv] Add definitions for GL inverse hyperbolic functions #141720
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
Conversation
@llvm/pr-subscribers-mlir-spirv @llvm/pr-subscribers-mlir Author: Darren Wihandi (fairywreath) ChangesAdds definitions for Full diff: https://github.com/llvm/llvm-project/pull/141720.diff 3 Files Affected:
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td
index 057dfac4d6308..feae817c9b4ef 100644
--- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVGLOps.td
@@ -767,6 +767,77 @@ def SPIRV_GLTanhOp : SPIRV_GLUnaryArithmeticOp<"Tanh", 21, SPIRV_Float16or32> {
// -----
+def SPIRV_GLAsinhOp : SPIRV_GLUnaryArithmeticOp<"Asinh", 22, SPIRV_Float16or32> {
+ let summary = "Arc hyperbolic sine of operand in radians.";
+
+ let description = [{
+ Arc hyperbolic sine; result is the inverse of sinh.
+
+ The operand x must be a scalar or vector whose component type is 16-bit or
+ 32-bit floating-point.
+
+ Result Type and the type of x must be the same type. Results are computed
+ per component.
+
+ #### Example:
+
+ ```mlir
+ %2 = spirv.GL.Asinh %0 : f32
+ %3 = spirv.GL.Asinh %1 : vector<3xf16>
+ ```
+ }];
+}
+
+// -----
+
+def SPIRV_GLAcoshOp : SPIRV_GLUnaryArithmeticOp<"Acosh", 23, SPIRV_Float16or32> {
+ let summary = "Arc hyperbolic cosine of operand in radians.";
+
+ let description = [{
+ Arc hyperbolic cosine; result is the non-negative inverse of cosh. The resulting
+ value is NaN if x < 1.
+
+ The operand x must be a scalar or vector whose component type is 16-bit or
+ 32-bit floating-point.
+
+ Result Type and the type of x must be the same type. Results are computed
+ per component.
+
+ #### Example:
+
+ ```mlir
+ %2 = spirv.GL.Acosh %0 : f32
+ %3 = spirv.GL.Acosh %1 : vector<3xf16>
+ ```
+ }];
+}
+
+// -----
+
+def SPIRV_GLAtanhOp : SPIRV_GLUnaryArithmeticOp<"Atanh", 24, SPIRV_Float16or32> {
+ let summary = "Arc hyperbolic tangent of operand in radians.";
+
+ let description = [{
+ Arc hyperbolic tangent; result is the inverse of tanh. The resulting value
+ is NaN if abs x ≥ 1.
+
+ The operand x must be a scalar or vector whose component type is 16-bit or
+ 32-bit floating-point.
+
+ Result Type and the type of x must be the same type. Results are computed
+ per component.
+
+ #### Example:
+
+ ```mlir
+ %2 = spirv.GL.Atanh %0 : f32
+ %3 = spirv.GL.Atanh %1 : vector<3xf16>
+ ```
+ }];
+}
+
+// -----
+
def SPIRV_GLFClampOp : SPIRV_GLTernaryArithmeticOp<"FClamp", 43, SPIRV_Float> {
let summary = "Clamp x between min and max values.";
diff --git a/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir
index 0be047932c1f3..680a7e12b1082 100644
--- a/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/IR/gl-ops.mlir
@@ -254,6 +254,54 @@ func.func @coshvec(%arg0 : vector<3xf16>) -> () {
return
}
+//===----------------------------------------------------------------------===//
+// spirv.GL.Asinh
+//===----------------------------------------------------------------------===//
+
+func.func @asinh(%arg0 : f32) -> () {
+ // CHECK: spirv.GL.Asinh {{%.*}} : f32
+ %2 = spirv.GL.Asinh %arg0 : f32
+ return
+}
+
+func.func @asinhvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spirv.GL.Asinh {{%.*}} : vector<3xf16>
+ %2 = spirv.GL.Asinh %arg0 : vector<3xf16>
+ return
+}
+
+//===----------------------------------------------------------------------===//
+// spirv.GL.Acosh
+//===----------------------------------------------------------------------===//
+
+func.func @acosh(%arg0 : f32) -> () {
+ // CHECK: spirv.GL.Acosh {{%.*}} : f32
+ %2 = spirv.GL.Acosh %arg0 : f32
+ return
+}
+
+func.func @acoshvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spirv.GL.Acosh {{%.*}} : vector<3xf16>
+ %2 = spirv.GL.Acosh %arg0 : vector<3xf16>
+ return
+}
+
+//===----------------------------------------------------------------------===//
+// spirv.GL.Atanh
+//===----------------------------------------------------------------------===//
+
+func.func @atanh(%arg0 : f32) -> () {
+ // CHECK: spirv.GL.Atanh {{%.*}} : f32
+ %2 = spirv.GL.Atanh %arg0 : f32
+ return
+}
+
+func.func @atanhvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spirv.GL.Atanh {{%.*}} : vector<3xf16>
+ %2 = spirv.GL.Atanh %arg0 : vector<3xf16>
+ return
+}
+
//===----------------------------------------------------------------------===//
// spirv.GL.Pow
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/Target/SPIRV/gl-ops.mlir b/mlir/test/Target/SPIRV/gl-ops.mlir
index 7f9771220b75d..28e5a1fd72ec5 100644
--- a/mlir/test/Target/SPIRV/gl-ops.mlir
+++ b/mlir/test/Target/SPIRV/gl-ops.mlir
@@ -34,6 +34,12 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
%15 = spirv.GL.FMix %arg0 : f32, %arg1 : f32, %arg0 : f32 -> f32
// CHECK: {{%.*}} = spirv.GL.Fract {{%.*}} : f32
%16 = spirv.GL.Fract %arg0 : f32
+ // CHECK: {{%.*}} = spirv.GL.Asinh {{%.*}} : f32
+ %17 = spirv.GL.Asinh %arg0 : f32
+ // CHECK: {{%.*}} = spirv.GL.Acosh {{%.*}} : f32
+ %18 = spirv.GL.Acosh %arg0 : f32
+ // CHECK: {{%.*}} = spirv.GL.Atanh {{%.*}} : f32
+ %19 = spirv.GL.Atanh %arg0 : f32
spirv.Return
}
|
I'm probably not qualified to official approve it, but still LGTM |
Can someone help merge this if this looks good? Thanks! |
…vm#141720) Adds definitions for `Asinh`, `Acosh` and `Atanh` based on [SPIR-V extended instructions for GLSL](https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html). Their instruction numbers are 22, 23 and 24.
…vm#141720) Adds definitions for `Asinh`, `Acosh` and `Atanh` based on [SPIR-V extended instructions for GLSL](https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html). Their instruction numbers are 22, 23 and 24.
…vm#141720) Adds definitions for `Asinh`, `Acosh` and `Atanh` based on [SPIR-V extended instructions for GLSL](https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html). Their instruction numbers are 22, 23 and 24.
Adds definitions for
Asinh
,Acosh
andAtanh
based on SPIR-V extended instructions for GLSL. Their instruction numbers are 22, 23 and 24.