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

SCM Repository

[diderot] View of /branches/charisee/src/compiler/high-to-mid/testcases.sml
ViewVC logotype

View of /branches/charisee/src/compiler/high-to-mid/testcases.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2838 - (download) (annotate)
Tue Nov 25 03:40:24 2014 UTC (4 years, 8 months ago) by cchiw
File size: 4661 byte(s)
edit split-ein
(* Currently under construction 
 *
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 *)




structure testcases = struct

    local
   
    structure E = Ein
    structure mk= mkOperators
    structure SrcIL = HighIL
    structure SrcTy = HighILTypes
    structure SrcOp = HighOps
    structure SrcSV = SrcIL.StateVar
    structure VTbl = SrcIL.Var.Tbl
    structure DstIL = MidIL
    structure DstTy = MidILTypes
    structure DstOp = MidOps
    structure DstV = DstIL.Var
    structure SrcV = SrcIL.Var
    structure P=Printer
    structure F=Filter
    structure T=TransformEin
    structure split=Split
    structure Var = MidIL.Var
    val testing=0


    in
val cnt = ref 0
fun genName prefix = let
val n = !cnt
in
cnt := n+1;
String.concat[prefix, "_", Int.toString n]
end
fun setEin(params,index,body)=Ein.EIN{params=params, index=index, body=body}
fun assignEin (x, rator, args) = (x, DstIL.EINAPP(rator, args))
fun printEINAPP(id, DstIL.EINAPP(rator, args))=let
    val a=String.concatWith " , " (List.map Var.toString args)
    in
        String.concat([Var.toString id," ==",P.printerE rator, a])
    end



        fun itos i=Int.toString i
        fun  y i = DstV.new (genName ("yy"^itos i^"_"), DstTy.TensorTy [0,0])
        fun mkArgs n  =List.tabulate(n, (fn e=>DstV.new (genName ("xx"^itos e ^"_"), DstTy.TensorTy [e])))
        fun mkP n =List.tabulate(n, (fn e=>E.TEN(3,[])))
        fun mkIx n=List.tabulate(n, (fn e=>e ))
        
        val p5=mkP 5
        val i5=mkIx 5
        val a5=mkArgs 5
        val p3=mkP 3
        val i2=mkIx 2
         val i1=mkIx 1
        val a3=mkArgs 3
val p4=mkP 4
val a4=mkArgs 4


        val e1=assignEin(y 1,setEin(p3,i2,E.Add[E.Sub(E.Tensor(1,[E.V 0, E.V 1]),E.Tensor(0,[E.V 0, E.V 1])),E.Div(E.Tensor(1,[E.V 0, E.V 1]),E.Tensor(2,[]))]),a3)
        val e2=assignEin(y 2,setEin(p3,i2,E.Prod[E.Sub(E.Tensor(1,[E.V 1]),E.Tensor(0,[E.V 1])),E.Div(E.Tensor(1,[E.V 0]),E.Tensor(2,[]))]),a3)
        val e3=assignEin(y 3,setEin(p3,i2,E.Sum([(E.V 2,0,22),(E.V 3, 0,33)],E.Prod[E.Sub(E.Tensor(1,[E.V 1,E.V 2]),E.Tensor(0,[E.V 1,E.V 2])),E.Div(E.Tensor(1,[E.V 0, E.V 3]),E.Tensor(2,[]))])),a3)
        val e4=assignEin(y 4,setEin(p3,i2,E.Prod[E.Sum([(E.V 2,0,22)],E.Add[E.Tensor(1,[E.V 2,E.V 1]),E.Tensor(2,[E.V 2,E.V 1])]),E.Tensor(2,[E.V 0, E.V 1])]),a3)
        val e5=assignEin(y 5,setEin(p3,i2,E.Sum([(E.V 2,0,22)],E.Prod[E.Tensor(0,[E.V 2,E.V 1]),E.Sum([(E.V 3,0,33)],E.Prod[E.Tensor(2,[E.V 2,E.V 3]),E.Tensor(3,[E.V 3,E.V 0])])])),a3)
         val e6=assignEin(y 6,setEin(p3,i2,E.Sum([(E.V 2,0,22)],E.Prod[
                E.Sub(E.Tensor(0,[E.V 2,E.V 1]),E.Tensor(3,[E.V 2,E.V 1])),E.Sum([(E.V 3,0,33)],
                E.Prod[E.Add[E.Tensor(2,[E.V 2,E.V 3]),E.Tensor(1,[E.V 2,E.V 3]) ],E.Tensor(3,[E.V 3,E.V 0])])])),a3)
        val e7=assignEin(y 7,setEin(p3,i2,E.Add[E.Sub(E.Tensor(1,[E.V 0, E.V 1]),E.Tensor(0,[E.V 0, E.V 1])),E.Div(E.Tensor(1,[E.V 0, E.V 1]),
            E.Sum([(E.V 2,0,22)],E.Prod[E.Tensor(2,[E.V 2]),E.Tensor(1,[E.V 2])]) )]),a3)
        val e8=assignEin(y 8,setEin(p3,i2,
                E.Div(E.Tensor(1,[E.V 0, E.V 1]),
                E.Sum([(E.V 2,0,22)],E.Prod[E.Tensor(2,[E.V 2]),E.Tensor(0,[E.V 2])]) )),a3)
val e9=assignEin(y 9,setEin(p3,i2,
E.Prod[E.Tensor(1,[ E.V 1]),
E.Sum([(E.V 2,0,22)],E.Prod[E.Tensor(2,[E.V 2,E.V 0]),E.Tensor(0,[E.V 2])])] ),a3)

val e10=assignEin(y 10,setEin(p4,i2,
E.Prod[
E.Add[E.Tensor(1,[ E.V 1]),E.Sub(E.Tensor(1,[ E.V 1]),E.Div(E.Tensor(2,[ E.V 1]),E.Tensor(3,[])))],
E.Sum([(E.V 2,0,22)],E.Prod[E.Tensor(2,[E.V 2,E.V 0]),
E.Add[E.Tensor(3,[E.V 2]),E.Tensor(0,[E.V 2])]
])] ),a4)


val e11=assignEin(y 11,setEin(p4,i2,
E.Prod[
E.Add[E.Tensor(1,[ E.V 1]),E.Sub(E.Tensor(1,[ E.V 1]),E.Div(E.Tensor(2,[ E.V 1]),E.Tensor(3,[])))],
E.Sum([(E.V 2,0,22)],E.Prod[E.Tensor(2,[E.V 2,E.V 0]),E.Tensor(3,[E.V 2]),E.Tensor(0,[E.V 2])])
]) ,a4)


val e12=assignEin(y 12,setEin(p4,i2,

E.Add[E.Tensor(1,[ E.V 1,E.V 0]),E.Sub(E.Tensor(0,[ E.V 1,E.V 0]),E.Div(E.Tensor(2,[ E.V 1,E.V 0]),E.Tensor(3,[])))]) ,a4)


val e13=assignEin(y 13,setEin(p4,i2,
    E.Add[E.Tensor(1,[E.V 0, E.V 1]),
    E.Prod[E.Tensor(1,[E.V 0]), E.Prod[E.Tensor(0,[E.V 1]),  E.Tensor(0,[E.V 1])]]]
) ,a4)



val e14=assignEin(y 14,setEin(p4,i2,
E.Add[E.Tensor(1,[E.V 0, E.V 1]),
E.Sum([(E.V 2, 0 ,22)],E.Prod[E.Tensor(1,[E.V 0,E.V 2]), E.Prod[E.Tensor(0,[E.V 1,E.V 2]),  E.Tensor(3,[E.V 1,E.V 2])]]
)]) ,a4)






    fun test()=let
        val _ =List.map    (fn e=> split.gettest e) [e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14]
        val _ = raise Fail"stop"
    in 1 end 
  end; (* local *)

end (* local *)

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