Skip to content

Commit d3ddc1e

Browse files
authored
Merge pull request #1291 from herbie-fp/unused-stuff
Minor reorganizations
2 parents 9dd1411 + 0219f07 commit d3ddc1e

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

src/core/egg-herbie.rkt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@
312312
(egg-parsed->expr (flatten-let egg-expr) ctx (context-repr ctx)))
313313

314314
(module+ test
315-
(*context* (make-debug-context '(x y z)))
315+
(define ctx (make-debug-context '(x y z)))
316316

317317
(define test-exprs
318318
(list (cons '(+.f64 y x) '(+.f64 $var1 $var0))
@@ -327,12 +327,12 @@
327327

328328
(let ([egg-graph (make-egraph-data)])
329329
(for ([(in expected-out) (in-dict test-exprs)])
330-
(define out (expr->egg-expr in (*context*)))
331-
(define computed-in (egg-expr->expr out (*context*)))
330+
(define out (expr->egg-expr in ctx))
331+
(define computed-in (egg-expr->expr out ctx))
332332
(check-equal? out expected-out)
333333
(check-equal? computed-in in)))
334334

335-
(*context* (make-debug-context '(x a b c r)))
335+
(set! ctx (make-debug-context '(x a b c r)))
336336
(define extended-expr-list
337337
; specifications
338338
(list '(/ (- (exp x) (exp (neg x))) 2)
@@ -355,8 +355,8 @@
355355

356356
(let ([egg-graph (make-egraph-data)])
357357
(for ([expr extended-expr-list])
358-
(define egg-expr (expr->egg-expr expr (*context*)))
359-
(check-equal? (egg-expr->expr egg-expr (*context*)) expr))))
358+
(define egg-expr (expr->egg-expr expr ctx))
359+
(check-equal? (egg-expr->expr egg-expr ctx) expr))))
360360

361361
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
362362
;; Proofs
@@ -1282,7 +1282,7 @@
12821282
;; - scheduler: `(scheduler . <name>)` [default: backoff]
12831283
;; - `simple`: run all rules without banning
12841284
;; - `backoff`: ban rules if the fire too much
1285-
(define (make-egraph batch roots reprs schedule #:context [ctx (*context*)])
1285+
(define (make-egraph batch roots reprs schedule ctx)
12861286
(define (oops! fmt . args)
12871287
(apply error 'verify-schedule! fmt args))
12881288
; verify the schedule

src/core/egglog-herbie.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
;; - scheduler: `(scheduler . <name>)` [default: backoff]
6666
;; - `simple`: run all rules without banning
6767
;; - `backoff`: ban rules if the fire too much
68-
(define (make-egglog-runner batch roots reprs schedule #:context [ctx (*context*)])
68+
(define (make-egglog-runner batch roots reprs schedule ctx)
6969
(define (oops! fmt . args)
7070
(apply error 'verify-schedule! fmt args))
7171
; verify the schedule

src/core/explain.rkt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@
3535
[(symbol? expr) #f]
3636
[else #t]))
3737

38-
(define (actual-errors expr pcontext)
38+
(define (actual-errors expr ctx pcontext)
3939
(match-define (cons subexprs pt-errorss)
4040
(parameterize ([*pcontext* pcontext])
41-
(flip-lists (hash->list (first (compute-local-errors (list (all-subexpressions expr))
42-
(*context*)))))))
41+
(flip-lists (hash->list (first (compute-local-errors (list (all-subexpressions expr)) ctx))))))
4342

4443
(define pt-worst-subexpr
4544
(append* (reap [sow]
@@ -503,9 +502,9 @@
503502
oflow-hash
504503
uflow-hash)
505504

506-
(define tcount-hash (actual-errors expr pctx))
505+
(define tcount-hash (actual-errors expr ctx pctx))
507506

508-
(define repr (repr-of expr (*context*)))
507+
(define repr (repr-of expr ctx))
509508
(define (values->json vs repr)
510509
(map (lambda (value) (value->json value repr)) (vector->list vs)))
511510

src/core/patch.rkt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@
8484

8585
(define runner
8686
(if (flag-set? 'generate 'egglog)
87-
(make-egglog-runner input-batch (batch-roots input-batch) reprs schedule)
88-
(make-egraph global-batch roots reprs schedule)))
87+
(make-egglog-runner input-batch (batch-roots input-batch) reprs schedule (*context*))
88+
(make-egraph global-batch roots reprs schedule (*context*))))
8989

9090
(define batchrefss
9191
(if (flag-set? 'generate 'egglog)
@@ -164,8 +164,8 @@
164164

165165
(define runner
166166
(if (flag-set? 'generate 'egglog)
167-
(make-egglog-runner input-batch (batch-roots input-batch) reprs schedule)
168-
(make-egraph global-batch roots reprs schedule)))
167+
(make-egglog-runner input-batch (batch-roots input-batch) reprs schedule (*context*))
168+
(make-egraph global-batch roots reprs schedule (*context*))))
169169

170170
(define batchrefss
171171
(if (flag-set? 'generate 'egglog)

src/core/preprocess.rkt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
"../utils/common.rkt"
88
"../utils/float.rkt"
99
"../utils/timeline.rkt"
10-
"../utils/float.rkt"
1110
"batch.rkt"
12-
"egglog-herbie.rkt"
13-
"../config.rkt"
1411
"egg-herbie.rkt"
1512
"points.rkt"
1613
"programs.rkt"
@@ -77,7 +74,8 @@
7774
(make-egraph batch
7875
(batch-roots batch)
7976
(make-list (vector-length (batch-roots batch)) (context-repr ctx))
80-
`((,rules . ((node . ,(*node-limit*)))))))
77+
`((,rules . ((node . ,(*node-limit*)))))
78+
ctx))
8179

8280
;; collect equalities
8381
(for/list ([(ident spec*) (in-dict identities)]

0 commit comments

Comments
 (0)