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

SCM Repository

[diderot] View of /branches/charisee/src/compiler/einTest/examplesFull.sml
ViewVC logotype

View of /branches/charisee/src/compiler/einTest/examplesFull.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2498 - (download) (annotate)
Wed Oct 30 17:35:23 2013 UTC (8 years, 1 month ago) by cchiw
File size: 9874 byte(s)
add type checking
(* examples for the rewrite rules *)

structure  ExamplesF =struct

local
structure E = Ein

in

(*Sub*)
(*Div*)
(*Neg*)
(*Add*)


val s0= E.Tensor(0,[])
val s1= E.Tensor(1,[])
val s2= E.Tensor(2,[])
val s3= E.Tensor(3,[])
val s4= E.Tensor(4,[])
val s5= E.Tensor(5,[])

val p0=E.Partial[E.V 0]
val p1=E.Partial[E.V 1]
val p2=E.Partial[E.V 2]

val t41= E.Tensor(4,[E.V 1])
val t00= E.Tensor(0,[E.V 0])
val t10=E.Tensor(1,[E.V 0])
val t11=E.Tensor(1,[E.V 1])
val t20=E.Tensor(2,[E.V 0])
val t21=E.Tensor(2,[E.V 1])
val t30=E.Tensor(3,[E.V 0])
val t04=E.Tensor(0,[E.V 4])
val t15=E.Tensor(1,[E.V 5])
val t02=E.Tensor(0,[E.V 2])
val t14=E.Tensor(1,[E.V 4])
val t22=E.Tensor(2,[E.V 2])
val t33=E.Tensor(3,[E.V 3])
val t44=E.Tensor(4,[E.V 4])


val t40= E.Tensor(4,[E.V 0])



val f00=E.Field(0,[E.V 0])
val f10=E.Field(1,[E.V 0])
val f20=E.Field(2,[E.V 0])

val c01=E.Conv(0,[],1,[])
val c12=E.Conv(1,[],2,[])
val c23=E.Conv(2,[],3,[])
val c34=E.Conv(3,[],4,[])


val d10=E.Delta(E.V 1, E.V 0)
val d12=E.Delta(E.V 1, E.V 2)
val d34=E.Delta(E.V 3, E.V 4)
val d14=E.Delta(E.V 1, E.V 4)
val d23=E.Delta(E.V 2, E.V 3)

val eps1=E.Epsilon(0,1,2)
val eps2=E.Epsilon(0,3,4)
val eps3=E.Epsilon(5,6,7)



(*Add*)
val a=E.Prod[t00,t10]

val add1=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3], body=E.Add[s0,s1,t20,E.Add[s3]]}


(*Probe*)
val tmp1=E.Probe(c01,s2)
val tmp2=E.Probe(c34, s5)
val probe1=E.EIN{params=[E.FLD(3),E.TEN,E.TEN], index=[E.SX(1,4)],
            body=E.Sum([E.V 0],tmp1)}
val probe2=E.EIN{params=[E.FLD(3),E.TEN,E.TEN], index=[],
            body=E.Neg(tmp1)}
val probe3=E.EIN{params=[E.FLD(3),E.TEN,E.TEN,E.FLD(3),E.TEN,E.TEN], index=[],
            body=E.Add[tmp1,tmp2]}
val probe4=E.EIN{params=[E.FLD(3),E.TEN,E.TEN,E.FLD(3),E.TEN,E.TEN], index=[],
            body=E.Sub(tmp1,tmp2)}
val probe5=E.EIN{params=[E.FLD(3),E.TEN,E.TEN,E.TEN], index=[],
            body=E.Div(tmp1,s3)}
val probe6=E.EIN{params=[E.FLD(3),E.TEN,E.TEN,E.TEN], index=[],
            body=E.Prod[tmp1,s3]}
val probe7=E.EIN{params=[E.FLD(3),E.TEN,E.TEN,E.TEN], index=[],
            body=E.Prod[tmp1,t30]}
val probe8=E.EIN{params=[E.FLD(3),E.TEN,E.TEN], index=[], body=tmp1}



(*Prod *)
val prod2=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3], body=E.Prod[s1,t30,t21]}

(*SUM*)
val sum1=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3], body=E.Sum([E.V 0],E.Prod[s1,s2,t30,t40])}
val sum2=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3], body=E.Sum([E.V 0],E.Prod[s1,t30,t21,t40])}
val sum3=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3], body=E.Sum([E.V 0],E.Add[t30,E.Prod[s0,t20,t10]])}
val sum4=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3], body=E.Sum([E.V 0],E.Sub(t30,E.Prod[s0,t20,t10]))}
val sum5=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3], body=E.Sum([E.V 0],E.Div(E.Prod[s0,t20,t10],s3))}
val sum6=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN],
            index=[E.SX(1,8),E.SX(1,8),E.SX(1,8),E.SX(1,8)],
            body=E.Sum([E.V 0,E.V 1, E.V 2, E.V 3, E.V 4],E.Prod[eps1,eps2,t11,t22,t33,t44])}
val sum7=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN],
            index=[E.SX(1,8),E.SX(1,8),E.SX(1,8),E.SX(1,8),E.SX(1,8),E.SX(1,8)],
                body=E.Sum([E.V 0,E.V 1, E.V 2],E.Prod[eps1,
          E.Sum([E.V 3, E.V 4],E.Prod[eps2,t11,t22,t33,t44])]) }
val sum8=E.EIN{params=[E.TEN,E.TEN,E.TEN,E.TEN,E.TEN], index=[E.IX 3,E.SX(1,8)], body=E.Sum([E.V 2],E.Prod[d12,t02,t10])}
val sum9=E.EIN{params=[E.FLD(3)], index=[E.SX(1,8),E.IX 3], body=E.Sum([E.V 0],E.Prod[d10,f00])}

val sumapply1=E.EIN{params=[E.TEN],
            index=[E.IX 3,E.SX(1,8)], body=E.Sum([E.V 1],E.Apply(p0,s0))}
val sumapply2=E.EIN{params=[E.FLD(2),E.TEN],
            index=[E.SX(1,8)], body=E.Sum([E.V 0],E.Apply(E.Prod[p0,p0],c01))}
val sumapply3=E.EIN{params=[E.FLD(2),E.TEN,E.FLD(2),E.TEN],
            index=[E.SX(1,8)], body=E.Sum([E.V 0],E.Apply(E.Prod[p0,p0],E.Add[c01,c23]))}

val sumapply4=E.EIN{params=[E.FLD(2),E.TEN,E.FLD(2),E.TEN],
            index=[E.SX(1,8)], body=E.Sum([E.V 0],E.Apply(E.Prod[p0,p0],E.Sub(c01,c23)))}
val sumapply5=E.EIN{params=[E.FLD(2),E.TEN,E.TEN],
            index=[E.SX(1,8)], body=E.Sum([E.V 0],E.Apply(E.Prod[p0,p0],E.Div(c01,s2)))}
val sumapply6=E.EIN{params=[E.FLD(2),E.TEN,E.FLD(2),E.TEN],
        index=[E.IX 2,E.IX 2,E.IX 2], body=E.Sum([E.V 0],E.Apply(E.Prod[p0,p1,p2],E.Apply(p0,E.Sub(c01,c23))))}
val sumapply7=E.EIN{params=[E.FLD(3)], index=[E.SX(1,8),E.IX 3], body=E.Sum([E.V 0],E.Apply(p0,E.Prod[d10,f00]))}


(*
(*probe *)
val pos=s1
val add=E.Add[c0,c1,E.Prod[s0,c2]]

val probe1=E.EIN{params=[E.FLD(3),E.TEN,E.TEN], index=[], body=E.Probe(c0,s2)}



val probe2=E.Probe(E.Sum([E.V 2],c0),pos)
val probe3= E.Probe(E.Neg(E.Prod[s0,c0]),pos)
val probe4= E.Probe(add,pos)
val probe5= E.Probe(E.Sub( E.Add[c0,c1,E.Prod[s0,c2]], c1),pos)
val probe6=E.Probe(E.Prod[s0,c1], pos)
val probe7= E.Probe(E.Prod[s1,  E.Apply(p0, E.Prod[s0,c0])],pos )
val probe8= E.Probe( E.Prod[s1, add],pos)
val probe9=E.Probe(E.Div(c0,s0), pos)
val probe10=E.Probe(E.Prod[s0,t0,c0],pos)
val probe11= E.Probe(E.Apply(p1,E.Conv(0, [E.V 0],1,[])),t0)
val probe12= E.Probe(E.Apply(E.Partial [E.V 1,E.V 0],E.Conv(0, [E.V 0],1,[])),t0)
val probe13= E.Probe(E.Apply(E.Prod[E.Partial[E.V 3],E.Partial [E.V 1,E.V 0]],E.Conv(0, [E.V 0],1,[])),t0)


(*Sum*)

val sum1=E.EIN{params=[E.FLD(3),E.TEN,E.FLD(3),E.TEN], index=[], body=E.Sum([],E.Add[c0,c2,E.Prod[s1,c2]])}


val sum2=E.Sum([E.V 0],E.Prod[t0,E.Add[t1,t1]])
val sum3=E.Sum([E.V 0],E.Prod[t0,E.Add[t1,t1],t3])
val sum4=E.Sum([E.V 0],E.Prod[s0, E.Sub(f1,f2)])
val sum5=E.Sum([E.V 0],E.Prod[t0, E.Sub(t1,t1)])
val sum6= E.Sum([E.V 0],E.Div(f1,s1))

            (*Eps Eps=> Deltas-Deltas*)
val sum7=E.Sum([E.V 0, E.V 1, E.V 3],E.Prod[eps1,eps2,E.Tensor(0,[E.V 1]),E.Tensor(1,[E.V 3])])
val sum8=(E.Sum([E.V 0, E.V 1, E.V 2, E.V 3, E.V 4],E.Prod[eps1,eps2,E.Tensor(0,[E.V 3]), t14,E.Tensor(2,[E.V 1]), E.Tensor(3,[E.V 2]) ]))
val sum9=(E.Sum([E.V 0, E.V 1, E.V 3],E.Prod[eps1,eps2,eps3,E.Tensor(0,[E.V 3]), t14 ]))
val sum10=(E.Sum([E.V 0, E.V 5, E.V 6],E.Prod[eps1,eps2,eps3,E.Tensor(0,[E.V 3]), t15 ]))
val sum11=(E.Sum([E.V 0, E.V 5, E.V 6],E.Prod[eps1,eps2,eps3,E.Tensor(0,[E.V 5]), E.Tensor(1,[E.V 6]) ]))

val sumIndex=[E.V 0,E.V 1, E.V 2,E.V 3, E.V 4, E.V 5]


(*Dels(i,j) Tensor(i)=> Tensor(j)*)
val sum12=E.Sum(sumIndex,E.Prod[d1,d2,t0,t1])
val sum13=E.Sum(sumIndex,E.Prod[d1,d2,t02,t14])
val sum14=E.Sum(sumIndex,E.Prod[d1,d2,t3,t02])



(*sum apply*)
val sum15=E.Sum([E.V 0],E.Apply(p1,s1))
val sum16=E.Sum([E.V 0],E.Apply(E.Prod[p2,p0],f0))
val sum17=E.Sum([E.V 0], E.Apply(p1,E.Prod[s0, E.Sub(f1,f2)]))
val sum18= E.Sum([E.V 0, E.V 1],E.Apply(p0,E.Prod[f1,E.Field(0,[E.V 1]),E.Field(2,[E.V 1])]))
val sum19= E.Sum([E.V 0, E.V 1],E.Apply(p0,E.Prod[f1,E.Delta(E.V 5, E.V 6),E.Field(0,[E.V 1]),E.Field(2,[E.V 1])]))
val sum20=E.Sum([E.V 0],E.Apply(p0,E.Sub(E.Field(0,[E.V 1]),E.Field(1,[E.V 2]))))
val sum21=E.Sum([E.V 0],E.Apply(p0,E.Prod[s0,f0]))
val sum22=E.Sum([E.V 0],E.Apply(p0,E.Add[E.Field(0,[E.V 1]),E.Field(1,[E.V 2])]))
val sum23=E.Sum([E.V 0],E.Apply(p0,s0))

(* Partial_i Dels(i, j)=> E.Partial(j)*)
val sum24=E.Sum([E.V 0, E.V 1],E.Apply(p0,E.Prod[E.Delta(E.V 1,E.V 0),E.Tensor(0,[E.V 1])]))
val sum25=E.Sum([E.V 0, E.V 1],E.Apply(p0,E.Prod[E.Delta(E.V 1,E.V 0),E.Field(0,[E.V 1])]))

(*Eps_ijk Partial_ij*)
val sum26=E.Sum([E.V 0, E.V 1, E.V 2],E.Apply(E.Partial([E.V 1, E.V 0]),E.Prod[eps1,E.Tensor(0,[E.V 1])]))
val sum27=E.Sum([E.V 0, E.V 1, E.V 2],E.Apply(E.Partial([E.V 2, E.V 1]),E.Prod[eps1,E.Tensor(0,[E.V 1])]))
val sum28=E.Sum([E.V 0, E.V 1, E.V 2],E.Apply(E.Partial([E.V 0, E.V 2]),E.Prod[eps1,E.Tensor(0,[E.V 1])]))


val prod1= E.Prod[p2,p1,t0]
val prod2= E.Prod[E.Partial [E.V 2,E.V 3],p1,t0]
val prod3=E.Prod[t0,E.Add[t1,t1],E.Add[E.Prod[t0,t1],E.Prod[t0,t1]]]
val prod4=E.Prod[p0,t0,E.Add[t1,t1]]
val prod5=E.Prod[t0, E.Sub(t1,t1)]
val prod6=E.Prod[t0, E.Sub(t1,t1),t3]
val prod7=E.Prod[s0, E.Sub(f1,f2)]
val prod8=E.Prod[p0,E.Add[E.Tensor(0,[E.V 1]),E.Tensor(1,[E.V 2])]]
val prod9=E.Prod[p0,E.Sub(E.Tensor(0,[E.V 1]),E.Tensor(1,[E.V 2]))]
val prod10=E.Prod[p0,s0]


(***** Apply ******)
val apply1=E.Apply(E.Partial([E.V 2]),E.Prod[E.Tensor(0,[E.V 1,E.V 2]),E.Tensor(2,[E.V 2,E.V 3]) ,E.Tensor(5,[E.V 2,E.V 4])])
val apply2= E.Apply(E.Prod[p2,p1],f0)
val apply3= E.Apply(E.Prod[p2,p1], E.Sum([E.V 0],f0))
val apply4= E.Apply(p1,E.Conv(0, [E.V 0],1,[]))
val apply5= E.Apply(E.Partial [E.V 1,E.V 0],E.Conv(0, [E.V 0],1,[]))
val apply6= E.Apply(E.Prod[E.Partial[E.V 3],E.Partial [E.V 1,E.V 0]],E.Conv(0, [E.V 0],1,[]))
val apply7=E.Apply(p1,E.Prod[s0, E.Sub(f1,f2)])
val apply8=E.Apply(p0,E.Add[E.Field(0,[E.V 1]),E.Field(1,[E.V 2])])
val apply9=E.Apply(p0,E.Add[E.Field(0,[E.V 1]),E.Apply(p0,E.Field(1,[E.V 2]))])
val apply10=E.Apply(p0,E.Sub(E.Field(0,[E.V 1]),E.Field(1,[E.V 2])))
val apply11=E.Apply(p0,E.Sub(E.Field(0,[E.V 1]),E.Apply(p0,E.Field(1,[E.V 2]))))
val apply12=E.Apply(p0,s0)
val apply13=E.Apply(p0,E.Prod[s0,f1])
val apply14= E.Prod[p0,t1,E.Tensor(0,[E.V 1])]
val apply15= E.Prod[p0,t0,E.Add[E.Tensor(1,[E.V 1]),E.Tensor(2,[E.V 1])]]
val apply16= E.Apply(p0,E.Prod[t1,E.Tensor(0,[E.V 1])])
val apply17= E.Apply(p0,E.Prod[f1,E.Field(0,[E.V 1])])
val apply18= E.Apply(p0,E.Prod[f1,E.Field(0,[E.V 1]),E.Field(2,[E.V 1])])



(*apply sum*)
val applysum1=E.Apply(p1,E.Sum([E.V 0],E.Prod[s0, E.Sub(f1,f2)]))
val applysum2=E.Apply(p0,E.Sum([E.V 1],E.Add[E.Field(0,[E.V 1]),E.Field(1,[E.V 1])]))
val applysum3=E.Apply(p0,E.Sum([E.V 0],E.Sub(E.Field(0,[E.V 1]),E.Field(1,[E.V 1]))))
val applysum4=E.Apply(p0,E.Sum([E.V 0],s0))
val applysum5=E.Apply(p0,E.Sum([E.V 0],E.Prod[s0,f0]))
val applysum6= E.Apply(p0,E.Sum([E.V 1],E.Prod[f1,E.Field(0,[E.V 1]),E.Field(2,[E.V 1])]))
val applysum7= E.Apply(p0,E.Sum([E.V 1],E.Prod[f1,d2,E.Field(0,[E.V 1]),E.Field(2,[E.V 1])]))


*)


end;
end

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