Blyx Nest Blyx language
Registry / Framework
framework · v0.1.1

Flightdeck residual-rms

Fuse a residual addition with pre-normalization and return the combined residual stream and scaled output.

Source repository · Package JSON

Use Flightdeck residual-rms

use vendor::fd_residual_rms::residual_rms;

Run the example

nest demo fd_residual_rms@0.1.1
blyxc native-run fd_residual_rms-demo/main.blyx
Example source and expected output
use vendor::fd_residual_rms::residual_rms;
fn main() { fd_residual_rms(2, 7); }

Expected output

module {
  func.func @main(%x: tensor<2x7xf32>, %residual: tensor<2x7xf32>, %gain: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
    %v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
    %v1 = stablehlo.add %x, %residual : tensor<2x7xf32>
    %v2 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
    %v3 = stablehlo.multiply %v1, %v1 : tensor<2x7xf32>
    %v4 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<f32>
    %v5 = stablehlo.reduce(%v3 init: %v4) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v6 = stablehlo.broadcast_in_dim %v5, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v7 = stablehlo.constant dense<7.0> : tensor<2x7xf32>
    %v8 = stablehlo.divide %v6, %v7 : tensor<2x7xf32>
    %v9 = stablehlo.constant dense<1.00000000000000008e-05> : tensor<2x7xf32>
    %v10 = stablehlo.add %v8, %v9 : tensor<2x7xf32>
    %v11 = stablehlo.sqrt %v10 : tensor<2x7xf32>
    %v12 = stablehlo.divide %v2, %v11 : tensor<2x7xf32>
    %v13 = stablehlo.multiply %v1, %v12 : tensor<2x7xf32>
    %v14 = stablehlo.multiply %v13, %gain : tensor<2x7xf32>
    return %v1, %v14 : tensor<2x7xf32>, tensor<2x7xf32>
  }
}

Published versions

VersionPackageSource commitSHA-256
0.1.1Download ZIP · Browse filesbf9c3d5003e63f5be3ccdebe33e8cb8a2d14a896f59cd59e4b59c8d04e3ce4b2cfa7a0e092
0.1.0Download ZIP · Browse filesd5835c5109201637d675373db68ab6be3c85e845af276f2123370bd9d67e4b2db4d4e166a2