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 3258, Sun Sep 20 18:05:06 2015 UTC revision 3259, Mon Sep 21 15:14:52 2015 UTC
# Line 57  Line 57 
57      fun getBody(_,DstIL.EINAPP(E.EIN{body,...},_))=body      fun getBody(_,DstIL.EINAPP(E.EIN{body,...},_))=body
58      fun setBody(body',(y,DstIL.EINAPP(E.EIN{params,index,body},args)))=      fun setBody(body',(y,DstIL.EINAPP(E.EIN{params,index,body},args)))=
59              (y,DstIL.EINAPP(E.EIN{params=params,index=index,body=body'},args))              (y,DstIL.EINAPP(E.EIN{params=params,index=index,body=body'},args))
60        fun setBodye(body',E.EIN{params,index,body})=
61               E.EIN{params=params,index=index,body=body'}
62    
63      fun testp n=(case testing      fun testp n=(case testing
64          of 0=> 1          of 0=> 1
# Line 239  Line 241 
241              | E.Sum(sx,E.Prod[eps0,E.Probe _ ])  => (false,E.Sum(sx,E.Prod[eps0,multiPs(Ps,newsx,t)]))              | E.Sum(sx,E.Prod[eps0,E.Probe _ ])  => (false,E.Sum(sx,E.Prod[eps0,multiPs(Ps,newsx,t)]))
242              | _                                  => (case tsplitvar              | _                                  => (case tsplitvar
243                  of(* true =>   (true,multiMergePs(Ps,newsx,t))  (*pushes summations in place*)                  of(* true =>   (true,multiMergePs(Ps,newsx,t))  (*pushes summations in place*)
244                  | false*) _ =>   (false,multiPs(Ps,newsx,t))                  | false*) _ =>   (true,multiPs(Ps,newsx,t))
245                  (*end case*))                  (*end case*))
246              (*end case*))              (*end case*))
247    
# Line 252  Line 254 
254          val originalb=Ein.body e          val originalb=Ein.body e
255          val params=Ein.params e          val params=Ein.params e
256          val index=Ein.index e          val index=Ein.index e
257          val _=("\n"^P.printbody originalb)          val _=print("\n Inside Lift: "^P.printbody originalb)
258    
259          val E.Probe(E.Conv(Vid,alpha,hid,dx),E.Tensor(tid,_))=p          val E.Probe(E.Conv(Vid,alpha,hid,dx),E.Tensor(tid,_))=p
260          val fid=length(params)          val fid=length(params)
# Line 278  Line 280 
280          val einApp1=mkEinApp(ein1,args')          val einApp1=mkEinApp(ein1,args')
281          val rtn1=(FArg,einApp1)          val rtn1=(FArg,einApp1)
282          val rtn=code@[rtn1]@rtn0          val rtn=code@[rtn1]@rtn0
283          (*val _= einapptostring (originalb,rtn1,rtn0)*)  
284          in          in
285              rtn              rtn
286          end          end
287    
   
288      (* expandEinOp: code->  code list      (* expandEinOp: code->  code list
289      *A this point we only have simple ein ops      *A this point we only have simple ein ops
290      *Looks to see if the expression has a probe. If so, replaces it.      *Looks to see if the expression has a probe. If so, replaces it.
# Line 291  Line 292 
292      *)      *)
293     fun expandEinOp( e as (y, DstIL.EINAPP(ein,args)),fieldset)=let     fun expandEinOp( e as (y, DstIL.EINAPP(ein,args)),fieldset)=let
294    
   
295          fun checkConst ([],a) = liftProbe a          fun checkConst ([],a) = liftProbe a
296          | checkConst ((E.C _::_),a) =(("\n \n constant field"^(printEINAPP e));replaceProbe a)          | checkConst ((E.C _::_),a) =(print("\n \n constant field"^(printEINAPP e));replaceProbe a)
297          | checkConst ((_ ::es),a)= checkConst(es,a)          | checkConst ((_ ::es),a)= checkConst(es,a)
298    
299          fun rewriteBody b=(case b          fun rewriteBody b=(case b
300              of E.Probe(E.Conv(_,_,_,[]),_)              of E.Probe(E.Conv(_,_,_,[]),_)
301                  => replaceProbe(0,e,b, [])                  => replaceProbe(0,e,b, [])
302              | E.Probe(E.Conv (_,alpha,_,dx),_)              | E.Probe(E.Conv (_,alpha,_,dx),_)
303                  => checkConst(alpha@dx,(0,e,b,[]))                  => checkConst(dx,(0,e,b,[])) (*scans dx for contant*)
304              | E.Sum(sx,p as E.Probe(E.Conv(_,_,_,[]),_))              | E.Sum(sx,p as E.Probe(E.Conv(_,_,_,[]),_))
305                  => replaceProbe(0,e,p, sx)                  => replaceProbe(0,e,p, sx)
306              | E.Sum(sx,p as E.Probe(E.Conv(_,[],_,dx),_))              | E.Sum(sx,p as E.Probe(E.Conv(_,[],_,dx),_))
307                  => checkConst(dx,(0,e,p,sx))                  => checkConst(dx,(0,e,p,sx))
308              (*| E.Sum(sx as [(v,_,_)],p as (E.Probe((E.Conv(_,alpha,_,dx),_))))=>(case              | E.Sum(sx as [(v,_,_)],p as (E.Probe((E.Conv(_,alpha,_,dx),_))))=>
309                      (List.find (fn x => x = v) dx)                  (print(P.printbody(b));case (List.find (fn x => x = v) dx)
310                      of NONE=>  checkConst(alpha@dx,(1,e,p,sx))                      of NONE=>  checkConst(dx,(1,e,p,sx))
311                      (*need to push summation to lifted exp rather than transform exp.*)                      (*need to push summation to lifted exp rather than transform exp.*)
312                      | SOME _=> replaceProbe(1,e, p, sx)                      | SOME _=> replaceProbe(1,e, p, sx)
313                      (*end case*))*)                  (*end case*))
314                | E.Sum(sx as [(v1,_,_),(v2,_,_)],p as (E.Probe((E.Conv(_,alpha,_,dx),_))))=>
315                    (print(P.printbody(b));case ((List.find (fn x => x = v1) dx),(List.find (fn x => x = v2) dx))
316                        of (NONE,NONE)=>  checkConst(dx,(1,e,p,sx))
317                        |  ( _ , NONE)=>  checkConst(dx,(1,e,p,sx))
318                        |  _=> (*replaceProbe(1,e, p, sx)*) checkConst(dx,(1,e,p,sx))
319                    (*end case*))
320              | E.Sum(sx,E.Probe p)              | E.Sum(sx,E.Probe p)
321                  => replaceProbe(0,e,E.Probe p, sx)                  => replaceProbe(0,e,E.Probe p, sx)
322              | E.Sum(sx,E.Prod[eps,E.Probe p])              | E.Sum(sx,E.Prod[eps,E.Probe p])
# Line 322  Line 329 
329          of NONE=> (("\n \n not replacing"^(printEINAPP e));(rewriteBody(Ein.body ein),fieldset))          of NONE=> (("\n \n not replacing"^(printEINAPP e));(rewriteBody(Ein.body ein),fieldset))
330          | SOME v=> (("\n replacing"^(P.printerE ein));( [(y,DstIL.VAR v)] , fieldset))          | SOME v=> (("\n replacing"^(P.printerE ein));( [(y,DstIL.VAR v)] , fieldset))
331              (*end case*))              (*end case*))
   
         (*val code=rewriteBody(Ein.body ein)  
         in (code,fieldset)*)  
332          end          end
333    
334    end; (* local *)    end; (* local *)

Legend:
Removed from v.3258  
changed lines
  Added in v.3259

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