Registry / Framework

framework · v0.1.1
Flightdeck teacher-fit
Distil a teacher into student logits with temperature two and the temperature-squared loss convention.
Use Flightdeck teacher-fit
use vendor::fd_teacher_fit::teacher_fit;
Run the example
nest demo fd_teacher_fit@0.1.1
blyxc native-run fd_teacher_fit-demo/main.blyx
Example source and expected output
use vendor::fd_teacher_fit::teacher_fit;
fn main() { fd_teacher_fit(2, 7); }
Expected output
module {
func.func @main(%student: tensor<2x7xf32>, %teacher: tensor<2x7xf32>) -> (tensor<2x7xf32>, tensor<2x7xf32>) {
%v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<2x7xf32>
%v1 = stablehlo.constant dense<2.00000000000000000e+00> : tensor<2x7xf32>
%v2 = stablehlo.divide %student, %v1 : tensor<2x7xf32>
%v3 = stablehlo.constant dense<-3.40282346000000007e+38> : tensor<f32>
%v4 = stablehlo.reduce(%v2 init: %v3) applies stablehlo.maximum across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
%v5 = stablehlo.broadcast_in_dim %v4, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
%v6 = stablehlo.subtract %v2, %v5 : tensor<2x7xf32>
%v7 = stablehlo.exponential %v6 : tensor<2x7xf32>
%v8 = stablehlo.constant dense<0.00000000000000000e+00> : tensor<f32>
%v9 = stablehlo.reduce(%v7 init: %v8) 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.log %v10 : tensor<2x7xf32>
%v12 = stablehlo.subtract %v6, %v11 : tensor<2x7xf32>
%v13 = stablehlo.divide %teacher, %v1 : tensor<2x7xf32>
%v14 = stablehlo.reduce(%v13 init: %v3) applies stablehlo.maximum across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
%v15 = stablehlo.broadcast_in_dim %v14, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
%v16 = stablehlo.subtract %v13, %v15 : tensor<2x7xf32>
%v17 = stablehlo.exponential %v16 : tensor<2x7xf32>
%v18 = stablehlo.reduce(%v17 init: %v8) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
%v19 = stablehlo.broadcast_in_dim %v18, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
%v20 = stablehlo.log %v19 : tensor<2x7xf32>
%v21 = stablehlo.subtract %v16, %v20 : tensor<2x7xf32>
%v22 = stablehlo.constant dense<4.00000000000000000e+00> : tensor<2x7xf32>
%v23 = stablehlo.exponential %v21 : tensor<2x7xf32>
%v24 = stablehlo.subtract %v21, %v12 : tensor<2x7xf32>
%v25 = stablehlo.multiply %v23, %v24 : tensor<2x7xf32>
%v26 = stablehlo.reduce(%v25 init: %v8) applies stablehlo.add across dimensions = [1] : (tensor<2x7xf32>, tensor<f32>) -> tensor<2xf32>
%v27 = stablehlo.broadcast_in_dim %v26, dims = [0] : (tensor<2xf32>) -> tensor<2x7xf32>
%v28 = stablehlo.multiply %v22, %v27 : tensor<2x7xf32>
%v29 = stablehlo.exponential %v12 : tensor<2x7xf32>
%v30 = stablehlo.subtract %v29, %v23 : tensor<2x7xf32>
%v31 = stablehlo.multiply %v1, %v30 : tensor<2x7xf32>
return %v28, %v31 : tensor<2x7xf32>, tensor<2x7xf32>
}
}
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.1 | Download ZIP · Browse files | bf9c3d5003 | 6b3bb65597b947ccb4dffda97ba5c7e6092d6b36da6c4cc27137cef7f5904de5 |
| 0.1.0 | Download ZIP · Browse files | d5835c5109 | 28737d73906e5cd6bdfe68edbfbea91c2a9b877bf1ea7c8fbc35092b4e6e1b7a |