Skip to content

Commit 521277c

Browse files
authored
[mlir][spirv] Add CL.mix op (#72800)
1 parent b84fe8f commit 521277c

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

mlir/include/mlir/Dialect/SPIRV/IR/SPIRVCLOps.td

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,37 @@ class SPIRV_CLTernaryArithmeticOp<string mnemonic, int opcode, Type type,
111111

112112

113113

114+
// -----
115+
116+
def SPIRV_CLMixOp : SPIRV_CLTernaryArithmeticOp<"mix", 99, SPIRV_Float> {
117+
let summary = "Returns the linear blend of x & y implemented as: x + (y - x) * a";
118+
119+
let description = [{
120+
Result Type, x, y and a must be floating-point or vector(2,3,4,8,16) of
121+
floating-point values.
122+
123+
All of the operands, including the Result Type operand, must be of the
124+
same type.
125+
126+
Note: This instruction can be implemented using contractions such as mad
127+
or fma.
128+
129+
<!-- End of AutoGen section -->
130+
131+
```
132+
mix-op ::= ssa-id `=` `spirv.CL.mix` ssa-use, ssa-use, ssa-use `:`
133+
float-scalar-vector-type
134+
```
135+
136+
#### Example:
137+
138+
```mlir
139+
%0 = spirv.CL.mix %a, %b, %c : f32
140+
%1 = spirv.CL.mix %a, %b, %c : vector<3xf16>
141+
```
142+
}];
143+
}
144+
114145
// -----
115146

116147
def SPIRV_CLCeilOp : SPIRV_CLUnaryArithmeticOp<"ceil", 12, SPIRV_Float> {

mlir/test/Dialect/SPIRV/IR/ocl-ops.mlir

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,26 @@ func.func @fma(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> ()
188188

189189
// -----
190190

191+
//===----------------------------------------------------------------------===//
192+
// spirv.CL.mix
193+
//===----------------------------------------------------------------------===//
194+
195+
func.func @mix(%a : f32, %b : f32, %c : f32) -> () {
196+
// CHECK: spirv.CL.mix {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : f32
197+
%2 = spirv.CL.mix %a, %b, %c : f32
198+
return
199+
}
200+
201+
// -----
202+
203+
func.func @mix(%a : vector<3xf32>, %b : vector<3xf32>, %c : vector<3xf32>) -> () {
204+
// CHECK: spirv.CL.mix {{%[^,]*}}, {{%[^,]*}}, {{%[^,]*}} : vector<3xf32>
205+
%2 = spirv.CL.mix %a, %b, %c : vector<3xf32>
206+
return
207+
}
208+
209+
// -----
210+
191211
//===----------------------------------------------------------------------===//
192212
// spirv.CL.{F|S|U}{Max|Min}
193213
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)