[Mlir-commits] [mlir] 1e21ca4 - [spirv] Add SPIR-V GLSL extended Round op
Lei Zhang
llvmlistbot at llvm.org
Thu Sep 3 06:42:46 PDT 2020
Author: Zhibin Li
Date: 2020-09-03T09:42:35-04:00
New Revision: 1e21ca4d25f9743a0efdb1775812da84f8f98fa2
URL: https://github.com/llvm/llvm-project/commit/1e21ca4d25f9743a0efdb1775812da84f8f98fa2
DIFF: https://github.com/llvm/llvm-project/commit/1e21ca4d25f9743a0efdb1775812da84f8f98fa2.diff
LOG: [spirv] Add SPIR-V GLSL extended Round op
Reviewed By: mravishankar, antiagainst
Differential Revision: https://reviews.llvm.org/D86914
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 70534111b97f..10cafd825116 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td
@@ -430,6 +430,36 @@ def SPV_GLSLFloorOp : SPV_GLSLUnaryArithmeticOp<"Floor", 8, SPV_Float> {
// -----
+def SPV_GLSLRoundOp: SPV_GLSLUnaryArithmeticOp<"Round", 1, SPV_Float> {
+ let summary = "Rounds to the whole number";
+
+ let description = [{
+ Result is the value equal to the nearest whole number.
+
+ The operand x must be a scalar or vector whose component type is
+ floating-point.
+
+ Result Type and the type of x must be the same type. Results are computed
+ per component.
+
+ <!-- End of AutoGen section -->
+ ```
+ float-scalar-vector-type ::= float-type |
+ `vector<` integer-literal `x` float-type `>`
+ floor-op ::= ssa-id `=` `spv.GLSL.Round` ssa-use `:`
+ float-scalar-vector-type
+ ```
+ #### Example:
+
+ ```mlir
+ %2 = spv.GLSL.Round %0 : f32
+ %3 = spv.GLSL.Round %1 : vector<3xf16>
+ ```
+ }];
+}
+
+// -----
+
def SPV_GLSLInverseSqrtOp : SPV_GLSLUnaryArithmeticOp<"InverseSqrt", 32, SPV_Float> {
let summary = "Reciprocal of sqrt(operand)";
diff --git a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir b/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
index 9909ef3698e1..223b6301207d 100644
--- a/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
+++ b/mlir/test/Dialect/SPIRV/Serialization/glsl-ops.mlir
@@ -26,6 +26,8 @@ spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
%10 = spv.GLSL.Cosh %arg0 : f32
// CHECK: {{%.*}} = spv.GLSL.Pow {{%.*}} : f32
%11 = spv.GLSL.Pow %arg0, %arg1 : f32
+ // CHECK: {{%.*}} = spv.GLSL.Round {{%.*}} : f32
+ %12 = spv.GLSL.Round %arg0 : f32
spv.Return
}
}
diff --git a/mlir/test/Dialect/SPIRV/glslops.mlir b/mlir/test/Dialect/SPIRV/glslops.mlir
index a8df3710a1d8..3e699ed05958 100644
--- a/mlir/test/Dialect/SPIRV/glslops.mlir
+++ b/mlir/test/Dialect/SPIRV/glslops.mlir
@@ -254,3 +254,18 @@ func @powvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) -> () {
// -----
+//===----------------------------------------------------------------------===//
+// spv.GLSL.Round
+//===----------------------------------------------------------------------===//
+
+func @round(%arg0 : f32) -> () {
+ // CHECK: spv.GLSL.Round {{%.*}} : f32
+ %2 = spv.GLSL.Round %arg0 : f32
+ return
+}
+
+func @roundvec(%arg0 : vector<3xf16>) -> () {
+ // CHECK: spv.GLSL.Round {{%.*}} : vector<3xf16>
+ %2 = spv.GLSL.Round %arg0 : vector<3xf16>
+ return
+}
More information about the Mlir-commits
mailing list