Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/ein/order-ein.sml
ViewVC logotype

Diff of /branches/charisee/src/compiler/ein/order-ein.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2583, Thu Apr 10 19:50:28 2014 UTC revision 2584, Tue Apr 15 03:22:58 2014 UTC
# Line 10  Line 10 
10    
11  (*Orders the expression correctly.*)  (*Orders the expression correctly.*)
12  fun orderfn(Ein.EIN{params, index, body})= let  fun orderfn(Ein.EIN{params, index, body})= let
13      (* val _ = print "\n IN ORDER \n"*)
14     val changed =ref false     val changed =ref false
15     fun order(body)=(case body     fun order(body)=(case body
16          of E.Const _ => body          of E.Const _ => body
# Line 23  Line 24 
24          | E.Conv _=>body          | E.Conv _=>body
25          | E.Sum(c1,E.Sum(c2, e))=>(changed:=true;E.Sum(c1@c2,order e))          | E.Sum(c1,E.Sum(c2, e))=>(changed:=true;E.Sum(c1@c2,order e))
26          | E.Sum(sumIndex,E.Prod e)=> let          | E.Sum(sumIndex,E.Prod e)=> let
27                (*val _ =print "\n NOPE"*)
28              fun prodMatch(c,s,p,[])=let              fun prodMatch(c,s,p,[])=let
29                  val p'=case p of [e1] => e1                  val p'=case p of [e1] => e1
30                      |_=> E.Prod p                      |_=> E.Prod p
# Line 40  Line 42 
42              | prodMatch(c,s,p,(E.Const v)::es)= prodMatch(1,s@[E.Const v], p,es)              | prodMatch(c,s,p,(E.Const v)::es)= prodMatch(1,s@[E.Const v], p,es)
43              | prodMatch(c,s,[],(E.Tensor(id,[]))::es)= prodMatch(c,s@[E.Tensor(id,[])], [],es)              | prodMatch(c,s,[],(E.Tensor(id,[]))::es)= prodMatch(c,s@[E.Tensor(id,[])], [],es)
44              | prodMatch(c,s,p,(E.Tensor(id,[]))::es)= prodMatch(1,s@[E.Tensor(id,[])],p, es)              | prodMatch(c,s,p,(E.Tensor(id,[]))::es)= prodMatch(1,s@[E.Tensor(id,[])],p, es)
45                | prodMatch(c,s,[],(E.Conv(v,[],h,[]))::es)=
46                    (prodMatch(c,s@[E.Conv(v,[],h,[])], [],es))
47                | prodMatch(c,s,p,(E.Conv(v,[],h,[]))::es)=
48                        (prodMatch(1,s@[E.Conv(v,[],h,[])],p, es))
49                | prodMatch(c,s,[],(E.Probe(E.Conv(v,[],h,[]),E.Tensor(t,[])))::es)=
50                    (prodMatch(c,s@[E.Probe(E.Conv(v,[],h,[]),E.Tensor(t,[]))], [],es))
51                | prodMatch(c,s,p,(E.Probe(E.Conv(v,[],h,[]),E.Tensor(t,[])))::es)=
52                    (prodMatch(1,s@[E.Probe(E.Conv(v,[],h,[]),E.Tensor(t,[]))],p, es))
53              | prodMatch(c,s,p,E.Prod e::es)=  prodMatch(c,s,p,e@ es)              | prodMatch(c,s,p,E.Prod e::es)=  prodMatch(c,s,p,e@ es)
54              | prodMatch(c,s,p,e::es)=  prodMatch(c,s,p@[e], es)              | prodMatch(c,s,p,e::es)=  prodMatch(c,s,p@[e], es)
55              val e'= order(E.Prod e)              val e'= order(E.Prod e)
# Line 53  Line 63 
63          | E.Sub(e1,e2) => E.Sub(order e1, order e2)          | E.Sub(e1,e2) => E.Sub(order e1, order e2)
64          | E.Div(e1,e2)=> E.Div(order e1, order e2)          | E.Div(e1,e2)=> E.Div(order e1, order e2)
65          | E.Apply(e1,e2)=> E.Apply(e1, order e2)          | E.Apply(e1,e2)=> E.Apply(e1, order e2)
66          | E.Probe(e1,e2)=> E.Probe(e1,order e2)          | E.Probe(e1,e2)=> (print "\n probe \n"; E.Probe(order e1,order e2))
67          | E.Img _ => body          | E.Img _ => body
68          | E.Prod [e1]=>e1          | E.Prod [e1]=>e1
69          | E.Prod e=>let          | E.Prod e=>let
70    
71              fun prodMatch(c,s,eps,dels,p,[])= (c,E.Prod(s@eps@dels@p))              fun prodMatch(c,s,eps,dels,p,[])= (c,E.Prod(s@eps@dels@p))
72              | prodMatch(c,s,eps,[],[],(E.Epsilon e)::es)=prodMatch(c,s,eps@[E.Epsilon e],[],[], es)              | prodMatch(c,s,eps,[],[],(E.Epsilon e)::es)=prodMatch(c,s,eps@[E.Epsilon e],[],[], es)
73              | prodMatch(_,s,eps,dels,p,(E.Epsilon e)::es)=prodMatch(1,s,eps@[E.Epsilon e],dels,p, es)              | prodMatch(_,s,eps,dels,p,(E.Epsilon e)::es)=prodMatch(1,s,eps@[E.Epsilon e],dels,p, es)

Legend:
Removed from v.2583  
changed lines
  Added in v.2584

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0