|
71 | 71 | (vector-copy! vprecs 0 vprecs-new)) |
72 | 72 |
|
73 | 73 | ; 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: |
75 | 75 | ; 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)) |
78 | 81 | (define (precision-tuning ivec vregs vprecs-max varc vstart-precs) |
79 | 82 | ; vector stores minimum additional precision that is needed to evaluate an instruction |
80 | 83 | (define vprecs-min (make-vector (vector-length vprecs-max) 0)) |
|
85 | 88 | (define srcs (map (lambda (x) (vector-ref vregs x)) tail-registers)) ; tail of the current instr |
86 | 89 | (define output (vector-ref vregs n)) ; output of the current instr |
87 | 90 |
|
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 |
90 | 93 |
|
91 | 94 | (when (>= min-prec (*rival-max-precision*)) ; Early stopping on lower bound |
92 | 95 | (*sampling-iteration* (*rival-max-iterations*))) |
|
96 | 99 | (max (+ max-prec (vector-ref vstart-precs (- n varc))) (*base-tuning-precision*))) |
97 | 100 | (vector-set! vprecs-max (- n varc) (min final-precision (*rival-max-precision*))) |
98 | 101 |
|
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 |
100 | 103 |
|
101 | 104 | ; Precision propogation for each tail instruction |
102 | 105 | (for ([x (in-list tail-registers)] |
103 | 106 | [bound (in-list ampl-bounds)] |
104 | 107 | #:when (>= x varc)) ; when tail register is not a variable |
105 | 108 | (match-define (list up-bound lo-bound) bound) |
106 | 109 |
|
107 | | - ; Upper bound propogation |
| 110 | + ; Upper precision bound propogation |
108 | 111 | (vector-set! vprecs-max |
109 | 112 | (- x varc) |
110 | 113 | (max (vector-ref vprecs-max (- x varc)) (+ max-prec up-bound))) |
111 | 114 |
|
112 | | - ; Lower bound propogation |
| 115 | + ; Lower precision bound propogation |
113 | 116 | (vector-set! vprecs-min |
114 | 117 | (- 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