[Mlir-commits] [mlir] 9c1c825 - [mlir][spirv] Adding sin op in the GLSL extension
Lei Zhang
llvmlistbot at llvm.org
Fri Feb 7 13:37:21 PST 2020
Author: natashaknk
Date: 2020-02-07T16:36:12-05:00
New Revision: 9c1c825b724928130a4e73a24d12943de1fd0581
URL: https://github.com/llvm/llvm-project/commit/9c1c825b724928130a4e73a24d12943de1fd0581
DIFF: https://github.com/llvm/llvm-project/commit/9c1c825b724928130a4e73a24d12943de1fd0581.diff
LOG: [mlir][spirv] Adding sin op in the GLSL extension
Differential Revision: https://reviews.llvm.org/D74151
Added:
Modified:
mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
mlir/test/Dialect/SPIRV/glslops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
index b3324df69bf1..faf114ccd083 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
@@ -200,6 +200,38 @@ def SPV_GLSLCosOp : SPV_GLSLUnaryArithmeticOp<"Cos", 14, SPV_Float16or32> {
// -----
+def SPV_GLSLSinOp : SPV_GLSLUnaryArithmeticOp<"Sin", 13, SPV_Float16or32> {
+ let summary = "Sine of operand in radians";
+
+ let description = [{
+ The standard trigonometric sine of x radians.
+
+ 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.
+
+ ### Custom assembly format
+ ```
+ restricted-float-scalar-type ::= `f16` | `f32`
+ restricted-float-scalar-vector-type ::=
+ restricted-float-scalar-type |
+ `vector<` integer-literal `x` restricted-float-scalar-type `>`
+ sin-op ::= ssa-id `=` `spv.GLSL.Sin` ssa-use `:`
+ restricted-float-scalar-vector-type
+ ```
+ For example:
+
+ ```
+ %2 = spv.GLSL.Sin %0 : f32
+ %3 = spv.GLSL.Sin %1 : vector<3xf16>
+ ```
+ }];
+}
+
+// -----
+
def SPV_GLSLExpOp : SPV_GLSLUnaryArithmeticOp<"Exp", 27, SPV_Float16or32> {
let summary = "Exponentiation of Operand 1";
diff --git a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir b/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
index 2ebe1882a926..d2582a953666 100644
--- a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
@@ -8,6 +8,10 @@ spv.module "Logical" "GLSL450" {
%1 = spv.GLSL.FMax %arg0, %arg1 : f32
// CHECK: {{%.*}} = spv.GLSL.Sqrt {{%.*}} : f32
%2 = spv.GLSL.Sqrt %arg0 : f32
+ // CHECK: {{%.*}} = spv.GLSL.Cos {{%.*}} : f32
+ %3 = spv.GLSL.Cos %arg0 : f32
+ // CHECK: {{%.*}} = spv.GLSL.Sin {{%.*}} : f32
+ %4 = spv.GLSL.Sin %arg0 : f32
spv.Return
}
}
diff --git a/mlir/test/Dialect/SPIRV/glslops.mlir b/mlir/test/Dialect/SPIRV/glslops.mlir
index e3a3ca52e449..8e06df3d9eeb 100644
--- a/mlir/test/Dialect/SPIRV/glslops.mlir
+++ b/mlir/test/Dialect/SPIRV/glslops.mlir
@@ -107,3 +107,35 @@ func @sqrtvec(%arg0 : vector<3xf16>) -> () {
%2 = spv.GLSL.Sqrt %arg0 : vector<3xf16>
return
}
+
+//===----------------------------------------------------------------------===//
+// spv.GLSL.Cos
+//===----------------------------------------------------------------------===//
+
+func @cos(%arg0 : f32) -> () {
+ // CHECK: spv.GLSL.Cos {{%.*}} : f32
+ %2 = spv.GLSL.Cos %arg0 : f32
+ return
+}
+
+func @cosvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spv.GLSL.Cos {{%.*}} : vector<3xf16>
+ %2 = spv.GLSL.Cos %arg0 : vector<3xf16>
+ return
+}
+
+//===----------------------------------------------------------------------===//
+// spv.GLSL.Sin
+//===----------------------------------------------------------------------===//
+
+func @sin(%arg0 : f32) -> () {
+ // CHECK: spv.GLSL.Sin {{%.*}} : f32
+ %2 = spv.GLSL.Sin %arg0 : f32
+ return
+}
+
+func @sinvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spv.GLSL.Sin {{%.*}} : vector<3xf16>
+ %2 = spv.GLSL.Sin %arg0 : vector<3xf16>
+ return
+}
More information about the Mlir-commits
mailing list