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

Flightdeck weighted-accumulation

Merge two per-example mean gradients using their counts, then emit the merged mean and new count. Nonnegative counts are row constants.

Source repository · Package JSON

Use Flightdeck weighted-accumulation

use vendor::fd_weighted_accumulation::weighted_accumulation;

Run the example

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

Expected output

module {
  func.func @main(%first: tensor<2x7xf32>, %second: tensor<2x7xf32>, %count1: tensor<2x7xf32>, %count2: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
    %v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
    %v1 = stablehlo.add %count1, %count2 : tensor<2x7xf32>
    %v2 = stablehlo.multiply %first, %count1 : tensor<2x7xf32>
    %v3 = stablehlo.multiply %second, %count2 : tensor<2x7xf32>
    %v4 = stablehlo.add %v2, %v3 : tensor<2x7xf32>
    %v5 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
    %v6 = stablehlo.maximum %v1, %v5 : tensor<2x7xf32>
    %v7 = stablehlo.divide %v4, %v6 : tensor<2x7xf32>
    return %v7, %v1 : tensor<2x7xf32>, tensor<2x7xf32>
  }
}

Published versions

VersionPackageSource commitSHA-256
0.1.1Download ZIP · Browse filesbf9c3d5003cc2b417ca0599df40242c3dd742b9ead745d10d0d33c7809d6bded9340b6bd04
0.1.0Download ZIP · Browse filesd5835c5109bc7cb35a1e7165ca95a3a816413d4f5b5277d14a6df79d3f7ce48f853f4a385b