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

SCM Repository

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

Diff of /branches/vis15/src/compiler/tree-ir/tree-types.sml

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

revision 3941, Wed Jun 8 19:10:45 2016 UTC revision 3955, Sun Jun 12 15:55:01 2016 UTC
# Line 25  Line 25 
25                                           * and the second is the target width, which will be                                           * and the second is the target width, which will be
26                                           * >= the vector width.                                           * >= the vector width.
27                                           *)                                           *)
 (* QUESTION: should we have a TensorRefTy that is represented as "float *" (instead  
  * of as "float[n]"), or should we just drop the length when converting TensorTy to  
  * a C++ type?  
  *)  
28        | TensorTy of int list            (* in-memory tensor type.  For 0th order and 1st        | TensorTy of int list            (* in-memory tensor type.  For 0th order and 1st
29                                           * order tensors, the local-variable types will                                           * order tensors, the local-variable types will
30                                           * be RealTy and VecTy (resp.).                                           * be RealTy and VecTy (resp.).
31                                           *)                                           *)
32          | TensorRefTy of int list         (* a shared reference to tensor *)
33        | TupleTy of t list               (* tuples; used for multiple return values *)        | TupleTy of t list               (* tuples; used for multiple return values *)
34        | SeqTy of t * int option        | SeqTy of t * int option
35        | ImageTy of ImageInfo.info        | ImageTy of ImageInfo.info
# Line 88  Line 85 
85      fun isPaddedVec (VecTy(wid, hwWid)) = (wid <> hwWid)      fun isPaddedVec (VecTy(wid, hwWid)) = (wid <> hwWid)
86        | isPaddedVec _ = false        | isPaddedVec _ = false
87    
88      (* are two type structurally equal? *)
89      fun same (BoolTy, BoolTy) = true      fun same (BoolTy, BoolTy) = true
90        | same (StringTy, StringTy) = true        | same (StringTy, StringTy) = true
91        | same (IntTy, IntTy) = true        | same (IntTy, IntTy) = true
92        | same (VecTy(wid1, hwWid1), VecTy(wid2, hwWid2)) = (wid1 = wid2) andalso (hwWid1 = hwWid2)        | same (VecTy(wid1, hwWid1), VecTy(wid2, hwWid2)) = (wid1 = wid2) andalso (hwWid1 = hwWid2)
93        | same (TensorTy dd1, TensorTy dd2) = ListPair.allEq (op =) (dd1, dd2)        | same (TensorTy dd1, TensorTy dd2) = ListPair.allEq (op =) (dd1, dd2)
94          | same (TensorRefTy dd1, TensorRefTy dd2) = ListPair.allEq (op =) (dd1, dd2)
95        | same (TupleTy tys1, TupleTy tys2) = ListPair.allEq same (tys1, tys2)        | same (TupleTy tys1, TupleTy tys2) = ListPair.allEq same (tys1, tys2)
96        | same (SeqTy(ty1, NONE), SeqTy(ty2, NONE)) = same(ty1, ty2)        | same (SeqTy(ty1, NONE), SeqTy(ty2, NONE)) = same(ty1, ty2)
97        | same (SeqTy(ty1, SOME n1), SeqTy(ty2, SOME n2)) = (n1 = n2) andalso same(ty1, ty2)        | same (SeqTy(ty1, SOME n1), SeqTy(ty2, SOME n2)) = (n1 = n2) andalso same(ty1, ty2)
# Line 100  Line 99 
99        | same (StrandTy n1, StrandTy n2) = Atom.same(n1, n2)        | same (StrandTy n1, StrandTy n2) = Atom.same(n1, n2)
100        | same _ = false        | same _ = false
101    
102      (* is a source type compatible with the destination type? *)
103        fun match {src = TensorTy dd1, dst = TensorRefTy dd2} = ListPair.allEq (op =) (dd1, dd2)
104          | match {src, dst} = same(src, dst)
105    
106      fun hash BoolTy = 0w1      fun hash BoolTy = 0w1
107        | hash StringTy = 0w2        | hash StringTy = 0w2
108        | hash IntTy = 0w3        | hash IntTy = 0w3
109        | hash (VecTy(wid, hwWid)) = 0w5 * Word.fromInt wid + 0w7 * Word.fromInt hwWid        | hash (VecTy(wid, hwWid)) = 0w5 * Word.fromInt wid + 0w7 * Word.fromInt hwWid
110        | hash (TensorTy dd) = List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) 0w13 dd        | hash (TensorTy dd) = List.foldl (fn (d, s) => 0w11 * Word.fromInt d + s) 0w13 dd
111        | hash (TupleTy tys) = List.foldl (fn (ty, s) => hash ty + s) 0w17 tys        | hash (TensorRefTy dd) = List.foldl (fn (d, s) => 0w13 * Word.fromInt d + s) 0w17 dd
112        | hash (SeqTy(ty, NONE)) = hash ty + 0w19        | hash (TupleTy tys) = List.foldl (fn (ty, s) => hash ty + s) 0w19 tys
113        | hash (SeqTy(ty, SOME n)) = Word.fromInt n * hash ty + 0w23        | hash (SeqTy(ty, NONE)) = hash ty + 0w23
114          | hash (SeqTy(ty, SOME n)) = Word.fromInt n * hash ty + 0w29
115        | hash (ImageTy info) = 0w37 * ImageInfo.hash info + 0w6        | hash (ImageTy info) = 0w37 * ImageInfo.hash info + 0w6
116        | hash (StrandTy n) = Atom.hash n        | hash (StrandTy n) = Atom.hash n
117    
# Line 121  Line 125 
125        | toString (TensorTy dd) = String.concat [        | toString (TensorTy dd) = String.concat [
126              "tensor[", String.concatWithMap "," Int.toString dd, "]"              "tensor[", String.concatWithMap "," Int.toString dd, "]"
127            ]            ]
128          | toString (TensorRefTy dd) = String.concat [
129                "&tensor[", String.concatWithMap "," Int.toString dd, "]"
130              ]
131        | toString (TupleTy tys) = String.concat [        | toString (TupleTy tys) = String.concat [
132              "(", String.concatWithMap " * " toString tys, ")"              "(", String.concatWithMap " * " toString tys, ")"
133            ]            ]

Legend:
Removed from v.3941  
changed lines
  Added in v.3955

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