// Fit nonnegative counts using a log-rate prediction. Returns Poisson NLL without the target-only factorial term and the log-rate gradient. use graph_io; pub fn fd_poisson_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.exponential %x : tensor", rows, width); // rate = exp(x) fd_line(" %v2 = stablehlo.multiply %target, %x : tensor", rows, width); fd_line(" %v3 = stablehlo.subtract %v1, %v2 : tensor", rows, width); // loss = rate-target*x fd_line(" %v4 = stablehlo.subtract %v1, %target : tensor", rows, width); // grad = rate-target fd_line(" return %v3, %v4 : tensor, tensor", rows, width); println!(" }"); println!("}"); }