[mlir][spirv] Add definition for GL Exp2 (#143678)
This commit is contained in:
@@ -838,6 +838,34 @@ def SPIRV_GLAtanhOp : SPIRV_GLUnaryArithmeticOp<"Atanh", 24, SPIRV_Float16or32>
|
||||
|
||||
// -----
|
||||
|
||||
def SPIRV_GLExp2Op : SPIRV_GLUnaryArithmeticOp<"Exp2", 29, SPIRV_Float16or32> {
|
||||
let summary = "Result is 2 raised to the x power";
|
||||
|
||||
let description = [{
|
||||
Result is 2 raised to the x power; 2**x.
|
||||
|
||||
```
|
||||
exp2(Inf) = Inf.
|
||||
exp2(-Inf) = +0.
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
#### Example:
|
||||
|
||||
```mlir
|
||||
%2 = spirv.GL.Exp2 %0 : f32
|
||||
%3 = spirv.GL.Exp2 %1 : vector<3xf16>
|
||||
```
|
||||
}];
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
def SPIRV_GLLog2Op : SPIRV_GLUnaryArithmeticOp<"Log2", 30, SPIRV_Float16or32> {
|
||||
let summary = "Result is the base-2 logarithm of x";
|
||||
|
||||
|
||||
@@ -789,3 +789,29 @@ func.func @tanh_invalid_type(%arg0 : i32) -> () {
|
||||
%0 = spirv.GL.Tanh %arg0 : i32
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// spirv.GL.Exp2
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func.func @exp2(%arg0 : f32) -> () {
|
||||
// CHECK: spirv.GL.Exp2 {{%.*}} : f32
|
||||
%0 = spirv.GL.Exp2 %arg0 : f32
|
||||
return
|
||||
}
|
||||
|
||||
func.func @exp2vec(%arg0 : vector<3xf16>) -> () {
|
||||
// CHECK: spirv.GL.Exp2 {{%.*}} : vector<3xf16>
|
||||
%0 = spirv.GL.Exp2 %arg0 : vector<3xf16>
|
||||
return
|
||||
}
|
||||
|
||||
// -----
|
||||
|
||||
func.func @exp2_invalid_type(%arg0 : i32) -> () {
|
||||
// expected-error @+1 {{op operand #0 must be 16/32-bit float or vector of 16/32-bit float values}}
|
||||
%0 = spirv.GL.Exp2 %arg0 : i32
|
||||
return
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
|
||||
%20 = spirv.GL.Log2 %arg0 : f32
|
||||
// CHECK: {{%.*}} = spirv.GL.Tanh {{%.*}} : f32
|
||||
%21 = spirv.GL.Tanh %arg0 : f32
|
||||
// CHECK: {{%.*}} = spirv.GL.Exp2 {{%.*}} : f32
|
||||
%22 = spirv.GL.Exp2 %arg0 : f32
|
||||
spirv.Return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user