Skip to content

Commit 373dcb5

Browse files
committed
a little bug + comments
1 parent 9cc1641 commit 373dcb5

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

eval/adjust.rkt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,13 @@
7171
(vector-copy! vprecs 0 vprecs-new))
7272

7373
; This function goes through ivec and vregs and calculates (+ ampls base-precisions) for each operator in ivec
74-
; Roughly speaking:
74+
; Roughly speaking, the upper precision bound is calculated as:
7575
; vprecs-max[i] = min( *rival-max-precision*
76-
; max( *base-tuning-precision* (+ parent-prec-upper-bound vstart-precs[i])),
77-
; parent-prec-upper-bound = (car (get-bounds(parent)))
76+
; max( *base-tuning-precision* (+ max-prec vstart-precs[i])),
77+
; max-prec = (car (get-bounds parent))
78+
; While lower precision bound is calculated as:
79+
; vprecs-min[i] = max( min-prec vprecs-min[i] )
80+
; min-prec = (cdr (get-bounds parent))
7881
(define (precision-tuning ivec vregs vprecs-max varc vstart-precs)
7982
; vector stores minimum additional precision that is needed to evaluate an instruction
8083
(define vprecs-min (make-vector (vector-length vprecs-max) 0))
@@ -85,8 +88,8 @@
8588
(define srcs (map (lambda (x) (vector-ref vregs x)) tail-registers)) ; tail of the current instr
8689
(define output (vector-ref vregs n)) ; output of the current instr
8790

88-
(define max-prec (vector-ref vprecs-max (- n varc))) ; intro for the current instruction
89-
(define min-prec (vector-ref vprecs-min (- n varc)))
91+
(define max-prec (vector-ref vprecs-max (- n varc))) ; upper precision bound given from parent
92+
(define min-prec (vector-ref vprecs-min (- n varc))) ; lower precision bound given from parent
9093

9194
(when (>= min-prec (*rival-max-precision*)) ; Early stopping on lower bound
9295
(*sampling-iteration* (*rival-max-iterations*)))
@@ -96,20 +99,20 @@
9699
(max (+ max-prec (vector-ref vstart-precs (- n varc))) (*base-tuning-precision*)))
97100
(vector-set! vprecs-max (- n varc) (min final-precision (*rival-max-precision*)))
98101

99-
(define ampl-bounds (get-bounds op output srcs)) ; ampl bounds for children instructions
102+
(define ampl-bounds (get-bounds op output srcs)) ; amplification bounds for children instructions
100103

101104
; Precision propogation for each tail instruction
102105
(for ([x (in-list tail-registers)]
103106
[bound (in-list ampl-bounds)]
104107
#:when (>= x varc)) ; when tail register is not a variable
105108
(match-define (list up-bound lo-bound) bound)
106109

107-
; Upper bound propogation
110+
; Upper precision bound propogation
108111
(vector-set! vprecs-max
109112
(- x varc)
110113
(max (vector-ref vprecs-max (- x varc)) (+ max-prec up-bound)))
111114

112-
; Lower bound propogation
115+
; Lower precision bound propogation
113116
(vector-set! vprecs-min
114117
(- x varc)
115-
(min (vector-ref vprecs-min (- x varc)) (+ min-prec lo-bound))))))
118+
(max (vector-ref vprecs-min (- x varc)) (+ min-prec lo-bound))))))

0 commit comments

Comments
 (0)