From 256811da7e843bc3b5c6a9a36f2f49ea91bae83f Mon Sep 17 00:00:00 2001 From: Scott Todd Date: Wed, 4 Dec 2019 09:15:49 -0800 Subject: [PATCH] [spirv] Adding sqrt op in the GLSL extension. PiperOrigin-RevId: 283769736 Change-Id: Idf156efd2c223488ba3a4e63ad04c393cde443bc --- .../mlir/Dialect/SPIRV/SPIRVGLSLOps.td | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/third_party/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td b/third_party/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td index 217b6d92865..2a1e8f32807 100644 --- a/third_party/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td +++ b/third_party/mlir/include/mlir/Dialect/SPIRV/SPIRVGLSLOps.td @@ -516,6 +516,36 @@ def SPV_GLSLSSignOp : SPV_GLSLUnaryArithmeticOp<"SSign", 7, SPV_Integer> { // ----- +def SPV_GLSLSqrtOp : SPV_GLSLUnaryArithmeticOp<"Sqrt", 31, SPV_Float> { + let summary = "Returns the square root of the operand"; + + let description = [{ + Result is the square root of x. Result is undefined if x < 0. + + 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. + + ### Custom assembly format + ``` {.ebnf} + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + sqrt-op ::= ssa-id `=` `spv.GLSL.Sqrt` ssa-use `:` + float-scalar-vector-type + ``` + For example: + + ``` + %2 = spv.GLSL.Sqrt %0 : f32 + %3 = spv.GLSL.Sqrt %1 : vector<3xf16> + ``` + }]; +} + +// ----- + def SPV_GLSLTanhOp : SPV_GLSLUnaryArithmeticOp<"Tanh", 21, SPV_Float16or32> { let summary = "Hyperbolic tangent of operand in radians";