Skip to content

Commit 2077e0b

Browse files
committed
calculating maxlog, minlog and logspan once
1 parent d3f323a commit 2077e0b

File tree

2 files changed

+160
-116
lines changed

2 files changed

+160
-116
lines changed

eval/adjust.rkt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"../ops/all.rkt"
55
"machine.rkt"
66
racket/list
7-
racket/match)
7+
racket/match
8+
racket/vector
9+
racket/function)
810

911
(provide backward-pass
1012
make-hint)
@@ -235,15 +237,20 @@
235237
; max-prec = (car (get-bounds parent))
236238
(define (precision-tuning ivec vregs vprecs-max varc vstart-precs vrepeats vhint)
237239
(define vprecs-min (make-vector (vector-length ivec) 0))
240+
241+
(define slack (get-slack))
242+
(define vlogs (vector-map (curryr minlog+maxlog+logspan slack) vregs))
243+
238244
(for ([instr (in-vector ivec (- (vector-length ivec) 1) -1 -1)]
239245
[repeat? (in-vector vrepeats (- (vector-length vrepeats) 1) -1 -1)]
240246
[n (in-range (- (vector-length vregs) 1) -1 -1)]
241247
[hint (in-vector vhint (- (vector-length vhint) 1) -1 -1)]
242248
[output (in-vector vregs (- (vector-length vregs) 1) -1 -1)]
249+
[logs (in-vector vlogs (- (vector-length vlogs) 1) -1 -1)]
243250
#:when (and hint (not repeat?)))
244251
(define op (car instr))
245252
(define tail-registers (drop-self-pointer (cdr instr) n))
246-
(define srcs (map (lambda (x) (vector-ref vregs x)) tail-registers))
253+
(define srcs (map (lambda (x) (cons (vector-ref vregs x) (vector-ref vlogs x))) tail-registers))
247254

248255
(define max-prec (vector-ref vprecs-max (- n varc))) ; upper precision bound given from parent
249256
(define min-prec (vector-ref vprecs-min (- n varc))) ; lower precision bound given from parent
@@ -264,7 +271,8 @@
264271
(*sampling-iteration* (*rival-max-iterations*)))])
265272

266273
; Precision propogation for each tail instruction
267-
(define ampl-bounds (get-bounds op output srcs)) ; amplification bounds for children instructions
274+
(define ampl-bounds
275+
(get-bounds op (cons output logs) srcs)) ; amplification bounds for children instructions
268276
(for ([x (in-list tail-registers)]
269277
[bound (in-list ampl-bounds)]
270278
#:when (>= x varc)) ; when tail register is not a variable

0 commit comments

Comments
 (0)