Registry / Framework

framework · v0.1.1
Flightdeck ternary-compress
Threshold small gradient coordinates and reconstruct retained signs with their mean absolute magnitude. Supply a nonnegative per-row threshold.
Use Flightdeck ternary-compress
use vendor::fd_ternary_compress::ternary_compress;
Run the example
nest demo fd_ternary_compress@0.1.1
blyxc native-run fd_ternary_compress-demo/main.blyx
Example source and expected output
use vendor::fd_ternary_compress::ternary_compress;
fn main() { fd_ternary_compress(2, 7); }
Expected output
module {
func.func @main(%grad: tensor<2x7xf32>, %threshold: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>, tensor<2x7xf32>) {
%v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
%v1 = stablehlo.abs %grad : tensor<2x7xf32>
%v2 = stablehlo.compare GT, %v1, %threshold, FLOAT : (tensor<2x7xf32>, tensor<2x7xf32>) -> tensor<2x7xi1>
%v3 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
%v4 = stablehlo.select %v2, %v3, %v0 : tensor<2x7xi1>, tensor<2x7xf32>
%v5 = stablehlo.multiply %v1, %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.reduce(%v4 init: %v6) 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.maximum %v10, %v3 : tensor<2x7xf32>
%v12 = stablehlo.divide %v8, %v11 : tensor<2x7xf32>
%v13 = stablehlo.sign %grad : tensor<2x7xf32>
%v14 = stablehlo.multiply %v13, %v4 : tensor<2x7xf32>
%v15 = stablehlo.multiply %v12, %v14 : tensor<2x7xf32>
return %v14, %v15, %v12 : tensor<2x7xf32>, tensor<2x7xf32>, tensor<2x7xf32>
}
}
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.1 | Download ZIP · Browse files | bf9c3d5003 | efe3f39f2742c8db0d375a2175fa4cd3d21c629eea2bb3dddfb1c4dfa7e5907a |
| 0.1.0 | Download ZIP · Browse files | d5835c5109 | 36c9cd3b547e8c548083080e3a1d659fc47a6bfe74a6eb0f0829180a09de5c00 |