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/probe-ein.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/high-to-mid/probe-ein.sml

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

revision 3733, Thu Apr 7 21:50:15 2016 UTC revision 3734, Thu Apr 7 22:06:42 2016 UTC
# Line 87  Line 87 
87     * vector     * vector
88     *)     *)
89      fun buildPos (s, dir, dim, f) = let      fun buildPos (s, dir, dim, f) = let
90            val x = DstV.new ("x", DstTy.realTy)            val x = V.new ("x", Ty.realTy)
91            val u = DstV.new ("kernel_pos", DstTy.TensorTy[2*s])            val u = V.new ("kernel_pos", Ty.TensorTy[2*s])
92            val stms = [            val stms = [
93                    IR.ASSGN(x, IR.OP(Op.Index(DstTy.TensorTy[dim], dir), [f])),                    IR.ASSGN(x, IR.OP(Op.Index(Ty.TensorTy[dim], dir), [f])),
94                    IR.ASSGN(u, IR.OP(Op.BuildPos(s), [x]))                    IR.ASSGN(u, IR.OP(Op.BuildPos(s), [x]))
95                  ]                  ]
96            in            in
# Line 99  Line 99 
99    
100    (* apply differentiation *)    (* apply differentiation *)
101      fun getKrnDel (s, h, k, u) = let      fun getKrnDel (s, h, k, u) = let
102          val v = DstV.new ("kernel_del"^Int.toString k, DstTy.TensorTy[2*s])          val v = V.new ("kernel_del"^Int.toString k, Ty.TensorTy[2*s])
103          in          in
104            (v, IR.ASSGN(v, IR.OP(Op.EvalKernel(2*s, h, k), [u])))            (v, IR.ASSGN(v, IR.OP(Op.EvalKernel(2*s, h, k), [u])))
105          end          end
# Line 107  Line 107 
107    (*lifted Kernel expressions*)    (*lifted Kernel expressions*)
108  (* TODO: match against argsA list? *)  (* TODO: match against argsA list? *)
109      fun liftKrn (dx, dir, dim, argsA, hid, fid, s) = let      fun liftKrn (dx, dir, dim, argsA, hid, fid, s) = let
110          val (posV, stms) = buildPos (s, dir, dim, List.nth(args, fid))          val (posV, stms) = buildPos (s, dir, dim, List.nth(argsA, fid))
111          val h = List.nth(argsA, hid)          val h = List.nth(argsA, hid)
112          fun iter (0, vs, stms) = (vs, stms)          fun iter (0, vs, stms) = (vs, stms)
113            | iter (n, vs, stms) = let            | iter (n, vs, stms) = let
# Line 122  Line 122 
122            case vs            case vs
123             of [v] => (v, stms'@stms) (* scalar result *)             of [v] => (v, stms'@stms) (* scalar result *)
124              | _ => let              | _ => let
125                  val consTy = DstTy.TensorTy[nKernEvals, 2*s]                  val consTy = Ty.TensorTy[nKernEvals, 2*s]
126                  val resV = DstV.new ("kernel_cons", consTy)                  val resV = V.new ("kernel_cons", consTy)
127                  val stm = IR.ASSGN(resV, IR.CONS(vs, consTy))                  val stm = IR.ASSGN(resV, IR.CONS(vs, consTy))
128                  in                  in
129                    (resV, stm :: stms' @ stms)                    (resV, stm :: stms' @ stms)
# Line 152  Line 152 
152                  val pos0 = E.Opn(E.Add, [E.Tensor(fid,[cx]), Vsum])                  val pos0 = E.Opn(E.Add, [E.Tensor(fid,[cx]), Vsum])
153                  val deltas = List.map (fn e =>(cx, e)) dx                  val deltas = List.map (fn e =>(cx, e)) dx
154                  val rest0 = E.Krn(hid, deltas, E.Op2(E.Sub,E.Tensor(nid,[cx]), Vsum))                  val rest0 = E.Krn(hid, deltas, E.Op2(E.Sub,E.Tensor(nid,[cx]), Vsum))
155                  val (  (* WHAT NEXT?? *)
156                  in                  in
157                    createKRN (d', pos0::imgpos, rest0::rest)                    createKRN (d', pos0::imgpos, rest0::rest)
158                  end                  end
# Line 216  Line 216 
216            val params' = params @ [E.TEN(true, [dim]), E.TEN(true, [dim]), E.TEN(true, [dim, dim])]            val params' = params @ [E.TEN(true, [dim]), E.TEN(true, [dim]), E.TEN(true, [dim, dim])]
217            val probe' = fieldReconstruction (avail, dim, s, freshIndex+length dx', alpha, dx', Vid, hid, n, f)            val probe' = fieldReconstruction (avail, dim, s, freshIndex+length dx', alpha, dx', Vid, hid, n, f)
218            val (_, body') = arrangeBody (body, Ps, sx', probe')            val (_, body') = arrangeBody (body, Ps, sx', probe')
219            val einapp = (y, IR.EINAPP(mkEin(params', index, body'), argsA@[n, f, PArg]))            val einapp = (y, IR.EINAPP(mkEin(params', index, body'), args @ [n, f, PArg]))
220            in            in
221              AvailRHS.addAssignToList (avail, einapp)              AvailRHS.addAssignToList (avail, einapp)
222            end            end
# Line 285  Line 285 
285                  replaceProbe (avail, e, E.Probe p, sx)                  replaceProbe (avail, e, E.Probe p, sx)
286              | (E.Sum(sx, E.Opn(E.Prod, [eps, E.Probe p]))) =>              | (E.Sum(sx, E.Opn(E.Prod, [eps, E.Probe p]))) =>
287                  replaceProbe (avail, e, E.Probe p, sx)                  replaceProbe (avail, e, E.Probe p, sx)
288              | _ => addAssignToList (avail, e)              | _ => AvailRHS.addAssignToList (avail, e)
289            (* end case *))            (* end case *))
290    
291    end (* ProbeEin *)    end (* ProbeEin *)

Legend:
Removed from v.3733  
changed lines
  Added in v.3734

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