Registry / Framework

framework · v0.1.1
Flightdeck clip-row-grad
Clip each gradient row to a supplied positive L2 bound. Repeat the same bound across features in a row.
Use Flightdeck clip-row-grad
use vendor::fd_clip_row_grad::clip_row_grad;
Run the example
nest demo fd_clip_row_grad@0.1.1
blyxc native-run fd_clip_row_grad-demo/main.blyx
Example source and expected output
use vendor::fd_clip_row_grad::clip_row_grad;
fn main() { fd_clip_row_grad(2, 7); }
Expected output
module {
func.func @main(%grad: tensor<2x7xf32>, %bound: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
%v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
%v1 = stablehlo.multiply %grad, %grad : tensor<2x7xf32>
%v2 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<f32>
%v3 = stablehlo.reduce(%v1 init: %v2) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
%v4 = stablehlo.broadcast_in_dim %v3, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
%v5 = stablehlo.sqrt %v4 : tensor<2x7xf32>
%v6 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
%v7 = stablehlo.constant dense<9.99999999999999945e-21> : tensor<2x7xf32>
%v8 = stablehlo.maximum %v5, %v7 : tensor<2x7xf32>
%v9 = stablehlo.divide %bound, %v8 : tensor<2x7xf32>
%v10 = stablehlo.minimum %v6, %v9 : tensor<2x7xf32>
%v11 = stablehlo.multiply %grad, %v10 : tensor<2x7xf32>
return %v11, %v5 : tensor<2x7xf32>, tensor<2x7xf32>
}
}
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.1 | Download ZIP · Browse files | bf9c3d5003 | c22febb3ce7c7bce99ff11779ce236fc7465538772d4ffc2e98017cd49e711a1 |
| 0.1.0 | Download ZIP · Browse files | d5835c5109 | 2843cadad251364adb08b3389a21ce2224636c8ba26d9f88016ca12f1ccbd2ec |