SCM Repository
Annotation of /trunk/src/IL/types.sml
Parent Directory
|
Revision Log
Revision 7 - (view) (download)
1 : | jhr | 7 | (* types.sml |
2 : | * | ||
3 : | * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) | ||
4 : | * All rights reserved. | ||
5 : | *) | ||
6 : | |||
7 : | structure Types : TYPES = | ||
8 : | sig | ||
9 : | |||
10 : | (* kinds for type variables *) | ||
11 : | datatype kind | ||
12 : | = TK_DIM (* ranges over dimensions (1, 2, ...) *) | ||
13 : | | TK_INT (* ranges over integer types *) | ||
14 : | | TK_FLT (* ranges over floating-point types *) | ||
15 : | | TK_RAW (* ranges over raw (scalar) types *) | ||
16 : | |||
17 : | datatype raw_ty | ||
18 : | = Int8 | UInt8 | ||
19 : | | Int16 | UInt16 | ||
20 : | | Int32 | UInt32 | ||
21 : | | Int64 | UInt64 | ||
22 : | | Float | Double | ||
23 : | |||
24 : | datatype ty | ||
25 : | = T_Var of var | ||
26 : | | T_Bool | ||
27 : | (* scalars, vectors, matrices, etc. *) | ||
28 : | | T_Tensor of {order : dim list, ty : raw_ty} | ||
29 : | (* data sets from NNRD *) | ||
30 : | | T_Data of { | ||
31 : | dim : dim, (* 2D or 3D data set *) | ||
32 : | order : dim list, (* tensor order/dimension info *) | ||
33 : | rep_ty : ty (* representation type of elements (raw kind) *) | ||
34 : | } | ||
35 : | (* continuous field reconstructed from a data set *) | ||
36 : | | T_Field of { | ||
37 : | dim : dim, (* 2D or 3D field *) | ||
38 : | order : dim list, (* tensor order/dimension info *) | ||
39 : | rep_ty : ty, (* representation type of elements (raw kind) *) | ||
40 : | ty : ty (* type of samples (float kind) *) | ||
41 : | } | ||
42 : | |||
43 : | and dim = DIM of word | DIMVAR of var | ||
44 : | |||
45 : | (* type variables *) | ||
46 : | and var = TV of { | ||
47 : | stamp : Stamp.stamp, | ||
48 : | kind : kind | ||
49 : | } | ||
50 : | |||
51 : | (* given a dataset or field type, return the element type, which will be | ||
52 : | * a tensor type. | ||
53 : | *) | ||
54 : | fun elemTypeOf (T_Data{order, rep_ty, ...}) = T_Tensor{order=order, ty=rep_ty} | ||
55 : | | elemTypeOf (T_Field{order, ty, ...}) = T_Tensor{order=order, ty=ty} | ||
56 : | | elemTypeOf _ = raise Fail "not a dataset/field" | ||
57 : | |||
58 : | end |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |