aboutsummaryrefslogtreecommitdiff
path: root/src/CHAD/AST.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2026-01-26 23:36:56 +0100
committerTom Smeding <tom@tomsmeding.com>2026-01-26 23:36:56 +0100
commita9e6c72eff3bee8d45e0d906e8cd027066e04793 (patch)
treec6e5038b42af243c5281b77f273a3a8d376a8260 /src/CHAD/AST.hs
parent06bb9c1a82e6680cffa9f34683c48e0885e495b5 (diff)
Optimise eflattenHEADmaster
Diffstat (limited to 'src/CHAD/AST.hs')
-rw-r--r--src/CHAD/AST.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/CHAD/AST.hs b/src/CHAD/AST.hs
index ce9eb20..b795070 100644
--- a/src/CHAD/AST.hs
+++ b/src/CHAD/AST.hs
@@ -583,8 +583,10 @@ eshapeProd (SS n) e =
eflatten :: Ex env (TArr n t) -> Ex env (TArr N1 t)
eflatten e =
let STArr n _ = typeOf e
- in elet e $
- EReshape ext (SS SZ) (EPair ext (ENil ext) (eshapeProd n (EShape ext (evar IZ)))) (evar IZ)
+ in case n of
+ SS SZ -> e
+ _ -> elet e $
+ EReshape ext (SS SZ) (EPair ext (ENil ext) (eshapeProd n (EShape ext (evar IZ)))) (evar IZ)
-- ezeroD2 :: STy t -> Ex env (ZeroInfo (D2 t)) -> Ex env (D2 t)
-- ezeroD2 t ezi = EZero ext (d2M t) ezi