Registry / Framework

framework · v0.1.1
Flightdeck lars-step
Scale each parameter row by a LARS trust ratio before an SGD step. Zero norms fall back to unit scaling.
Use Flightdeck lars-step
use vendor::fd_lars_step::lars_step;
Run the example
nest demo fd_lars_step@0.1.1
blyxc native-run fd_lars_step-demo/main.blyx
Example source and expected output
use vendor::fd_lars_step::lars_step;
fn main() { fd_lars_step(2, 7); }
Expected output
module {
func.func @main(%weight: tensor<2x7xf32>, %grad: tensor<2x7xf32>, %lr: tensor<2x7xf32>, %decay: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
%v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
%v1 = stablehlo.multiply %decay, %weight : tensor<2x7xf32>
%v2 = stablehlo.add %grad, %v1 : tensor<2x7xf32>
%v3 = stablehlo.multiply %weight, %weight : 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.sqrt %v6 : tensor<2x7xf32>
%v8 = stablehlo.multiply %v2, %v2 : tensor<2x7xf32>
%v9 = stablehlo.reduce(%v8 init: %v4) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
%v10 = stablehlo.broadcast_in_dim %v9, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
%v11 = stablehlo.sqrt %v10 : tensor<2x7xf32>
%v12 = stablehlo.multiply %v7, %v11 : tensor<2x7xf32>
%v13 = stablehlo.compare GT, %v12, %v0, FLOAT : (tensor<2x7xf32>, tensor<2x7xf32>) -> tensor<2x7xi1>
%v14 = stablehlo.constant dense<1.00000000000000002e-03> : tensor<2x7xf32>
%v15 = stablehlo.multiply %v14, %v7 : tensor<2x7xf32>
%v16 = stablehlo.constant dense<9.99999999999999945e-21> : tensor<2x7xf32>
%v17 = stablehlo.maximum %v11, %v16 : tensor<2x7xf32>
%v18 = stablehlo.divide %v15, %v17 : tensor<2x7xf32>
%v19 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
%v20 = stablehlo.select %v13, %v18, %v19 : tensor<2x7xi1>, tensor<2x7xf32>
%v21 = stablehlo.multiply %lr, %v20 : tensor<2x7xf32>
%v22 = stablehlo.multiply %v21, %v2 : tensor<2x7xf32>
%v23 = stablehlo.subtract %weight, %v22 : tensor<2x7xf32>
return %v23, %v20 : tensor<2x7xf32>, tensor<2x7xf32>
}
}
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.1 | Download ZIP · Browse files | bf9c3d5003 | 936ae06d15877daa0fb8819060c20cd79eee7e6751af9afa968c703132578eed |
| 0.1.0 | Download ZIP · Browse files | d5835c5109 | 8d8434bbfd11a8be761694da33dba26a91d91af162a91512ade050e28b7f9610 |