Registry / Framework

framework · v0.1.1
Flightdeck unit-embeddings
Normalize retrieval embeddings to near-unit length and differentiate a row objective through the normalization.
Use Flightdeck unit-embeddings
use vendor::fd_unit_embeddings::unit_embeddings;
Run the example
nest demo fd_unit_embeddings@0.1.1
blyxc native-run fd_unit_embeddings-demo/main.blyx
Example source and expected output
use vendor::fd_unit_embeddings::unit_embeddings;
fn main() { fd_unit_embeddings(2, 7); }
Expected output
module {
func.func @main(%x: tensor<2x7xf32>, %upstream: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
%v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
%v1 = stablehlo.constant dense<1.00000000000000000e+00> : tensor<2x7xf32>
%v2 = stablehlo.multiply %x, %x : 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.constant dense<9.99999999999999955e-07> : tensor<2x7xf32>
%v7 = stablehlo.add %v5, %v6 : tensor<2x7xf32>
%v8 = stablehlo.sqrt %v7 : tensor<2x7xf32>
%v9 = stablehlo.divide %v1, %v8 : tensor<2x7xf32>
%v10 = stablehlo.multiply %x, %v9 : tensor<2x7xf32>
%v11 = stablehlo.multiply %v10, %upstream : tensor<2x7xf32>
%v12 = stablehlo.reduce(%v11 init: %v3) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
%v13 = stablehlo.broadcast_in_dim %v12, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
%v14 = stablehlo.multiply %v10, %v13 : tensor<2x7xf32>
%v15 = stablehlo.subtract %upstream, %v14 : tensor<2x7xf32>
%v16 = stablehlo.multiply %v9, %v15 : tensor<2x7xf32>
return %v10, %v16 : tensor<2x7xf32>, tensor<2x7xf32>
}
}
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.1 | Download ZIP · Browse files | bf9c3d5003 | acc174627f1ab95094e5b1db82784b84f36c124616a77804c4d6ea47867879bd |
| 0.1.0 | Download ZIP · Browse files | d5835c5109 | 3e90109ec9c3313716944ad59b4be7c7939f33eb10a3492da8917bf1fbc20668 |