// Downweight large regression residuals using a unit-scale Cauchy objective. use graph_io; pub fn fd_cauchy_fit(rows: i64, width: i64) { println!("module {"); fd_line(" func.func @main(%x: tensor, %target: tensor) -> (tensor, tensor) {", rows, width); fd_line(" %v0 = stablehlo.constant dense<0.00000000000000000e+00> : tensor", rows, width); fd_line(" %v1 = stablehlo.subtract %x, %target : tensor", rows, width); // r = x-target fd_line(" %v2 = stablehlo.constant dense<5.00000000000000000e-01> : tensor", rows, width); fd_line(" %v3 = stablehlo.multiply %v1, %v1 : tensor", rows, width); fd_line(" %v4 = stablehlo.log_plus_one %v3 : tensor", rows, width); fd_line(" %v5 = stablehlo.multiply %v2, %v4 : tensor", rows, width); // loss = 0.5*log1p(r*r) fd_line(" %v6 = stablehlo.constant dense<1.00000000000000000e+00> : tensor", rows, width); fd_line(" %v7 = stablehlo.add %v6, %v3 : tensor", rows, width); fd_line(" %v8 = stablehlo.divide %v1, %v7 : tensor", rows, width); // grad = r/(1+r*r) fd_line(" return %v5, %v8 : tensor, tensor", rows, width); println!(" }"); println!("}"); }