diff options
-rw-r--r-- | mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td | 333 | ||||
-rw-r--r-- | mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir | 160 |
2 files changed, 483 insertions, 10 deletions
diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td index 026f59b..124d828 100644 --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td @@ -113,31 +113,223 @@ class SPIRV_CLTernaryArithmeticOp<string mnemonic, int opcode, Type type, // ----- -def SPIRV_CLMixOp : SPIRV_CLTernaryArithmeticOp<"mix", 99, SPIRV_Float> { - let summary = "Returns the linear blend of x & y implemented as: x + (y - x) * a"; +def SPIRV_CLAtan2Op : SPIRV_CLBinaryArithmeticOp<"atan2", 7, SPIRV_Float > { + let summary = "Compute the arc tangent of y / x."; let description = [{ - Result Type, x, y and a must be floating-point or vector(2,3,4,8,16) of + Result is an angle in radians. + + Result Type, y and x must be floating-point or vector(2,3,4,8,16) of floating-point values. All of the operands, including the Result Type operand, must be of the same type. - Note: This instruction can be implemented using contractions such as mad - or fma. + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + atan2-op ::= ssa-id `=` `spirv.CL.atan2` ssa-use `:` + float-scalar-vector-type + ``` + #### Example: + + ```mlir + %2 = spirv.CL.atan2 %0, %1 : f32 + %3 = spirv.CL.atan2 %0, %1 : vector<4xf16> + ``` + }]; +} + +// ----- + +def SPIRV_CLAcosOp : SPIRV_CLUnaryArithmeticOp<"acos", 0, SPIRV_Float > { + let summary = "Compute the arc cosine of x."; + + let description = [{ + Result is an angle in radians. + + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. <!-- End of AutoGen section --> ``` - mix-op ::= ssa-id `=` `spirv.CL.mix` ssa-use, ssa-use, ssa-use `:` - float-scalar-vector-type + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + acos-op ::= ssa-id `=` `spirv.CL.acos` ssa-use `:` + float-scalar-vector-type ``` #### Example: ```mlir - %0 = spirv.CL.mix %a, %b, %c : f32 - %1 = spirv.CL.mix %a, %b, %c : vector<3xf16> + %2 = spirv.CL.acos %0 : f32 + %3 = spirv.CL.acos %1 : vector<4xf16> + ``` + }]; +} + +// ----- + +def SPIRV_CLAcoshOp : SPIRV_CLUnaryArithmeticOp<"acosh", 1, SPIRV_Float > { + let summary = "Compute the inverse hyperbolic cosine of x ."; + + let description = [{ + Result is an angle in radians. + + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + acosh-op ::= ssa-id `=` `spirv.CL.acosh` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.acosh %0 : f32 + %3 = spirv.CL.acosh %1 : vector<4xf16> + ``` + }]; +} + +// ----- + +def SPIRV_CLAsinOp : SPIRV_CLUnaryArithmeticOp<"asin", 3, SPIRV_Float > { + let summary = "Compute the arc sine of x."; + + let description = [{ + Result is an angle in radians. + + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + asin-op ::= ssa-id `=` `spirv.CL.asin` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.asin %0 : f32 + %3 = spirv.CL.asin %1 : vector<4xf16> + ``` + }]; +} + +// ----- + +def SPIRV_CLAsinhOp : SPIRV_CLUnaryArithmeticOp<"asinh", 4, SPIRV_Float > { + let summary = "Compute the inverse hyperbolic sine of x."; + + let description = [{ + Result is an angle in radians. + + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + asinh-op ::= ssa-id `=` `spirv.CL.asinh` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.asinh %0 : f32 + %3 = spirv.CL.asinh %1 : vector<4xf16> + ``` + }]; +} + +// ----- + +def SPIRV_CLAtanOp : SPIRV_CLUnaryArithmeticOp<"atan", 6, SPIRV_Float > { + let summary = "Compute the arc tangent of x."; + + let description = [{ + Result is an angle in radians. + + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + atan-op ::= ssa-id `=` `spirv.CL.atan` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.atan %0 : f32 + %3 = spirv.CL.atan %1 : vector<4xf16> + ``` + }]; +} + +// ----- + +def SPIRV_CLAtanhOp : SPIRV_CLUnaryArithmeticOp<"atanh", 8, SPIRV_Float > { + let summary = "Compute the hyperbolic arc tangent of x."; + + let description = [{ + Result is an angle in radians. + + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + atanh-op ::= ssa-id `=` `spirv.CL.atanh` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.atanh %0 : f32 + %3 = spirv.CL.atanh %1 : vector<4xf16> ``` }]; } @@ -207,6 +399,36 @@ def SPIRV_CLCosOp : SPIRV_CLUnaryArithmeticOp<"cos", 14, SPIRV_Float> { // ----- +def SPIRV_CLCoshOp : SPIRV_CLUnaryArithmeticOp<"cosh", 15, SPIRV_Float > { + let summary = "Compute the hyperbolic cosine of x radians."; + + let description = [{ + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + cosh-op ::= ssa-id `=` `spirv.CL.cosh` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.cosh %0 : f32 + %3 = spirv.CL.cosh %1 : vector<4xf16> + ``` + }]; +} + +// ----- + def SPIRV_CLErfOp : SPIRV_CLUnaryArithmeticOp<"erf", 18, SPIRV_Float> { let summary = [{ Error function of x encountered in integrating the normal distribution. @@ -386,7 +608,7 @@ def SPIRV_CLFloorOp : SPIRV_CLUnaryArithmeticOp<"floor", 25, SPIRV_Float> { ```mlir %2 = spirv.CL.floor %0 : f32 - %3 = spirv.CL.ceifloorl %1 : vector<3xf16> + %3 = spirv.CL.floor %1 : vector<3xf16> ``` }]; } @@ -456,6 +678,37 @@ def SPIRV_CLLogOp : SPIRV_CLUnaryArithmeticOp<"log", 37, SPIRV_Float> { // ----- +def SPIRV_CLMixOp : SPIRV_CLTernaryArithmeticOp<"mix", 99, SPIRV_Float> { + let summary = "Returns the linear blend of x & y implemented as: x + (y - x) * a"; + + let description = [{ + Result Type, x, y and a must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + Note: This instruction can be implemented using contractions such as mad + or fma. + + <!-- End of AutoGen section --> + + ``` + mix-op ::= ssa-id `=` `spirv.CL.mix` ssa-use, ssa-use, ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %0 = spirv.CL.mix %a, %b, %c : f32 + %1 = spirv.CL.mix %a, %b, %c : vector<3xf16> + ``` + }]; +} + +// ----- + def SPIRV_CLPowOp : SPIRV_CLBinaryArithmeticOp<"pow", 48, SPIRV_Float> { let summary = "Compute x to the power y."; @@ -696,6 +949,36 @@ def SPIRV_CLSinOp : SPIRV_CLUnaryArithmeticOp<"sin", 57, SPIRV_Float> { // ----- +def SPIRV_CLSinhOp : SPIRV_CLUnaryArithmeticOp<"sinh", 59, SPIRV_Float > { + let summary = "Compute hyperbolic sine of x radians."; + + let description = [{ + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + sinh-op ::= ssa-id `=` `spirv.CL.sinh` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.sinh %0 : f32 + %3 = spirv.CL.sinh %1 : vector<4xf16> + ``` + }]; +} + +// ----- + def SPIRV_CLSqrtOp : SPIRV_CLUnaryArithmeticOp<"sqrt", 61, SPIRV_Float> { let summary = "Compute square root of x."; @@ -726,6 +1009,36 @@ def SPIRV_CLSqrtOp : SPIRV_CLUnaryArithmeticOp<"sqrt", 61, SPIRV_Float> { // ----- +def SPIRV_CLTanOp : SPIRV_CLUnaryArithmeticOp<"tan", 62, SPIRV_Float > { + let summary = "Compute tangent of x radians."; + + let description = [{ + Result Type and x must be floating-point or vector(2,3,4,8,16) of + floating-point values. + + All of the operands, including the Result Type operand, must be of the + same type. + + <!-- End of AutoGen section --> + + ``` + float-scalar-vector-type ::= float-type | + `vector<` integer-literal `x` float-type `>` + tan-op ::= ssa-id `=` `spirv.CL.tan` ssa-use `:` + float-scalar-vector-type + ``` + + #### Example: + + ```mlir + %2 = spirv.CL.tan %0 : f32 + %3 = spirv.CL.tan %1 : vector<4xf16> + ``` + }]; +} + +// ----- + def SPIRV_CLTanhOp : SPIRV_CLUnaryArithmeticOp<"tanh", 63, SPIRV_Float> { let summary = "Compute hyperbolic tangent of x radians."; diff --git a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir index f4e3a83..81ba471 100644 --- a/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir +++ b/mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir @@ -280,3 +280,163 @@ func.func @printf(%arg0 : !spirv.ptr<i8, UniformConstant>, %arg1 : i32, %arg2 : return %0 : i32 } +// ----- + +func.func @tan(%arg0 : f32) -> () { + // CHECK: spirv.CL.tan {{%.*}} : f32 + %2 = spirv.CL.tan %arg0 : f32 + return +} + +// ----- + +func.func @tan(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.tan {{%.*}} : vector<4xf16> + %2 = spirv.CL.tan %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @atan(%arg0 : f32) -> () { + // CHECK: spirv.CL.atan {{%.*}} : f32 + %2 = spirv.CL.atan %arg0 : f32 + return +} + +// ----- + +func.func @atan(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.atan {{%.*}} : vector<4xf16> + %2 = spirv.CL.atan %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @atanh(%arg0 : f32) -> () { + // CHECK: spirv.CL.atanh {{%.*}} : f32 + %2 = spirv.CL.atanh %arg0 : f32 + return +} + +// ----- + +func.func @atanh(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.atanh {{%.*}} : vector<4xf16> + %2 = spirv.CL.atanh %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @sinh(%arg0 : f32) -> () { + // CHECK: spirv.CL.sinh {{%.*}} : f32 + %2 = spirv.CL.sinh %arg0 : f32 + return +} + +// ----- + +func.func @sinh(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.sinh {{%.*}} : vector<4xf16> + %2 = spirv.CL.sinh %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @cosh(%arg0 : f32) -> () { + // CHECK: spirv.CL.cosh {{%.*}} : f32 + %2 = spirv.CL.cosh %arg0 : f32 + return +} + +// ----- + +func.func @cosh(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.cosh {{%.*}} : vector<4xf16> + %2 = spirv.CL.cosh %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @asin(%arg0 : f32) -> () { + // CHECK: spirv.CL.asin {{%.*}} : f32 + %2 = spirv.CL.asin %arg0 : f32 + return +} + +// ----- + +func.func @asin(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.asin {{%.*}} : vector<4xf16> + %2 = spirv.CL.asin %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @asinh(%arg0 : f32) -> () { + // CHECK: spirv.CL.asinh {{%.*}} : f32 + %2 = spirv.CL.asinh %arg0 : f32 + return +} + +// ----- + +func.func @asinh(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.asinh {{%.*}} : vector<4xf16> + %2 = spirv.CL.asinh %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @acos(%arg0 : f32) -> () { + // CHECK: spirv.CL.acos {{%.*}} : f32 + %2 = spirv.CL.acos %arg0 : f32 + return +} + +// ----- + +func.func @acos(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.acos {{%.*}} : vector<4xf16> + %2 = spirv.CL.acos %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @acosh(%arg0 : f32) -> () { + // CHECK: spirv.CL.acosh {{%.*}} : f32 + %2 = spirv.CL.acosh %arg0 : f32 + return +} + +// ----- + +func.func @acosh(%arg0 : vector<4xf16>) -> () { + // CHECK: spirv.CL.acosh {{%.*}} : vector<4xf16> + %2 = spirv.CL.acosh %arg0 : vector<4xf16> + return +} + +// ----- + +func.func @atan2(%arg0 : f32, %arg1 : f32) -> () { + // CHECK: spirv.CL.atan2 {{%.*}}, {{%.*}} : f32 + %2 = spirv.CL.atan2 %arg0, %arg1 : f32 + return +} + +// ----- + +func.func @atan2(%arg0 : vector<4xf16>, %arg1 : vector<4xf16>) -> () { + // CHECK: spirv.CL.atan2 {{%.*}}, {{%.*}} : vector<4xf16> + %2 = spirv.CL.atan2 %arg0, %arg1 : vector<4xf16> + return +} + |