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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/high-to-mid/clean-params.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/high-to-mid/clean-params.sml

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

revision 3574, Mon Jan 11 23:05:08 2016 UTC revision 3575, Tue Jan 12 15:05:58 2016 UTC
# Line 32  Line 32 
32              | _ => raise Fail(str ^ Int.toString e1)              | _ => raise Fail(str ^ Int.toString e1)
33            (* end case *))            (* end case *))
34    
     (* mkMapp:dict*params*var list ->dict*params*var list  
     * countmapp dictionary keeps track of which ids have been used  
     * mapp id the dictionary of the new ids  
     *)  
     fun mkMapp (freeParams, params, args) = let  
           fun m (_, _, mapp, p, [], a, []) = (mapp, rev p, rev a)  
             | m (i, j, mapp, p, p1::params, a, a1::arg) =  
                 if ISet.member(freeParams, i)  
                   then let  
                     val mapp2 = IMap.insert(mapp, i, j)  
                     in  
                       m (i+1, j+1, mapp2, p1::p, params, a1::a, arg)  
                     end  
                   else m (i+1, j, mapp, p, params, a, arg)  
             | m (_, _, _, _, _, _, []) = raise Fail "too many parameters"  
             | m (_, _, _, _, [], _, _) = raise Fail "too many args"  
           in  
             m (0, 0, IMap.empty, [], params, [], args)  
           end  
   
35    (* walk the ein expression and compute the set of free parameter indices (i.e., tensor,    (* walk the ein expression and compute the set of free parameter indices (i.e., tensor,
36     * image, and kernel variables) in the expression.     * image, and kernel variables) in the expression.
37     *)     *)
38      fun getIdCount b = let      fun getFreeParams b = let
39            fun walk (b, mapp) = (case b            fun walk (b, mapp) = (case b
40                   of E.Tensor(id, _) => ISet.add(mapp, id)                   of E.Tensor(id, _) => ISet.add(mapp, id)
41                    | E.Conv(v, _, h, _) => ISet.add(ISet.add(mapp, h), v)                    | E.Conv(v, _, h, _) => ISet.add(ISet.add(mapp, h), v)
# Line 73  Line 53 
53              walk (b, ISet.empty)              walk (b, ISet.empty)
54            end            end
55    
56        (* mkMapp:dict*params*var list ->dict*params*var list
57        * countmapp dictionary keeps track of which ids have been used
58        * mapp id the dictionary of the new ids
59        *)
60        fun mkMapp (freeParams, params, args) = let
61              fun m (_, _, mapp, p, [], a, []) = (mapp, rev p, rev a)
62                | m (i, j, mapp, p, p1::params, a, a1::arg) =
63                    if ISet.member(freeParams, i)
64                      then let
65                        val mapp2 = IMap.insert(mapp, i, j)
66                        in
67                          m (i+1, j+1, mapp2, p1::p, params, a1::a, arg)
68                        end
69                      else m (i+1, j, mapp, p, params, a, arg)
70                | m (_, _, _, _, _, _, []) = raise Fail "too many parameters"
71                | m (_, _, _, _, [], _, _) = raise Fail "too many args"
72              in
73                m (0, 0, IMap.empty, [], params, [], args)
74              end
75    
76      (*rewriteParam:dict*ein_exp ->ein_exp      (*rewriteParam:dict*ein_exp ->ein_exp
77      *rewrite ids in exp using mapp      *rewrite ids in exp using mapp
78      *)      *)
# Line 96  Line 96 
96      *cleans params      *cleans params
97      *)      *)
98      fun clean (y, body, params, index, args) = let      fun clean (y, body, params, index, args) = let
99            val freeParams = getIdCount body            val freeParams = getFreeParams body
100            val (mapp, Nparams, Nargs) = mkMapp (freeParams, params, args)            val (mapp, Nparams, Nargs) = mkMapp (freeParams, params, args)
101            val Nbody = rewriteParam (mapp, body)            val Nbody = rewriteParam (mapp, body)
102            in            in

Legend:
Removed from v.3574  
changed lines
  Added in v.3575

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