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

SCM Repository

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

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

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

revision 3190, Sat Apr 4 00:18:24 2015 UTC revision 3195, Wed May 20 21:02:12 2015 UTC
# Line 172  Line 172 
172      fun multiPs([P0,P1,P2],sx,body)= formBody(E.Sum(sx, E.Prod([P0,P1,P2,body])))      fun multiPs([P0,P1,P2],sx,body)= formBody(E.Sum(sx, E.Prod([P0,P1,P2,body])))
173        | multiPs(Ps,sx,body)=formBody(E.Sum(sx, E.Prod([body]@Ps)))        | multiPs(Ps,sx,body)=formBody(E.Sum(sx, E.Prod([body]@Ps)))
174    
175    
176        fun multiMergePs([P0,P1],[sx0,sx1],body)=E.Sum([sx0],E.Prod[P0,E.Sum([sx1],E.Prod[P1,body])])
177          | multiMergePs e=multiPs e
178    
179    
180      (* replaceProbe:ein_exp* params *midIL.var list * int list* sum_id list      (* replaceProbe:ein_exp* params *midIL.var list * int list* sum_id list
181              -> ein_exp* *code              -> ein_exp* *code
182      * Transforms position to world space      * Transforms position to world space
# Line 213  Line 218 
218              code@[einapp]              code@[einapp]
219          end          end
220    
221        val tsplitvar=true
222      fun createEinApp(originalb,alpha,index,freshIndex,dim,dx,sx)= let      fun createEinApp(originalb,alpha,index,freshIndex,dim,dx,sx)= let
223          val Pid=0          val Pid=0
224          val tid=1          val tid=1
# Line 229  Line 234 
234          val params=[E.TEN(1,[dim,dim]),E.TEN(1,sizes)]          val params=[E.TEN(1,[dim,dim]),E.TEN(1,sizes)]
235          val tshape=alpha@newdx          val tshape=alpha@newdx
236          val t=E.Tensor(tid,tshape)          val t=E.Tensor(tid,tshape)
237          val exp = multiPs(Ps,newsx,t)          val (splitvar,body)=(case originalb
238          val body=(case originalb              of E.Sum(sx, E.Probe _)              => (false,E.Sum(sx,multiPs(Ps,newsx,t)))
239              of E.Sum(sx, E.Probe _)              => E.Sum(sx,exp)              | E.Sum(sx,E.Prod[eps0,E.Probe _ ])  => (false,E.Sum(sx,E.Prod[eps0,multiPs(Ps,newsx,t)]))
240              | E.Sum(sx,E.Prod[eps0,E.Probe _ ])  => E.Sum(sx,E.Prod[eps0,exp])              | _                                  => (case tsplitvar
241              | _                                  => exp                  of false => (false,multiPs(Ps,newsx,t))
242                    | true =>   (true,multiMergePs(Ps,newsx,t))  (*pushes summations in place*)
243                    (*end case*))
244              (*end case*))              (*end case*))
245    
246          val ein0=mkEin(params,index,body)          val ein0=mkEin(params,index,body)
247          in          in
248              (ein0,sizes,dx)              (splitvar,ein0,sizes,dx)
249          end          end
250    
251      fun liftProbe(testN,(y, DstIL.EINAPP(e,args)),p ,sx)=let      fun liftProbe(testN,(y, DstIL.EINAPP(e,args)),p ,sx)=let
# Line 256  Line 263 
263    
264    
265          (*transform T*P*P..Ps*)          (*transform T*P*P..Ps*)
266          val (ein0,sizes,dx)= createEinApp(originalb,alpha,index,freshIndex,dim,dx,sx)          val (splitvar,ein0,sizes,dx)= createEinApp(originalb,alpha,index,freshIndex,dim,dx,sx)
267          val FArg  = DstV.new ("F", DstTy.TensorTy(sizes))          val FArg  = DstV.new ("F", DstTy.TensorTy(sizes))
268          val einApp0=mkEinApp(ein0,[PArg,FArg])          val einApp0=mkEinApp(ein0,[PArg,FArg])
269          val rtn0=(y,einApp0)          val rtn0=(case splitvar
270                of false => [(y,einApp0)]
271                | _      => Split.splitEinApp (y,einApp0)
272                (*end case*))
273    
274          (*lifted probe*)          (*lifted probe*)
275          val params'=params@[E.TEN(3,[dim]),E.TEN(1,[dim])]          val params'=params@[E.TEN(3,[dim]),E.TEN(1,[dim])]
# Line 267  Line 277 
277          val ein1=mkEin(params',sizes,body')          val ein1=mkEin(params',sizes,body')
278          val einApp1=mkEinApp(ein1,args')          val einApp1=mkEinApp(ein1,args')
279          val rtn1=(FArg,einApp1)          val rtn1=(FArg,einApp1)
280          val rtn=code@[rtn1,rtn0]          val rtn=code@[rtn1]@rtn0
281          val _= einapptostring (originalb,rtn1,rtn0)          (*val _= einapptostring (originalb,rtn1,rtn0)*)
282          in          in
283              rtn              rtn
284          end          end

Legend:
Removed from v.3190  
changed lines
  Added in v.3195

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