@@ -247,6 +247,28 @@ func.func @rms_layer_norm_v2(%x: tensor<1x384x768xf32>, %scale: tensor<768xf32>,
247247
248248// -----
249249
250+ // RMS Layer norm with multiple uses of the scale multiplication
251+ func.func @rms_layer_norm_multi_use (%x: tensor <1 x384 x768 xf32 >, %scale: tensor <768 xf32 >) -> (tensor <1 x384 x768 xf32 >) {
252+ %eps = onnx.Constant dense <9.99999974E-6 > : tensor <f32 >
253+ %dd = " onnx.Mul" (%x , %x ) : (tensor <1 x384 x768 xf32 >, tensor <1 x384 x768 xf32 >) -> tensor <1 x384 x768 xf32 >
254+ %var = " onnx.ReduceMeanV13" (%dd ) {axes = [-1 ], keepdims = 1 : si64 , onnx_node_name = " ReduceMean_42" } : (tensor <1 x384 x768 xf32 >) -> tensor <1 x384 x1 xf32 >
255+ %varEps = " onnx.Add" (%eps , %var ) : (tensor <f32 >, tensor <1 x384 x1 xf32 >) -> tensor <1 x384 x1 xf32 >
256+ %StdDev = " onnx.Sqrt" (%varEps ) : (tensor <1 x384 x1 xf32 >) -> tensor <1 x384 x1 xf32 >
257+ %Norm = " onnx.Div" (%x , %StdDev ) : (tensor <1 x384 x768 xf32 >, tensor <1 x384 x1 xf32 >) -> tensor <1 x384 x768 xf32 >
258+ %NormScaled = " onnx.Mul" (%scale , %Norm ) : (tensor <768 xf32 >, tensor <1 x384 x768 xf32 >) -> tensor <1 x384 x768 xf32 >
259+ %MultiUse = " onnx.Add" (%NormScaled , %NormScaled ) : (tensor <1 x384 x768 xf32 >, tensor <1 x384 x768 xf32 >) -> tensor <1 x384 x768 xf32 >
260+ return %MultiUse : tensor <1 x384 x768 xf32 >
261+ // CHECK-LABEL: func.func @rms_layer_norm_multi_use
262+ // CHECK-SAME: ([[PARAM_0_:%.+]]: tensor<1x384x768xf32>, [[PARAM_1_:%.+]]: tensor<768xf32>) -> tensor<1x384x768xf32> {
263+ // CHECK: [[VAR_0_:%.+]] = "onnx.NoValue"() {value} : () -> none
264+ // CHECK: [[VAR_Y_:%.+]], [[VAR_InvStdDev_:%.+]] = "onnx.RMSLayerNormalization"([[PARAM_0_]], [[PARAM_1_]], [[VAR_0_]]) {axis = 2 : si64, epsilon = 9.99999974E-6 : f32, stash_type = 1 : si64} : (tensor<1x384x768xf32>, tensor<768xf32>, none) -> (tensor<1x384x768xf32>, none)
265+ // CHECK: [[VAR_1_:%.+]] = "onnx.Add"([[VAR_Y_]], [[VAR_Y_]]) : (tensor<1x384x768xf32>, tensor<1x384x768xf32>) -> tensor<1x384x768xf32>
266+ // CHECK: return [[VAR_1_]] : tensor<1x384x768xf32>
267+ // CHECK: }
268+ }
269+
270+ // -----
271+
250272// COM: QLinearMatMul
251273func.func @qlinear_matmul (%arg0: tensor <?x?x768 xi8 >, %arg1: tensor <f32 >, %arg2: tensor <i8 >, %arg3: tensor <768 x768 xi8 >, %arg4: tensor <f32 >, %arg5: tensor <i8 >, %arg6: tensor <f32 >, %arg7: tensor <i8 >) -> (tensor <?x?x768 xi8 >) {
252274 %0 = " onnx.DequantizeLinear" (%arg0 , %arg1 , %arg2 ) {axis = 1 : si64 } : (tensor <?x?x768 xi8 >, tensor <f32 >, tensor <i8 >) -> tensor <?x?x768 xf32 >
0 commit comments