[mlir] Add Acos, Asin, Atan, Sinh, Cosh, Pow to SPIRVGLSLOps
Reviewed By: mravishankar, antiagainst Differential Revision: https://reviews.llvm.org/D86929
This commit is contained in:
parent
890707aa01
commit
2860b2c14b
3 changed files with 311 additions and 0 deletions
|
@ -265,6 +265,108 @@ def SPV_GLSLTanOp : SPV_GLSLUnaryArithmeticOp<"Tan", 15, SPV_Float16or32> {
|
|||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLAsinOp : SPV_GLSLUnaryArithmeticOp<"Asin", 16, SPV_Float16or32> {
|
||||
let summary = "Arc Sine of operand in radians";
|
||||
|
||||
let description = [{
|
||||
The standard trigonometric arc sine of x radians.
|
||||
|
||||
Result is an angle, in radians, whose sine is x. The range of result values
|
||||
is [-π / 2, π / 2]. Result is undefined 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.
|
||||
<!-- End of AutoGen section -->
|
||||
```
|
||||
restricted-float-scalar-type ::= `f16` | `f32`
|
||||
restricted-float-scalar-vector-type ::=
|
||||
restricted-float-scalar-type |
|
||||
`vector<` integer-literal `x` restricted-float-scalar-type `>`
|
||||
asin-op ::= ssa-id `=` `spv.GLSL.Asin` ssa-use `:`
|
||||
restricted-float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.GLSL.Asin %0 : f32
|
||||
%3 = spv.GLSL.Asin %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLAcosOp : SPV_GLSLUnaryArithmeticOp<"Acos", 17, SPV_Float16or32> {
|
||||
let summary = "Arc Cosine of operand in radians";
|
||||
|
||||
let description = [{
|
||||
The standard trigonometric arc cosine of x radians.
|
||||
|
||||
Result is an angle, in radians, whose cosine is x. The range of result
|
||||
values is [0, π]. Result is undefined 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.
|
||||
<!-- End of AutoGen section -->
|
||||
```
|
||||
restricted-float-scalar-type ::= `f16` | `f32`
|
||||
restricted-float-scalar-vector-type ::=
|
||||
restricted-float-scalar-type |
|
||||
`vector<` integer-literal `x` restricted-float-scalar-type `>`
|
||||
acos-op ::= ssa-id `=` `spv.GLSL.Acos` ssa-use `:`
|
||||
restricted-float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.GLSL.Acos %0 : f32
|
||||
%3 = spv.GLSL.Acos %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLAtanOp : SPV_GLSLUnaryArithmeticOp<"Atan", 18, SPV_Float16or32> {
|
||||
let summary = "Arc Tangent of operand in radians";
|
||||
|
||||
let description = [{
|
||||
The standard trigonometric arc tangent of x radians.
|
||||
|
||||
Result is an angle, in radians, whose tangent is y_over_x. The range of
|
||||
result values is [-π / 2, π / 2].
|
||||
|
||||
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.
|
||||
<!-- End of AutoGen section -->
|
||||
```
|
||||
restricted-float-scalar-type ::= `f16` | `f32`
|
||||
restricted-float-scalar-vector-type ::=
|
||||
restricted-float-scalar-type |
|
||||
`vector<` integer-literal `x` restricted-float-scalar-type `>`
|
||||
atan-op ::= ssa-id `=` `spv.GLSL.Atan` ssa-use `:`
|
||||
restricted-float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.GLSL.Atan %0 : f32
|
||||
%3 = spv.GLSL.Atan %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLExpOp : SPV_GLSLUnaryArithmeticOp<"Exp", 27, SPV_Float16or32> {
|
||||
let summary = "Exponentiation of Operand 1";
|
||||
|
||||
|
@ -513,6 +615,40 @@ def SPV_GLSLSMinOp : SPV_GLSLBinaryArithmeticOp<"SMin", 39, SPV_Integer> {
|
|||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLPowOp : SPV_GLSLBinaryArithmeticOp<"Pow", 26, SPV_Float16or32> {
|
||||
let summary = "Return x raised to the y power of two operands";
|
||||
|
||||
let description = [{
|
||||
Result is x raised to the y power; x^y.
|
||||
|
||||
Result is undefined if x = 0 and y ≤ 0.
|
||||
|
||||
The operand x and y must be a scalar or vector whose component type is
|
||||
16-bit or 32-bit floating-point.
|
||||
|
||||
Result Type and the type of all operands must be the same type. Results are
|
||||
computed per component.
|
||||
|
||||
<!-- End of AutoGen section -->
|
||||
```
|
||||
restricted-float-scalar-type ::= `f16` | `f32`
|
||||
restricted-float-scalar-vector-type ::=
|
||||
restricted-float-scalar-type |
|
||||
`vector<` integer-literal `x` restricted-float-scalar-type `>`
|
||||
pow-op ::= ssa-id `=` `spv.GLSL.Pow` ssa-use `:`
|
||||
restricted-float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.GLSL.Pow %0, %1 : f32
|
||||
%3 = spv.GLSL.Pow %0, %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLFSignOp : SPV_GLSLUnaryArithmeticOp<"FSign", 6, SPV_Float> {
|
||||
let summary = "Returns the sign of the operand";
|
||||
|
||||
|
@ -602,6 +738,70 @@ def SPV_GLSLSqrtOp : SPV_GLSLUnaryArithmeticOp<"Sqrt", 31, SPV_Float> {
|
|||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLSinhOp : SPV_GLSLUnaryArithmeticOp<"Sinh", 19, SPV_Float16or32> {
|
||||
let summary = "Hyperbolic sine of operand in radians";
|
||||
|
||||
let description = [{
|
||||
Hyperbolic 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.
|
||||
|
||||
<!-- End of AutoGen section -->
|
||||
```
|
||||
restricted-float-scalar-type ::= `f16` | `f32`
|
||||
restricted-float-scalar-vector-type ::=
|
||||
restricted-float-scalar-type |
|
||||
`vector<` integer-literal `x` restricted-float-scalar-type `>`
|
||||
sinh-op ::= ssa-id `=` `spv.GLSL.Sinh` ssa-use `:`
|
||||
restricted-float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.GLSL.Sinh %0 : f32
|
||||
%3 = spv.GLSL.Sinh %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLCoshOp : SPV_GLSLUnaryArithmeticOp<"Cosh", 20, SPV_Float16or32> {
|
||||
let summary = "Hyperbolic cosine of operand in radians";
|
||||
|
||||
let description = [{
|
||||
Hyperbolic cosine 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.
|
||||
|
||||
<!-- End of AutoGen section -->
|
||||
```
|
||||
restricted-float-scalar-type ::= `f16` | `f32`
|
||||
restricted-float-scalar-vector-type ::=
|
||||
restricted-float-scalar-type |
|
||||
`vector<` integer-literal `x` restricted-float-scalar-type `>`
|
||||
cosh-op ::= ssa-id `=` `spv.GLSL.Cosh` ssa-use `:`
|
||||
restricted-float-scalar-vector-type
|
||||
```
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spv.GLSL.Cosh %0 : f32
|
||||
%3 = spv.GLSL.Cosh %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPV_GLSLTanhOp : SPV_GLSLUnaryArithmeticOp<"Tanh", 21, SPV_Float16or32> {
|
||||
let summary = "Hyperbolic tangent of operand in radians";
|
||||
|
||||
|
|
|
@ -14,6 +14,18 @@ spv.module Logical GLSL450 requires #spv.vce<v1.0, [Shader], []> {
|
|||
%4 = spv.GLSL.Sin %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Tan {{%.*}} : f32
|
||||
%5 = spv.GLSL.Tan %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Acos {{%.*}} : f32
|
||||
%6 = spv.GLSL.Acos %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Asin {{%.*}} : f32
|
||||
%7 = spv.GLSL.Asin %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Atan {{%.*}} : f32
|
||||
%8 = spv.GLSL.Atan %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Sinh {{%.*}} : f32
|
||||
%9 = spv.GLSL.Sinh %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Cosh {{%.*}} : f32
|
||||
%10 = spv.GLSL.Cosh %arg0 : f32
|
||||
// CHECK: {{%.*}} = spv.GLSL.Pow {{%.*}} : f32
|
||||
%11 = spv.GLSL.Pow %arg0, %arg1 : f32
|
||||
spv.Return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,3 +155,102 @@ func @tanvec(%arg0 : vector<3xf16>) -> () {
|
|||
%2 = spv.GLSL.Tan %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.GLSL.Acos
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func @acos(%arg0 : f32) -> () {
|
||||
// CHECK: spv.GLSL.Acos {{%.*}} : f32
|
||||
%2 = spv.GLSL.Acos %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func @acosvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.GLSL.Acos {{%.*}} : vector<3xf16>
|
||||
%2 = spv.GLSL.Acos %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.GLSL.Asin
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func @asin(%arg0 : f32) -> () {
|
||||
// CHECK: spv.GLSL.Asin {{%.*}} : f32
|
||||
%2 = spv.GLSL.Asin %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func @asinvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.GLSL.Asin {{%.*}} : vector<3xf16>
|
||||
%2 = spv.GLSL.Asin %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.GLSL.Atan
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func @atan(%arg0 : f32) -> () {
|
||||
// CHECK: spv.GLSL.Atan {{%.*}} : f32
|
||||
%2 = spv.GLSL.Atan %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func @atanvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.GLSL.Atan {{%.*}} : vector<3xf16>
|
||||
%2 = spv.GLSL.Atan %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.GLSL.Sinh
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func @sinh(%arg0 : f32) -> () {
|
||||
// CHECK: spv.GLSL.Sinh {{%.*}} : f32
|
||||
%2 = spv.GLSL.Sinh %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func @sinhvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.GLSL.Sinh {{%.*}} : vector<3xf16>
|
||||
%2 = spv.GLSL.Sinh %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.GLSL.Cosh
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func @cosh(%arg0 : f32) -> () {
|
||||
// CHECK: spv.GLSL.Cosh {{%.*}} : f32
|
||||
%2 = spv.GLSL.Cosh %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func @coshvec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.GLSL.Cosh {{%.*}} : vector<3xf16>
|
||||
%2 = spv.GLSL.Cosh %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spv.GLSL.Pow
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func @pow(%arg0 : f32, %arg1 : f32) -> () {
|
||||
// CHECK: spv.GLSL.Pow {{%.*}}, {{%.*}} : f32
|
||||
%2 = spv.GLSL.Pow %arg0, %arg1 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func @powvec(%arg0 : vector<3xf16>, %arg1 : vector<3xf16>) -> () {
|
||||
// CHECK: spv.GLSL.Pow {{%.*}}, {{%.*}} : vector<3xf16>
|
||||
%2 = spv.GLSL.Pow %arg0, %arg1 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
|
|
Loading…
Reference in a new issue