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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2496 - (download) (annotate)
Tue Oct 29 05:29:46 2013 UTC (5 years, 10 months ago) by cchiw
File size: 3873 byte(s)
changes to high-to-mid
(*Test Specialize transform function *)
structure  tSpecialize = struct

    structure G = GenericEin
    structure E = Ein
    structure S = Specialize
    structure EinOp = Operators
    structure P= Printer

val check=[7]

                (* Tensor Operations *)

val addition1T = S.transform(EinOp.addTensor, [[1,2]],[])
val additionT = S.transform(EinOp.addTensor, [[9]],[])
val addition2T = S.transform(EinOp.subTensor, [[3,4]],[])
val subtractionT = S.transform(EinOp.subTensor, [[3]],[])
val identityT=S.transform(EinOp.identity,[[3],[3]], [])
val traceT=S.transform(EinOp.trace,[[0,3]],[])
val scaleT=S.transform(EinOp.scaleTensor,[[3,3]],[])
val divideT=S.transform(EinOp.divideTensor,[[2,3]],[])
val transposeT=S.transform(EinOp.transpose,[[3],[4]],[])
val outerProductT=S.transform(EinOp.outerProduct,[[2],[3]],[])

                (*Inner Product*)
val dotProduct = S.transform(EinOp.innerProduct, [[],[],[0,3]],[])
val innerProduct1 = S.transform(EinOp.innerProduct, [[],[],[0,4]],[])
    (*M2x3* Vec3  *)
val mxv = S.transform(EinOp.innerProduct, [[2],[],[0,3]],[])
    (* Vec4 * Mat 4x2  *)
val vxm = S.transform(EinOp.innerProduct, [[],[2],[0,4]],[])
    (*Mat 4*5 x Mat 5*6*)
val mxm = S.transform(EinOp.innerProduct, [[4],[6],[0,5]],[])
val m3xv = S.transform(EinOp.innerProduct,[[4,2],[],[0,3]],[])
val m3xm4= S.transform(EinOp.innerProduct,[[4,2],[5,6,7],[0,3]],[])

                (*Double Dot*)
(*Second rank tensor Ts:[5,6], and third rank tensor Tt:[7,8,9]*)
(* Tt:[5,6,9] Ts:[6,9] *)
val ddTtTs = S.transform(EinOp.doubleDot,[[5],[],[0,6],[0,9]],[])
(* Tt:[6,9] Ts:[6,9,8] *)
val ddTsTt = S.transform(EinOp.doubleDot,[[],[8],[0,6],[0,9]],[])
(* Tt:[7,6,9] Ts:[6,9,8] *)
val ddTtTt = S.transform(EinOp.doubleDot,[[7],[8],[0,6],[0,9]],[]);
(* Tt:[7,2,6,9] Ts:[6,9,8] *)
val ddTfTt=  S.transform(EinOp.doubleDot,[[7,2],[8],[0,6],[0,9]],[])

            (* Tensor Operations-- test Zeros *)
val additionT0 = S.transform(EinOp.addTensor, [[]],[])
val subtractionT0 = S.transform(EinOp.subTensor, [[]],[])
val scaleT0=S.transform(EinOp.scaleTensor,[[]],[])
val divideT0=S.transform(EinOp.divideTensor,[[]],[])

(*Field Operations*)

val additionF= S.transform(EinOp.addField,[[]],[2,2])
val additionF1= S.transform(EinOp.addField,[[3]],[2,2])
val additionF2= S.transform(EinOp.addField,[[5,6]],[3,3])
val additionF3= S.transform(EinOp.addField,[[1]],[2,2])
val subtractionF=S.transform(EinOp.subField,[[1]],[3,3])
val scaleF= S.transform(EinOp.scaleField,[[1,3]],[2])
val divideF=S.transform(EinOp.divideField,[[2]],[3])

val gradientF=S.transform(EinOp.Grad,[[2]],[3])
val hessianF=S.transform(EinOp.Grad,[[3,3]],[3])
val divg=S.transform(EinOp.Divergence,[[0,8]] , [2])

val addTF= S.transform(EinOp.addTenField,[],[2])
val subTF= S.transform(EinOp.subTenField,[],[2])
val negF=S.transform(EinOp.negField,[[1]],[2] )
val co=S.transform(EinOp.conv,[[3,5]],[2])

fun test e= P.printerE e

fun run tester=
        val tt=[]
        val t0=[additionT0, subtractionT0, scaleT0, divideT0]
        val t1=  [additionT,subtractionT,identityT,scaleT, divideT, transposeT,outerProductT,traceT]
        val t2= [dotProduct,  mxv, vxm, mxm]
        val t3=[ddTtTs, ddTsTt, ddTtTt, ddTfTt]
        val f1=[additionF,additionF2, additionF3, subtractionF,scaleF,divideF]
        val f2=[gradientF,hessianF,divg]
        val newbie=[addTF,subTF,negF,co]


        if (tester=0) then List.map test t0
        else if (tester=1) then List.map test t1
        else if (tester=2) then List.map test t2
        else if (tester=3) then List.map test t3
        else if (tester=4) then List.map test f1
        else if (tester=5) then List.map test f2
        else if(tester=6) then List.map test newbie
        else List.map test tt

    val r=List.map run check

  end; (* local *)

    end (* local *)

ViewVC Help
Powered by ViewVC 1.0.0