32 |
(* end case *)) |
(* end case *)) |
33 |
|
|
34 |
fun pruneShape sv = (case TU.pruneShape(MV.toShape sv) |
fun pruneShape sv = (case TU.pruneShape(MV.toShape sv) |
35 |
of Ty.Shape dd => DstTy.TensorTy(List.map pruneDim dd) |
of Ty.Shape dd => DstTy.tensorTy(List.map pruneDim dd) |
36 |
| shp => raise Fail("unresolved shape " ^ TU.shapeToString shp) |
| shp => raise Fail("unresolved shape " ^ TU.shapeToString shp) |
37 |
(* end case *)) |
(* end case *)) |
38 |
|
|
39 |
fun dimVarToTensor dv = DstTy.TensorTy[pruneDim(MV.toDim dv)] |
fun dimVarToTensor dv = DstTy.tensorTy[pruneDim(MV.toDim dv)] |
40 |
fun shapeVarToTensor sv = pruneShape sv |
fun shapeVarToTensor sv = pruneShape sv |
41 |
|
|
42 |
fun assign (y, rator, xs) = [(y, IL.OP(rator, xs))] |
fun assign (y, rator, xs) = [(y, IL.OP(rator, xs))] |
59 |
(BV.sub_ii, simpleOp(Op.Sub DstTy.IntTy)), |
(BV.sub_ii, simpleOp(Op.Sub DstTy.IntTy)), |
60 |
(BV.sub_tt, tensorOp Op.Sub), |
(BV.sub_tt, tensorOp Op.Sub), |
61 |
(BV.mul_ii, simpleOp(Op.Mul DstTy.IntTy)), |
(BV.mul_ii, simpleOp(Op.Mul DstTy.IntTy)), |
62 |
(BV.mul_rr, simpleOp(Op.Mul(DstTy.TensorTy[]))), |
(BV.mul_rr, simpleOp(Op.Mul(DstTy.realTy))), |
63 |
(BV.mul_rt, tensorOp Op.Scale), |
(BV.mul_rt, tensorOp Op.Scale), |
64 |
(BV.mul_tr, fn (y, sv, [t, r]) => tensorOp Op.Scale (y, sv, [r, t])), |
(BV.mul_tr, fn (y, sv, [t, r]) => tensorOp Op.Scale (y, sv, [r, t])), |
65 |
(BV.div_ii, simpleOp(Op.Div DstTy.IntTy)), |
(BV.div_ii, simpleOp(Op.Div DstTy.IntTy)), |
66 |
(BV.div_rr, simpleOp(Op.Div(DstTy.TensorTy[]))), |
(BV.div_rr, simpleOp(Op.Div(DstTy.realTy))), |
67 |
(BV.div_tr, tensorOp Op.InvScale), |
(BV.div_tr, tensorOp Op.InvScale), |
68 |
(BV.lt_ii, simpleOp(Op.LT DstTy.IntTy)), |
(BV.lt_ii, simpleOp(Op.LT DstTy.IntTy)), |
69 |
(BV.lt_rr, simpleOp(Op.LT(DstTy.TensorTy[]))), |
(BV.lt_rr, simpleOp(Op.LT(DstTy.realTy))), |
70 |
(BV.lte_ii, simpleOp(Op.LTE DstTy.IntTy)), |
(BV.lte_ii, simpleOp(Op.LTE DstTy.IntTy)), |
71 |
(BV.lte_rr, simpleOp(Op.LTE(DstTy.TensorTy[]))), |
(BV.lte_rr, simpleOp(Op.LTE(DstTy.realTy))), |
72 |
(BV.gte_ii, simpleOp(Op.GTE DstTy.IntTy)), |
(BV.gte_ii, simpleOp(Op.GTE DstTy.IntTy)), |
73 |
(BV.gte_rr, simpleOp(Op.GTE(DstTy.TensorTy[]))), |
(BV.gte_rr, simpleOp(Op.GTE(DstTy.realTy))), |
74 |
(BV.gt_ii, simpleOp(Op.GT DstTy.IntTy)), |
(BV.gt_ii, simpleOp(Op.GT DstTy.IntTy)), |
75 |
(BV.gt_rr, simpleOp(Op.GT(DstTy.TensorTy[]))), |
(BV.gt_rr, simpleOp(Op.GT(DstTy.realTy))), |
76 |
(BV.equ_bb, simpleOp(Op.EQ DstTy.BoolTy)), |
(BV.equ_bb, simpleOp(Op.EQ DstTy.BoolTy)), |
77 |
(BV.equ_ii, simpleOp(Op.EQ DstTy.IntTy)), |
(BV.equ_ii, simpleOp(Op.EQ DstTy.IntTy)), |
78 |
(BV.equ_ss, simpleOp(Op.EQ DstTy.StringTy)), |
(BV.equ_ss, simpleOp(Op.EQ DstTy.StringTy)), |
79 |
(BV.equ_rr, simpleOp(Op.EQ(DstTy.TensorTy[]))), |
(BV.equ_rr, simpleOp(Op.EQ(DstTy.realTy))), |
80 |
(BV.neq_bb, simpleOp(Op.NEQ DstTy.BoolTy)), |
(BV.neq_bb, simpleOp(Op.NEQ DstTy.BoolTy)), |
81 |
(BV.neq_ii, simpleOp(Op.NEQ DstTy.IntTy)), |
(BV.neq_ii, simpleOp(Op.NEQ DstTy.IntTy)), |
82 |
(BV.neq_ss, simpleOp(Op.NEQ DstTy.StringTy)), |
(BV.neq_ss, simpleOp(Op.NEQ DstTy.StringTy)), |
83 |
(BV.neq_rr, simpleOp(Op.NEQ(DstTy.TensorTy[]))), |
(BV.neq_rr, simpleOp(Op.NEQ(DstTy.realTy))), |
84 |
(BV.neg_i, simpleOp(Op.Neg DstTy.IntTy)), |
(BV.neg_i, simpleOp(Op.Neg DstTy.IntTy)), |
85 |
(BV.neg_t, tensorOp Op.Neg), |
(BV.neg_t, tensorOp Op.Neg), |
86 |
(BV.neg_f, fn (y, _, xs) => assign(y, Op.NegField, xs)), |
(BV.neg_f, fn (y, _, xs) => assign(y, Op.NegField, xs)), |