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

SCM Repository

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

Diff of /branches/charisee/src/compiler/high-to-mid/ProbeEin.sml

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

revision 2680, Wed Aug 6 00:51:53 2014 UTC revision 2827, Tue Nov 11 00:18:38 2014 UTC
# Line 39  Line 39 
39    
40  val testing=0  val testing=0
41    
42  datatype peanut=    O of  DstOp.rator | E of Ein.ein|C of DstTy.ty|S of int  
 datatype peanut2=    O2 of  SrcOp.rator | E2 of Ein.ein|C2 of SrcTy.ty|S2 of int  
43      in      in
44    
45    
46  fun assign (x, rator, args) = (x, DstIL.OP(rator, args))  fun assign (x, rator, args) = (x, DstIL.OP(rator, args))
47  fun assignEin (x, rator, args) = ((x, DstIL.EINAPP(rator, args)))  fun assignEin (x, rator, args) = ((x, DstIL.EINAPP(rator, args)))
48    
 fun getRHS x  = (case SrcIL.Var.binding x  
     of SrcIL.VB_RHS(SrcIL.OP(rator, args)) => (O2 rator, args)  
     | SrcIL.VB_RHS(SrcIL.VAR x') => getRHS x'  
     | SrcIL.VB_RHS(SrcIL.EINAPP (e,args))=>(E2 e,args)  
     | SrcIL.VB_RHS(SrcIL.CONS (ty,args))=>(C2 ty,args)  
     | SrcIL.VB_NONE=>(S2 2,[])  
     | vb => raise Fail(concat[  
     "expected rhs operator for ", SrcIL.Var.toString x,  
     "but found ", SrcIL.vbToString vb])  
     (* end case *))  
   
 fun getRHSDst x  = (case DstIL.Var.binding x  
 of DstIL.VB_RHS(DstIL.OP(rator, args)) => (O rator, args)  
 | DstIL.VB_RHS(DstIL.VAR x') => getRHSDst x'  
 | DstIL.VB_RHS(DstIL.EINAPP (e,args))=>(E e,args)  
 | DstIL.VB_RHS(DstIL.CONS (ty,args))=>(C ty,args)  
 | DstIL.VB_NONE=>(S 2,[])  
 | vb => raise Fail(concat[  
 "expected rhs operator for ", DstIL.Var.toString x,  
 "but found ", DstIL.vbToString vb])  
 (* end case *))  
   
   
   
   
   
49    
50  (*Create fractional, and integer position vectors*)  (*Create fractional, and integer position vectors*)
51  fun transformToImgSpace  (dim,v,posx,varII)=let  fun transformToImgSpace  (dim,v,posx,imgArgDst)=let
   
52      val translate=DstOp.Translate v      val translate=DstOp.Translate v
53      val transform=DstOp.Transform v      val transform=DstOp.Transform v
54      val M  = DstV.new ("M", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)      val M  = DstV.new ("M", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)
   
55      val T  = DstV.new ("T", DstTy.tensorTy [dim])   (*translate*)      val T  = DstV.new ("T", DstTy.tensorTy [dim])   (*translate*)
56      val x  = DstV.new ("x", DstTy.vecTy dim)            (*Image-Space position*)      val x  = DstV.new ("x", DstTy.vecTy dim)            (*Image-Space position*)
   
     val xA  = DstV.new ("xA", DstTy.vecTy dim)            (*Image-Space position*)  
    (* val xB  = DstV.new ("xB", DstTy.vecTy dim)            (*Image-Space position*)*)  
57      val f  = DstV.new ("f", DstTy.vecTy dim)            (*fractional*)      val f  = DstV.new ("f", DstTy.vecTy dim)            (*fractional*)
58      val nd = DstV.new ("nd", DstTy.vecTy dim)           (*real position*)      val nd = DstV.new ("nd", DstTy.vecTy dim)           (*real position*)
59      val n  = DstV.new ("n", DstTy.iVecTy dim)           (*integer position*)      val n  = DstV.new ("n", DstTy.iVecTy dim)           (*integer position*)
60      val PosToImgSpace=mk.transform(dim,dim)      val PosToImgSpace=mk.transform(dim,dim)
   
      val PosToImgSpaceA=mk.transformA(dim,dim)  
      val PosToImgSpaceB=mk.transformB(dim,dim)  
61      val P  = DstV.new ("P", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)      val P  = DstV.new ("P", DstTy.tensorTy [dim,dim])   (*transform dim by dim?*)
   
62      val code=[      val code=[
63          assign(M, transform, [varII]),          assign(M, transform, [imgArgDst]),
64          assign(T, translate, [varII]),          assign(T, translate, [imgArgDst]),
65          assignEin(x, PosToImgSpace,[M,posx,T]) ,  (* MX+T*)          assignEin(x, PosToImgSpace,[M,posx,T]) ,  (* MX+T*)
   
 (*          assignEin(xA, PosToImgSpaceA,[M,posx,T]) ,  (* MX*)  
         assignEin(x, PosToImgSpaceB,[xA,T]) ,  (* ^+T*)*)  
66          assign(nd, DstOp.Floor dim, [x]),   (*nd *)          assign(nd, DstOp.Floor dim, [x]),   (*nd *)
67          assignEin(f, mk.subTen([dim]),[x,nd]),           (*fractional*)          assignEin(f, mk.subTen([dim]),[x,nd]),           (*fractional*)
68          assign(n, DstOp.RealToInt dim, [nd]), (*real to Int*)          assign(n, DstOp.RealToInt dim, [nd]), (*real to Int*)
# Line 110  Line 71 
71      in ([n,f],P,code)      in ([n,f],P,code)
72      end      end
73    
74    fun getRHS x  = (case SrcIL.Var.binding x
75  fun replaceH(kvar, place,args)=let      of SrcIL.VB_RHS(SrcIL.OP(rator, args)) => (rator, args)
76      val l1=List.take(args, place)      | SrcIL.VB_RHS(SrcIL.VAR x') => getRHS x'
77      val l2=List.drop(args,place+1)      | vb => raise Fail(concat[ "expected rhs operator for ", SrcIL.Var.toString x, "but found ", SrcIL.vbToString vb])
     in l1@[kvar]@l2 end  
   
 fun getImageSrc x  = (case SrcIL.Var.binding x  
 of SrcIL.VB_RHS(SrcIL.OP(SrcOp.LoadImage(img),[ivar])) =>  
         (print(String.concat["\n MOUSE-TOP::","---",SrcIL.Var.toString(ivar)]))  
 | vb => print "not imgae op"  
 (* end case *))  
   
 fun getImageDst x  = (case DstIL.Var.binding x  
 of DstIL.VB_RHS(DstIL.OP(DstOp.LoadImage(img),[ivar])) =>  
 (print(String.concat["\n MOUSE-Orig:","---",DstIL.Var.toString(x),"\n MOUSE-BOT:","---",DstIL.Var.toString(ivar)]);ivar)  
 | vb => raise Fail  "not load op"  
78  (* end case *))  (* end case *))
79    
   
   
80  (*Get Img, and Kern Args*)  (*Get Img, and Kern Args*)
81  fun getArgs(hid,hArg,V,imgArg,args,lift,varI)=case (getRHS hArg,getRHS imgArg)  fun getArgs(hid,hArg,V,imgArg,args,lift,varI)=(case (getRHS hArg,getRHS imgArg)
82      of ((O2(SrcOp.Kernel(h, i)),argK),(O2(SrcOp.LoadImage img),[yy]))=> let      of ((SrcOp.Kernel(h, i), _ ),(SrcOp.LoadImage img, _ ))=> let
83          val hvar=DstV.new ("KNL", DstTy.KernelTy)          val hvar=DstV.new ("KNL", DstTy.KernelTy)
84          val imgvar=DstV.new ("IMG", DstTy.ImageTy img)          val imgvar=DstV.new ("IMG", DstTy.ImageTy img)
85          val argsVK= (case lift          val argsVK= (case lift
86              of 0=> let              of 0=> let
87                  val _=print "non lift"                  val _=print "non lift"
88                  val argsN=replaceH(hvar, hid,args)                  val l1=List.take(args, hid)
89                  in (*replaceH(imgvar, V,argsN)*) replaceH(varI, V,argsN) end                  val l2=List.drop(args,hid+1)
90              | _ =>(* [imgvar, hvar]*) [varI, hvar]                  in
91                        l1@[hvar]@l2
92                    end
93                | _ => [varI, hvar]
94          (* end case *))          (* end case *))
95    
           (*val Vimg= assign(imgvar,DstOp.LoadImage img, varI)*)  
   
96          val assigments=[assign (hvar, DstOp.Kernel(h, i), [])]          val assigments=[assign (hvar, DstOp.Kernel(h, i), [])]
97          in          in
98              (Kernel.support h ,img, assigments,argsVK)              ((Kernel.support h) ,img, assigments,argsVK)
99          end          end
100      | ((O2(SrcOp.Kernel(h, i)),arg),_)=> raise Fail "Not an img Argument"      |  _ => raise Fail "Expected Image and kernel argument"
101      |  _ => raise Fail "Not a kernel argument"      (*end case*))
102    
103    
104  fun handleArgs(V,h,t,(params,args),origargs,lift,dstargs)=let  fun handleArgs(V,h,t,(params,args),origargs,lift,dstargs)=let
# Line 160  Line 108 
108      val newposArg=List.nth(args, t)      val newposArg=List.nth(args, t)
109      val imgArgDst=List.nth(dstargs,V)      val imgArgDst=List.nth(dstargs,V)
110      val (s,img,argcode,argsVH) =getArgs(h,kArg,V,imgArg,args,lift,imgArgDst)      val (s,img,argcode,argsVH) =getArgs(h,kArg,V,imgArg,args,lift,imgArgDst)
111      val varII =getImageDst imgArgDst      val (argsT,P,code')=transformToImgSpace(dim,img,newposArg,imgArgDst)
   
     val (argsT,P,code')=transformToImgSpace(dim,img,newposArg,varII)  
112      in (dim,argsVH@argsT,argcode@code', s,P)      in (dim,argsVH@argsT,argcode@code', s,P)
113      end      end
114    
# Line 237  Line 183 
183    
184      (*Look at Args and get dim, mid-il ops, support, and Arg for transformation matrix P*)      (*Look at Args and get dim, mid-il ops, support, and Arg for transformation matrix P*)
185      val (dim,args',code,support,PArg) = handleArgs(V,H,t,(params,args), origargs,1)      val (dim,args',code,support,PArg) = handleArgs(V,H,t,(params,args), origargs,1)
186        val _ =print("\nSupport is "^Int.toString support)
187    
188      (*New transformations:params, sx, rest, will be empty if no transformation is made*)      (*New transformations:params, sx, rest, will be empty if no transformation is made*)
189      val (oldArg,newArg,dx, paramsT,sxT,restT,ixT,dataT) = T.Transform(dx,shapebind,Vshapebind,dim,PArg,nsumshift,ns,4)      val (oldArg,newArg,dx, paramsT,sxT,restT,ixT,dataT) = T.Transform(dx,shapebind,Vshapebind,dim,PArg,nsumshift,ns,4)
# Line 300  Line 247 
247    
248    
249      val (dim,argsA,code,s,PArg) = handleArgs(V,h,t,(params,args), origargs,0,dstargs)      val (dim,argsA,code,s,PArg) = handleArgs(V,h,t,(params,args), origargs,0,dstargs)
250        val _ =print("\nSupport is "^Int.toString s)
251      val (_,_,dx, _,sxT,restT,_,_) = T.Transform(dx,shapebind,Vshapebind,dim,PArg,nsumshift,1,nid+1)      val (_,_,dx, _,sxT,restT,_,_) = T.Transform(dx,shapebind,Vshapebind,dim,PArg,nsumshift,1,nid+1)
252    
253      val params'=params@[E.TEN(3,[dim]),E.TEN(1,[dim]),E.TEN(1,[dim,dim])]      val params'=params@[E.TEN(3,[dim]),E.TEN(1,[dim]),E.TEN(1,[dim,dim])]

Legend:
Removed from v.2680  
changed lines
  Added in v.2827

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