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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/high-ir/check-high.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/high-ir/check-high.sml

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

revision 4264, Tue Jul 26 03:49:05 2016 UTC revision 4265, Tue Jul 26 12:48:43 2016 UTC
# Line 14  Line 14 
14      type rator = Op.rator      type rator = Op.rator
15      type ty = Ty.ty      type ty = Ty.ty
16    
   (* utility function for synthesizing eigenvector/eigenvalue signature *)  
     fun eigenSig dim = let  
           val tplTy = Ty.TupleTy[  
                   Ty.SeqTy(Ty.realTy, SOME dim),  
                   Ty.SeqTy(Ty.vecTy dim, SOME dim)  
                 ]  
           in  
             (tplTy, [Ty.TensorTy[dim, dim]])  
           end  
   
17      fun chkIndex (idx, bnd) = ((0 <= idx) andalso (idx < bnd))      fun chkIndex (idx, bnd) = ((0 <= idx) andalso (idx < bnd))
18    
19    (* Return the signature of a HighIL operator. *)    (* Return the signature of a HighIL operator. *)
# Line 48  Line 38 
38              | Op.Clamp ty => (ty, [ty, Ty.realTy, Ty.realTy])              | Op.Clamp ty => (ty, [ty, Ty.realTy, Ty.realTy])
39              | Op.MapClamp ty => (ty, [ty, ty, ty])              | Op.MapClamp ty => (ty, [ty, ty, ty])
40              | Op.Lerp ty => (ty, [ty, ty, Ty.realTy])              | Op.Lerp ty => (ty, [ty, ty, Ty.realTy])
             | Op.Eigen2x2 => eigenSig 2  
             | Op.Eigen3x3 => eigenSig 3  
41              | Op.Zero ty => (ty, [])              | Op.Zero ty => (ty, [])
42              | Op.TensorIndex(ty as Ty.TensorTy shp, idxs) =>              | Op.TensorIndex(ty as Ty.TensorTy shp, idxs) =>
43                  if ListPair.allEq chkIndex (idxs, shp)                  if ListPair.allEq chkIndex (idxs, shp)
# Line 92  Line 80 
80              | Op.BorderCtlWrap info => (Ty.ImageTy info, [Ty.ImageTy info])              | Op.BorderCtlWrap info => (Ty.ImageTy info, [Ty.ImageTy info])
81              | Op.LoadSeq(ty, _) => (ty, [])              | Op.LoadSeq(ty, _) => (ty, [])
82              | Op.LoadImage(ty, _) => (ty, [])              | Op.LoadImage(ty, _) => (ty, [])
             | Op.Print tys => (Ty.TupleTy[], tys)  
83              | Op.MathFn f => MathFns.sigOf (Ty.realTy, f)              | Op.MathFn f => MathFns.sigOf (Ty.realTy, f)
84              | _ => raise Fail("sigOf: invalid operator " ^ Op.toString rator)              | _ => raise Fail("sigOf: invalid operator " ^ Op.toString rator)
85            (* end case *))            (* end case *))
86    
87      (* utility function for synthesizing eigenvector/eigenvalue signature *)
88        fun eigenSig dim = let
89              val resTy = [
90                      Ty.SeqTy(Ty.realTy, SOME dim),
91                      Ty.SeqTy(Ty.vecTy dim, SOME dim)
92                    ]
93              in
94                (resTy, [Ty.TensorTy[dim, dim]])
95              end
96    
97        fun msigOf rator = (case rator
98               of Op.Eigen2x2 => eigenSig 2
99                | Op.Eigen3x3 => eigenSig 3
100                | Op.Print tys => ([], tys)
101                | _ => raise Fail("msigOf: invalid operator " ^ Op.toString rator)
102              (* end case *))
103    
104      fun typeOfCons (Ty.TensorTy dd', (ty1 as Ty.TensorTy dd)::r) =      fun typeOfCons (Ty.TensorTy dd', (ty1 as Ty.TensorTy dd)::r) =
105            if List.all (fn ty => Ty.same(ty1, ty)) r            if List.all (fn ty => Ty.same(ty1, ty)) r
106              then (dd' = (List.length r + 1)::dd)              then (dd' = (List.length r + 1)::dd)

Legend:
Removed from v.4264  
changed lines
  Added in v.4265

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