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

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

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

revision 3555, Thu Jan 7 21:42:13 2016 UTC revision 3556, Fri Jan 8 13:49:42 2016 UTC
# Line 1  Line 1 
1  structure Float : sig  (* float-ein.sml
2     *
3     * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
4     *
5     * COPYRIGHT (c) 2016 The University of Chicago
6     * All rights reserved.
7     *)
8    
9    structure FloatEin : sig
10    
11      val transform : MidIR.var * Ein.ein * MidIR.var list -> MidIR.assignment list      val transform : MidIR.var * Ein.ein * MidIR.var list -> MidIR.assignment list
12    
13    end = struct    end = struct
14    
15      structure IR = MidIR      structure IR = MidIR
16        structure V = IR.Var
17        structure Ty = MidTypes
18      structure E = Ein      structure E = Ein
19    
20      fun cut (name, origProbe, params, index, sx, argsOrig, avail, newvx) = let      fun cut (name, origProbe, params, index, sx, argsOrig, avail, newvx) = let
# Line 12  Line 22 
22            val (tshape, sizes, body) = cleanIndex (origProbe, index, sx)            val (tshape, sizes, body) = cleanIndex (origProbe, index, sx)
23            val id = length params            val id = length params
24            val Rparams = params@[E.TEN(true, sizes)]            val Rparams = params@[E.TEN(true, sizes)]
25            val M = DstV.new (concat[name, "_l_", itos id], DstTy.TensorTy sizes)            val M = V.new (concat[name, "_l_", Int.toString id], Ty.TensorTy sizes)
26            val (y, DstIL.EINAPP(ein, args)) = cleanParams(M, body, Rparams, sizes, argsOrig@[M])            val (y, IR.EINAPP(ein, args)) = cleanParams(M, body, Rparams, sizes, argsOrig@[M])
27        (*shift indices in probe body from constant to variable*)        (*shift indices in probe body from constant to variable*)
28            val E.Probe(E.Conv(V, [c1], h, dx), pos) = Ein.body ein            val Ein.EIN{
29            val index0 = Ein.index ein                    body=E.Probe(E.Conv(V, [c1], h, dx), pos),
30                      index = index0,
31                      params = params0
32                    } = ein
33  (* FIXME: this code is specialized to 3D *)  (* FIXME: this code is specialized to 3D *)
34            val index1 = index0@[3]            val index1 = index0@[3]
35            val body1_unshifted = E.Probe(E.Conv(V, [E.V newvx], h, dx), pos)            val unshiftedBody = E.Probe(E.Conv(V, [E.V newvx], h, dx), pos)
36          (* clean to get body indices in order *)          (* clean to get body indices in order *)
37            val (_ , _, body1) = cleanIndex.cleanIndex (body1_unshifted, index1, [])            val (_ , _, body1) = cleanIndex.cleanIndex (unshiftedBody, index1, [])
38            val lhs1 = DstV.new ("L", DstTy.TensorTy index1)            val lhs1 = V.new ("L", Ty.TensorTy index1)
39            val ein1 = mkEin(Ein.params ein,index1,body1)            val ein1 = mkEin(params0, index1, body1)
40            val lhs2 = AvailRHS.addAssign avail (lhs1, mkEinApp(ein1, args))            val lhs2 = AvailRHS.addAssign avail (lhs1, mkEinApp(ein1, args))
41            val Rargs = argsOrig @ [lhs2]            val Rargs = argsOrig @ [lhs2]
42          (*Probe that tensor at a constant position  c1*)          (*Probe that tensor at a constant position  c1*)
# Line 44  Line 57 
57            val id = length params            val id = length params
58            val Rparams = params @ [E.TEN(true, sizes)]            val Rparams = params @ [E.TEN(true, sizes)]
59            val Re = E.Tensor(id, tshape)            val Re = E.Tensor(id, tshape)
60            val M = DstV.new (concat[name, "_l_", itos id], DstTy.TensorTy sizes)            val M = V.new (concat[name, "_l_", Int.toString id], Ty.TensorTy sizes)
61            val (_, einapp) = cleanParams (M, body, Rparams, sizes, args @ [M])            val (_, einapp) = cleanParams (M, body, Rparams, sizes, args @ [M])
62            val var = AvailRHS.add avail (M, einapp)            val var = AvailRHS.addAssign avail (M, einapp)
63            val Rargs = argsOrig @ [var]            val Rargs = args @ [var]
64            in            in
65              (Re, Rparams, Rargs)              (Re, Rparams, Rargs)
66            end            end
# Line 73  Line 86 
86                        then let                        then let
87                          val (e', params', args') = lift("op1_e3", e, params, index, sx, args, avail)                          val (e', params', args') = lift("op1_e3", e, params, index, sx, args, avail)
88                          in                          in
89                            filterOps (es, e'::es', params', args')                            filter (es, e'::es', params', args')
90                          end                          end
91                        else filter (es, e::es', params, args)                        else filter (es, e::es', params, args)
92                  in                  in
# Line 107  Line 120 
120                    | E.Opn(opn, es) => let                    | E.Opn(opn, es) => let
121                        fun iter ([], es, params, args) = (List.rev es, params, args)                        fun iter ([], es, params, args) = (List.rev es, params, args)
122                          | iter (e::es, es', params, args) = let                          | iter (e::es, es', params, args) = let
123                              val (e', params', args') = rewrite (e, params, args)                              val (e', params', args') = rewrite (sx, e, params, args)
124                              in                              in
125                                iter (es, e'::es', params', args')                                iter (es, e'::es', params', args')
126                              end                              end
# Line 126  Line 139 
139            val (body', params', args') = rewrite ([], body, params, args)            val (body', params', args') = rewrite ([], body, params, args)
140            val einapp = cleanParams (y, body', params', index, args')            val einapp = cleanParams (y, body', params', index, args')
141            in            in
142              List.rev (IR.ASSGN(y, einapp) :: AvailEin.getAssignments avail)              List.rev (IR.ASSGN(y, einapp) :: AvailRHS.getAssignments avail)
143            end            end
144    
145    end    end

Legend:
Removed from v.3555  
changed lines
  Added in v.3556

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