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

Flightdeck logit-ensemble

Ensemble two model distributions by a probability-space mixture. Supply a row-constant mixing weight in [0,1].

Source repository · Package JSON

Use Flightdeck logit-ensemble

use vendor::fd_logit_ensemble::logit_ensemble;

Run the example

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

Expected output

module {
  func.func @main(%first: tensor<2x7xf32>, %second: tensor<2x7xf32>, %alpha: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
    %v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
    %v1 = stablehlo.constant dense<-3.40282346000000007e+38> : tensor<f32>
    %v2 = stablehlo.reduce(%first init: %v1) applies stablehlo.maximum across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v3 = stablehlo.broadcast_in_dim %v2, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v4 = stablehlo.subtract %first, %v3 : tensor<2x7xf32>
    %v5 = stablehlo.exponential %v4 : tensor<2x7xf32>
    %v6 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<f32>
    %v7 = stablehlo.reduce(%v5 init: %v6) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v8 = stablehlo.broadcast_in_dim %v7, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v9 = stablehlo.log %v8 : tensor<2x7xf32>
    %v10 = stablehlo.subtract %v4, %v9 : tensor<2x7xf32>
    %v11 = stablehlo.exponential %v10 : tensor<2x7xf32>
    %v12 = stablehlo.reduce(%second init: %v1) applies stablehlo.maximum across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v13 = stablehlo.broadcast_in_dim %v12, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v14 = stablehlo.subtract %second, %v13 : tensor<2x7xf32>
    %v15 = stablehlo.exponential %v14 : tensor<2x7xf32>
    %v16 = stablehlo.reduce(%v15 init: %v6) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v17 = stablehlo.broadcast_in_dim %v16, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v18 = stablehlo.log %v17 : tensor<2x7xf32>
    %v19 = stablehlo.subtract %v14, %v18 : tensor<2x7xf32>
    %v20 = stablehlo.exponential %v19 : tensor<2x7xf32>
    %v21 = stablehlo.multiply %alpha, %v11 : tensor<2x7xf32>
    %v22 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
    %v23 = stablehlo.subtract %v22, %alpha : tensor<2x7xf32>
    %v24 = stablehlo.multiply %v23, %v20 : tensor<2x7xf32>
    %v25 = stablehlo.add %v21, %v24 : tensor<2x7xf32>
    %v26 = stablehlo.constant dense<1.00000000000000008e-30> : tensor<2x7xf32>
    %v27 = stablehlo.maximum %v25, %v26 : tensor<2x7xf32>
    %v28 = stablehlo.log %v27 : tensor<2x7xf32>
    %v29 = stablehlo.multiply %v25, %v28 : tensor<2x7xf32>
    %v30 = stablehlo.reduce(%v29 init: %v6) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v31 = stablehlo.broadcast_in_dim %v30, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v32 = stablehlo.negate %v31 : tensor<2x7xf32>
    return %v25, %v32 : tensor<2x7xf32>, tensor<2x7xf32>
  }
}

Published versions

VersionPackageSource commitSHA-256
0.1.1Download ZIP · Browse filesbf9c3d50039965300f41039e1c507dc102e195c0a30cbe9a8327c3f7a54fb4307f38c42858
0.1.0Download ZIP · Browse filesd5835c510981e372749c2e08657f6cb626f72ae7acc2bf54bbf0883967058c8dafbf257cbc