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

Flightdeck geglu-backward

Use a tanh-approximate GELU gate and propagate both value and gate derivatives.

Source repository · Package JSON

Use Flightdeck geglu-backward

use vendor::fd_geglu_backward::geglu_backward;

Run the example

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

Expected output

module {
  func.func @main(%x: tensor<2x7xf32>, %gate: tensor<2x7xf32>, %upstream: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>, tensor<2x7xf32>) {
    %v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
    %v1 = stablehlo.constant dense<7.97884560800000031e-01> : tensor<2x7xf32>
    %v2 = stablehlo.constant dense<4.47149999999999978e-02> : tensor<2x7xf32>
    %v3 = stablehlo.multiply %v2, %gate : tensor<2x7xf32>
    %v4 = stablehlo.multiply %v3, %gate : tensor<2x7xf32>
    %v5 = stablehlo.multiply %v4, %gate : tensor<2x7xf32>
    %v6 = stablehlo.add %gate, %v5 : tensor<2x7xf32>
    %v7 = stablehlo.multiply %v1, %v6 : tensor<2x7xf32>
    %v8 = stablehlo.tanh %v7 : tensor<2x7xf32>
    %v9 = stablehlo.constant dense<5.00000000000000000e-01> : tensor<2x7xf32>
    %v10 = stablehlo.multiply %v9, %gate : tensor<2x7xf32>
    %v11 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
    %v12 = stablehlo.add %v11, %v8 : tensor<2x7xf32>
    %v13 = stablehlo.multiply %v10, %v12 : tensor<2x7xf32>
    %v14 = stablehlo.multiply %x, %v13 : tensor<2x7xf32>
    %v15 = stablehlo.multiply %upstream, %v13 : tensor<2x7xf32>
    %v16 = stablehlo.multiply %upstream, %x : tensor<2x7xf32>
    %v17 = stablehlo.multiply %v9, %v12 : tensor<2x7xf32>
    %v18 = stablehlo.multiply %v8, %v8 : tensor<2x7xf32>
    %v19 = stablehlo.subtract %v11, %v18 : tensor<2x7xf32>
    %v20 = stablehlo.multiply %v10, %v19 : tensor<2x7xf32>
    %v21 = stablehlo.multiply %v20, %v1 : tensor<2x7xf32>
    %v22 = stablehlo.constant dense<1.34144999999999986e-01> : tensor<2x7xf32>
    %v23 = stablehlo.multiply %v22, %gate : tensor<2x7xf32>
    %v24 = stablehlo.multiply %v23, %gate : tensor<2x7xf32>
    %v25 = stablehlo.add %v11, %v24 : tensor<2x7xf32>
    %v26 = stablehlo.multiply %v21, %v25 : tensor<2x7xf32>
    %v27 = stablehlo.add %v17, %v26 : tensor<2x7xf32>
    %v28 = stablehlo.multiply %v16, %v27 : tensor<2x7xf32>
    return %v14, %v15, %v28 : tensor<2x7xf32>, tensor<2x7xf32>, tensor<2x7xf32>
  }
}

Published versions

VersionPackageSource commitSHA-256
0.1.1Download ZIP · Browse filesbf9c3d50035bd39b5fe63cd852b5d75f78ca6de874949b9e291dfa28daf6a2820359195bec
0.1.0Download ZIP · Browse filesd5835c5109fbcb65d7c84d9e347f86edc30679870eda715fd92f4dd99bb75d33221d4d9087