Skip to content

Commit

Permalink
Remove lets in matrix demand (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
saulshanabrook authored Aug 23, 2023
1 parent 0f777d6 commit 42a9e77
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tests/matrix.egg
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
(rewrite (Times (Lit i) (Lit j)) (Lit (* i j)))
(rewrite (Times a b) (Times b a))

(datatype MExpr
(MMul MExpr MExpr)
(Kron MExpr MExpr)
(datatype MExpr
(MMul MExpr MExpr)
(Kron MExpr MExpr)
(NamedMat String)
(Id Dim)
; DSum
Expand All @@ -17,7 +17,7 @@
; Transpose
; Inverse
; Zero Math Math
; ScalarMul
; ScalarMul
)

; alternative encoding (type A) = (Matrix n m) may be more useful for "large story example"
Expand Down Expand Up @@ -45,26 +45,26 @@
(rewrite (Kron (MMul A C) (MMul B D)) (MMul (Kron A B) (Kron C D)))


(rewrite (MMul (Kron A B) (Kron C D))
(rewrite (MMul (Kron A B) (Kron C D))
(Kron (MMul A C) (MMul B D))
:when
:when
((= (ncols A) (nrows C))
(= (ncols B) (nrows D)))
)

; demand
(rule ((= e (MMul A B)))
((let demand1 (ncols A))
(let demand2 (nrows A))
(let demand3 (ncols B))
(let demand4 (nrows B)))
((ncols A)
(nrows A)
(ncols B)
(nrows B))
)

(rule ((= e (Kron A B)))
((let demand1 (ncols A))
(let demand2 (nrows A))
(let demand3 (ncols B))
(let demand4 (nrows B)))
((ncols A)
(nrows A)
(ncols B)
(nrows B))
)


Expand Down

0 comments on commit 42a9e77

Please sign in to comment.