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

SCM Repository

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

Diff of /branches/charisee/src/compiler/mid-to-low/helper.sml

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

revision 3138, Thu Mar 26 16:27:35 2015 UTC revision 3196, Fri May 29 18:42:37 2015 UTC
# Line 121  Line 121 
121      * projects tensor to a vector      * projects tensor to a vector
122      *just used by EintoVecOps but made sense to keep it here      *just used by EintoVecOps but made sense to keep it here
123      *)      *)
124      fun projTensor(_,(_,_,args,_,id,[]))= (List.nth(args,id),[])      fun (* projTensor(_,(_,_,args,3,id,[]))=let
125            val opp=DstOp.LdVec 3
126            val nU=List.nth(args,id)
127            val name=String.concat["LdVec_"]
128            val vecTy=DstTy.TensorTy [3]
129            in
130                assgn(opp,[nU],name,vecTy)
131            end
132        |*) projTensor(_,(_,_,args,_,id,[]))= (List.nth(args,id),[])
133      | projTensor(mapp,(lhs,params,args,vecIX,id,ix))= let      | projTensor(mapp,(lhs,params,args,vecIX,id,ix))= let
134          val nU=List.nth(args,id)          val nU=List.nth(args,id)
135          val ixx=(List.map (fn (e1)=> mapIndex(e1,mapp)) ix)          val ixx=(List.map (fn (e1)=> mapIndex(e1,mapp)) ix)
136          val ix'=DstTy.indexTy ixx          val ix'=DstTy.indexTy ixx
137          val argTy= getTensorTy(params,id)          val argTy= getTensorTy(params,id)
138          val vecTy=DstTy.TensorTy [vecIX]          val vecTy=DstTy.TensorTy [vecIX]
139          val opp=DstOp.ProjectTensor(id,vecIX,ix',argTy)          val opp=DstOp.ProjectLast(id,vecIX,ix',argTy)
140          val name=String.concat["Proj_",iToss ixx,"_"]          val name=String.concat["ProjLast_",iToss ixx,"_"]
141          in          in
142              assgn(opp,[nU],name,vecTy)              assgn(opp,[nU],name,vecTy)
143          end          end
144    
145    
146        fun projFirst(mapp,(lhs,params,args,vecIX,id,ix))= let
147            val nU=List.nth(args,id)
148            val argTy= getTensorTy(params,id)
149            val vecTy=DstTy.TensorTy [vecIX]
150            val ixx=(List.map (fn (e1)=> mapIndex(e1,mapp)) ix)
151            fun f cnt = let
152                val ix'=DstTy.indexTy ([cnt]@ixx)
153                val opp=DstOp.IndexTensor(id,ix',argTy)
154                val name=String.concat["IndexTensor_",iToss ixx,"_"]
155                in
156                    assgn(opp,[nU],name,realTy)
157                end
158            val ops=List.tabulate( vecIX, fn e=> f e)
159            fun iter ([],vCs,Cs)=(vCs,Cs)
160              | iter((vB,B)::es,vCs,Cs)= iter(es,vCs@[vB],Cs@B)
161    
162             val (vCs,Cs)=iter(ops,[],[])
163             val (vD,D)=assgnCons("projFirstCons", [vecIX], vCs)
164            in
165                (vD, Cs@D)
166            end
167    
168    
169    
170        fun projFirst2(mapp,(lhs,params,args,vecIX,id,ix))= let
171            val nU=List.nth(args,id)
172            val argTy= getTensorTy(params,id)
173            val vecTy=DstTy.TensorTy [vecIX]
174            val ixx=(List.map (fn (e1)=> mapIndex(e1,mapp)) ix)
175            val ix'=DstTy.indexTy ixx
176            val opp=DstOp.ProjectFirst(id,vecIX,ix',argTy)
177            val name=String.concat["ProjFirst_",iToss ixx,"_"]
178            in assgn(opp,[nU],name,vecTy)
179            end
180    
181    
182    
183      fun mkSqrt(nU,code)= let      fun mkSqrt(nU,code)= let
184          val opp=DstOp.Sqrt          val opp=DstOp.Sqrt
185          val name=String.concat["_Sqrt_"]          val name=String.concat["_Sqrt_"]

Legend:
Removed from v.3138  
changed lines
  Added in v.3196

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