22 |
|
|
23 |
type var_env = DstIL.var VTbl.hash_table |
type var_env = DstIL.var VTbl.hash_table |
24 |
|
|
25 |
|
fun cvtTy SrcTy.BoolTy = DstTy.BoolTy |
26 |
|
| cvtTy SrcTy.StringTy = DstTy.StringTy |
27 |
|
| cvtTy SrcTy.IntTy = DstTy.intTy |
28 |
|
| cvtTy (SrcTy.TensorTy[]) = DstTy.realTy |
29 |
|
| cvtTy (SrcTy.TensorTy[d]) = DstTy.VecTy d |
30 |
|
| cvtTy _ = raise Fail "unexpected higher-order tensor type" |
31 |
|
|
32 |
fun rename (env : var_env, x) = (case VTbl.find env x |
fun rename (env : var_env, x) = (case VTbl.find env x |
33 |
of SOME x' => x' |
of SOME x' => x' |
34 |
| NONE => let |
| NONE => let |
35 |
val x' = DstIL.Var.new (SrcIL.Var.name x) |
val x' = DstIL.Var.new (SrcIL.Var.name x, cvtTy(SrcIL.Var.ty x)) |
36 |
in |
in |
37 |
VTbl.insert env (x, x'); |
VTbl.insert env (x, x'); |
38 |
x' |
x' |
48 |
| _ => raise Fail "bogus field binding" |
| _ => raise Fail "bogus field binding" |
49 |
(* end case *)) |
(* end case *)) |
50 |
fun expand (FieldDef.CONV(_, img, _)) = let |
fun expand (FieldDef.CONV(_, img, _)) = let |
51 |
val imgPos = DstIL.Var.new "x" |
val imgPos = DstIL.Var.new ("x", DstTy.VecTy(ImageInfo.dim img)) |
52 |
in [ |
in [ |
53 |
(imgPos, DstIL.OP(DstOp.Transform img, [pos])), |
(imgPos, DstIL.OP(DstOp.Transform img, [pos])), |
54 |
(result, DstIL.OP(DstOp.Inside img, [imgPos])) |
(result, DstIL.OP(DstOp.Inside img, [imgPos])) |
69 |
Probe.expand (result, fld, pos) |
Probe.expand (result, fld, pos) |
70 |
end |
end |
71 |
|
|
|
fun cvtTy SrcTy.BoolTy = DstTy.BoolTy |
|
|
| cvtTy SrcTy.StringTy = DstTy.StringTy |
|
|
| cvtTy SrcTy.IntTy = DstTy.intTy |
|
|
| cvtTy (SrcTy.TensorTy[]) = DstTy.realTy |
|
|
| cvtTy (SrcTy.TensorTy[d]) = DstTy.VecTy d |
|
|
| cvtTy _ = raise Fail "unexpected higher-order tensor type" |
|
|
|
|
72 |
fun arity (SrcTy.TensorTy[]) = 1 |
fun arity (SrcTy.TensorTy[]) = 1 |
73 |
| arity (SrcTy.TensorTy[d]) = d |
| arity (SrcTy.TensorTy[d]) = d |
74 |
| arity _ = raise Fail "arity" |
| arity _ = raise Fail "arity" |