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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/high-to-mid/probe.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/high-to-mid/probe.sml

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

revision 736, Sat Apr 2 18:50:43 2011 UTC revision 737, Sat Apr 2 19:48:56 2011 UTC
# Line 140  Line 140 
140           *)           *)
141            val diffIter = let            val diffIter = let
142                  val partial = Partials.partial dim                  val partial = Partials.partial dim
143                  fun f (i, axes) = Partials.axis i :: axes                  fun f (i, (_::dd, axes)) = (dd, Partials.axis i :: axes)
144                  fun g axes = let                  fun labelNd (_::dd, _) = DstTy.tensorTy dd
145                    fun labelLf (_, axes) = let
146                          val r = DstV.new(                          val r = DstV.new(
147                                  String.concat("r" :: List.map Partials.axisToString axes),                                  String.concat("r" :: List.map Partials.axisToString axes),
148                                  DstTy.realTy)                                  DstTy.realTy)
# Line 149  Line 150 
150                            (r, partial axes)                            (r, partial axes)
151                          end                          end
152                  in                  in
153                    IT.create (k, dim, fn _ => (), f, g, [])                    IT.create (k, dim, labelNd, f, labelLf, (List.tabulate(k, fn _ => dim), []))
154                  end                  end
155  val _ = let  val _ = let
156  val indentWid = ref 2  val indentWid = ref 2
157  fun inc () = (indentWid := !indentWid + 2)  fun inc () = (indentWid := !indentWid + 2)
158  fun dec () = (indentWid := !indentWid - 2)  fun dec () = (indentWid := !indentWid - 2)
159  fun indent () = print(CharVector.tabulate(!indentWid, fn _ => #" "))  fun indent () = print(CharVector.tabulate(!indentWid, fn _ => #" "))
160  fun nd () = (indent(); print "ND\n");  fun nd ty = (indent(); print(concat["ND(", DstTy.toString ty, ")\n"]))
161  fun lf (x, partial) = (  fun lf (x, partial) = (
162        indent(); print(concat["LF(", DstV.toString x, ", ", Partials.partialToString partial, ")\n"]))        indent(); print(concat["LF(", DstV.toString x, ", ", Partials.partialToString partial, ")\n"]))
163  fun pr (Shape.ND(attr, kids)) = (nd attr; inc(); List.app pr kids; dec())  fun pr (Shape.ND(attr, kids)) = (nd attr; inc(); List.app pr kids; dec())
# Line 229  Line 230 
230                  in                  in
231                    List.foldr genProbeCode (cons (result, List.map getProbeVar kids) :: code) kids                    List.foldr genProbeCode (cons (result, List.map getProbeVar kids) :: code) kids
232                  end                  end
233              | genProbe (result, IT.ND(_, kids), code) = let              | genProbe (result, IT.ND(ty, kids), code) = let
234                  val tmps = List.tabulate(dim, fn i => DstV.new("t"^Int.toString i, DstTy.realTy))  (* FIXME: the type of the tmps depends on the types of the kids *)
235                    val tmps = List.tabulate(dim, fn i => DstV.new("t"^Int.toString i, ty))
236                  val code = cons(result, tmps) :: code                  val code = cons(result, tmps) :: code
237                  fun lp ([], [], code) = code                  fun lp ([], [], code) = code
238                    | lp (t::ts, kid::kids, code) = genProbe(t, kid, lp(ts, kids, code))                    | lp (t::ts, kid::kids, code) = genProbe(t, kid, lp(ts, kids, code))

Legend:
Removed from v.736  
changed lines
  Added in v.737

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