Skip to content

Commit

Permalink
Inlined point-error (maybe faster?)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavpanchekha committed Oct 1, 2024
1 parent a75f6ea commit 2e7af4a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/points.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@
;; Herbie's standard error measure is the average bits of error across
;; all points in a pcontext.

(define (point-error out exact repr)
(if ((representation-special-value? repr) out)
(+ 1 (expt 2 (representation-total-bits repr)))
(ulp-difference out exact repr)))

(define (average . s)
(/ (apply + s) (length s)))

Expand All @@ -72,9 +67,15 @@

(define (batch-errors exprs pcontext ctx)
(define fn (compile-progs exprs ctx))
(define repr (context-repr ctx))
(define special? (representation-special-value? repr))
(define max-error (+ 1 (expt 2 (representation-total-bits repr))))

(for/list ([(point exact) (in-pcontext pcontext)])
(for/list ([out (in-vector (apply fn point))])
(point-error out exact (context-repr ctx)))))
(if (special? out)
max-error
(ulp-difference out exact repr)))))

;; Herbie <=> JSON conversion for pcontext
;; A JSON pcontext is just a list of lists
Expand Down

0 comments on commit 2e7af4a

Please sign in to comment.