Compare commits

...

2 Commits

Author SHA1 Message Date
github-actions[bot]
7490019249 ci: update version string in docs 2025-03-17 14:47:02 +00:00
dante
1bef92407c fix: recip denom epsilon can induce non opt res (#957) 2025-03-17 14:46:33 +00:00
2 changed files with 6 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
import ezkl
project = 'ezkl'
release = '0.0.0'
release = '20.2.7'
version = release

View File

@@ -2346,7 +2346,11 @@ pub mod nonlinearities {
pub fn recip(a: &Tensor<IntegerRep>, input_scale: f64, out_scale: f64) -> Tensor<IntegerRep> {
a.par_enum_map(|_, a_i| {
let rescaled = (a_i as f64) / input_scale;
let denom = (1_f64) / (rescaled + f64::EPSILON);
let denom = if rescaled == 0_f64 {
(1_f64) / (rescaled + f64::EPSILON)
} else {
(1_f64) / (rescaled)
};
let d_inv_x = out_scale * denom;
Ok::<_, TensorError>(d_inv_x.round() as IntegerRep)
})