|
55 | 55 | [outputs (in-list simplification-options)]) |
56 | 56 | (match-define (cons _ simplified) outputs) |
57 | 57 | (define prev (car (alt-prevs altn))) |
58 | | - (for ([batchreff (in-list simplified)]) |
59 | | - (define spec (prog->spec (debatchref (alt-expr prev)))) |
60 | | - (define idx ; Munge |
61 | | - (mutable-batch-push! global-batch-mutable |
62 | | - (approx (mutable-batch-munge! global-batch-mutable spec) |
63 | | - (batchref-idx batchreff)))) |
64 | | - (sow (alt (batchref global-batch idx) `(simplify ,runner #f) (list altn) '())))) |
| 58 | + (for ([bref (in-list simplified)]) |
| 59 | + (sow (alt bref `(simplify ,runner #f) (list altn) '())))) |
65 | 60 | (batch-copy-mutable-nodes! global-batch global-batch-mutable))) ; Update global-batch |
66 | 61 |
|
67 | 62 | (timeline-push! 'count (length approxs) (length simplified)) |
|
80 | 75 | #;(log ,log-x ,exp-x)))) |
81 | 76 |
|
82 | 77 | (define (taylor-alts starting-exprs altns global-batch) |
83 | | - (define exprs |
84 | | - (for/list ([expr (in-list starting-exprs)]) |
85 | | - (prog->spec expr))) |
86 | | - (define free-vars (map free-variables exprs)) |
| 78 | + (define specs (map prog->spec starting-exprs)) |
| 79 | + (define free-vars (map free-variables specs)) |
87 | 80 | (define vars (context-vars (*context*))) |
88 | 81 |
|
89 | 82 | (reap [sow] |
90 | 83 | (define global-batch-mutable (batch->mutable-batch global-batch)) ; Create a mutable batch |
91 | 84 | (for* ([var (in-list vars)] |
92 | 85 | [transform-type transforms-to-try]) |
93 | 86 | (match-define (list name f finv) transform-type) |
94 | | - (define timeline-stop! (timeline-start! 'series (~a exprs) (~a var) (~a name))) |
95 | | - (define genexprs (approximate exprs var #:transform (cons f finv))) |
| 87 | + (define timeline-stop! (timeline-start! 'series (~a specs) (~a var) (~a name))) |
| 88 | + (define genexprs (approximate specs var #:transform (cons f finv))) |
96 | 89 | (for ([genexpr (in-list genexprs)] |
| 90 | + [spec (in-list specs)] |
| 91 | + [expr (in-list starting-exprs)] |
97 | 92 | [altn (in-list altns)] |
98 | 93 | [fv (in-list free-vars)] |
99 | | - #:when (member var fv)) ; check whether var exists in expr at all |
| 94 | + #:when (set-member? fv var)) ; check whether var exists in expr at all |
100 | 95 | (for ([i (in-range (*taylor-order-limit*))]) |
101 | | - (define gen (genexpr)) |
| 96 | + (define repr (repr-of expr (*context*))) |
| 97 | + (define gen (approx spec (hole (representation-name repr) (genexpr)))) |
102 | 98 | (define idx (mutable-batch-munge! global-batch-mutable gen)) ; Munge gen |
103 | 99 | (sow (alt (batchref global-batch idx) `(taylor ,name ,var) (list altn) '())))) |
104 | 100 | (timeline-stop!)) |
|
0 commit comments