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

Flightdeck dice-fit

Compute smoothed soft Dice loss over a row and its probability-space gradient. Use targets and predictions in [0,1].

Source repository · Package JSON

Use Flightdeck dice-fit

use vendor::fd_dice_fit::dice_fit;

Run the example

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

Expected output

module {
  func.func @main(%prediction: tensor<2x7xf32>, %target: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
    %v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
    %v1 = stablehlo.constant dense<2.00000000000000000e+00> : tensor<2x7xf32>
    %v2 = stablehlo.multiply %prediction, %target : tensor<2x7xf32>
    %v3 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<f32>
    %v4 = stablehlo.reduce(%v2 init: %v3) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v5 = stablehlo.broadcast_in_dim %v4, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v6 = stablehlo.multiply %v1, %v5 : tensor<2x7xf32>
    %v7 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
    %v8 = stablehlo.add %v6, %v7 : tensor<2x7xf32>
    %v9 = stablehlo.add %prediction, %target : tensor<2x7xf32>
    %v10 = stablehlo.reduce(%v9 init: %v3) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
    %v11 = stablehlo.broadcast_in_dim %v10, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
    %v12 = stablehlo.add %v11, %v7 : tensor<2x7xf32>
    %v13 = stablehlo.divide %v8, %v12 : tensor<2x7xf32>
    %v14 = stablehlo.subtract %v7, %v13 : tensor<2x7xf32>
    %v15 = stablehlo.multiply %v1, %target : tensor<2x7xf32>
    %v16 = stablehlo.multiply %v15, %v12 : tensor<2x7xf32>
    %v17 = stablehlo.subtract %v8, %v16 : tensor<2x7xf32>
    %v18 = stablehlo.multiply %v12, %v12 : tensor<2x7xf32>
    %v19 = stablehlo.divide %v17, %v18 : tensor<2x7xf32>
    return %v14, %v19 : tensor<2x7xf32>, tensor<2x7xf32>
  }
}

Published versions

VersionPackageSource commitSHA-256
0.1.1Download ZIP · Browse filesbf9c3d5003ba96b487d5c67bc70355db41d68e2d926932ab01d372a666b86755ea9aa6dd6d
0.1.0Download ZIP · Browse filesd5835c510975721a44c6a7a923dbbb3dd56659e2f7446fe32cada2c190add64aa92e511521