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 3349 - (download) (annotate)
Tue Oct 27 15:16:36 2015 UTC (3 years, 11 months ago) by jhr
File size: 7007 byte(s)
making copyrights consistent for all code in the repository
(* Currently under construction 
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 *)




structure splittestcases = 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 toStringBind(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 ( ("Y_"^itos i^"_"), DstTy.TensorTy [0,0])


           fun  mkArgs 1=[DstV.new("B_",DstTy.TensorTy [1])]
            | mkArgs 2=(mkArgs 1)@[DstV.new("C_",DstTy.TensorTy [2])]
            | mkArgs 3=(mkArgs 2)@[DstV.new("D_",DstTy.TensorTy [3])]
            | mkArgs 4=(mkArgs 3)@[DstV.new("E_",DstTy.TensorTy [4])]
            | mkArgs 5=(mkArgs 4)@[DstV.new("F_",DstTy.TensorTy [4])]
            | 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)



val e15=assignEin(y 15,setEin(p4,[3,3],
E.Prod[E.Tensor(0,[E.V 0, E.V 1]),
E.Sub(E.Tensor(1,[E.V 1,E.V 1]),E.Tensor(2,[E.V 1,E.V 1]))]
) ,a4)


val e16=assignEin(y 16,setEin(p4,[3,3],
E.Add[E.Tensor(0,[E.V 0, E.V 1]),
E.Sub(E.Tensor(1,[E.V 1,E.V 1]),E.Tensor(2,[E.V 1,E.V 1]))]
) ,a4)



val e17=assignEin(y 17,setEin(p4,[3,3],
E.Add[E.Prod[E.Tensor(0,[E.V 0, E.V 1]),E.Tensor(1,[E.V 0, E.V 1])],
E.Sub(E.Tensor(1,[E.V 0,E.V 1]),E.Tensor(2,[E.V 0,E.V 1]))]
) ,a4)


val e18=assignEin(y 18,setEin(p4,[3,3,3],
E.Prod[E.Prod[E.Tensor(0,[E.V 1, E.V 2]),E.Tensor(1,[E.V 1, E.V 2])],
E.Sub(E.Tensor(1,[E.V 0,E.V 1]),E.Tensor(2,[E.V 0,E.V 1]))]
) ,a4)


val e19=assignEin(y 19,setEin(p4,[00,11,22],
E.Sum([(E.V 5,0,55)],
E.Prod[E.Prod[E.Tensor(0,[E.V 1, E.V 5]),E.Tensor(1,[E.V 1, E.V 5])],
E.Sub(E.Tensor(1,[E.V 0,E.V 1]),E.Tensor(2,[E.V 0,E.V 1]))])
) ,a4)

val e20=assignEin(y 20,setEin(p4,[00,11,22],
E.Sub(E.Sum([(E.V 5,0,55)],
E.Prod[E.Prod[E.Tensor(0,[E.V 1, E.V 5]),E.Tensor(2,[E.V 1, E.V 5])]]),
E.Sub(E.Tensor(1,[E.V 0,E.V 1]),E.Tensor(2,[E.V 0,E.V 1])))
) ,a4)

val e21=assignEin(y 21,setEin(p4,[],
E.Sub(E.Tensor(1,[]),
    E.Sum([(E.V 3,0,33),(E.V 4,0,44),(E.V 5,0,55)],
        E.Prod[E.Prod[E.Tensor(0,[E.V 4, E.V 5]),E.Tensor(2,[E.V 4, E.V 5])]]))) ,a4)


val e21=assignEin(y 21,setEin(p4,[],
E.Sub(E.Tensor(1,[]),
E.Sum([(E.V 3,0,33),(E.V 4,0,44),(E.V 5,0,55)],
E.Prod[E.Tensor(0,[E.V 4, E.V 5]),E.Tensor(2,[E.V 4, E.V 5])]))) ,a4)



val e22=assignEin(y 22,setEin(p4,[],
E.Sub(E.Tensor(1,[]),
E.Sum([(E.V 0,0,00),(E.V 1,0,11),(E.V 2,0,22)],
E.Prod[E.Prod[E.Tensor(0,[E.V 0, E.V 2]),E.Tensor(2,[E.V 2, E.V 1])]]))) ,a4)






    fun test()=let
        fun f e=let
          val _ =  print("\n **************\n Staring\n "^toStringBind e)
          val (b,rtn)= split.gettest e
          val _ =  List.map (fn r=>print("\n\t"^toStringBind r)) ([b]@rtn)
         val _ =  print("\n ending \n **************\n ")
          in
                1
          end
        val _ =List.map f [e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20,e21]
        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