Home My Page Projects Code Snippets Project Openings diderot

SCM Repository

[diderot] Diff of /branches/charisee/src/compiler/basis/basis-vars.sml
 [diderot] / branches / charisee / src / compiler / basis / basis-vars.sml

Diff of /branches/charisee/src/compiler/basis/basis-vars.sml

revision 2925, Tue Mar 3 22:00:11 2015 UTC revision 2926, Tue Mar 3 22:38:29 2015 UTC
# Line 56  Line 56
56     *    r  -- real (tensor[])     *    r  -- real (tensor[])
57     *    t  -- tensor[shape]     *    t  -- tensor[shape]
58     *    f  -- field#k(d)[shape]     *    f  -- field#k(d)[shape]
59       *    s  -- field#k(d)[]
60     *)     *)
61
# Line 156  Line 157
157          in          in
158              [a,b] --> b              [a,b] --> b
159          end))          end))

160      val mul_fs = polyVar(N.op_mul, all([DK,NK,SK],      val mul_fs = polyVar(N.op_mul, all([DK,NK,SK],
161      fn [Ty.DIFF k, Ty.DIM d,Ty.SHAPE dd] => let      fn [Ty.DIFF k, Ty.DIM d,Ty.SHAPE dd] => let
162          val a = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape []}          val a = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape []}
# Line 178  Line 178
178              in              in
179                [t, Ty.realTy] --> t                [t, Ty.realTy] --> t
180              end))              end))
181        val div_ss = polyVar(N.op_mul, all([DK,NK],
182                fn [Ty.DIFF k, Ty.DIM d] => let
183                val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape []}
184                in
185                    [t, t] --> t
186                end))
187      val div_fs = polyVar(N.op_div, all([DK,DK,NK,SK],      val div_fs = polyVar(N.op_div, all([DK,DK,NK,SK],
188          fn [Ty.DIFF k,Ty.DIFF k2, Ty.DIM d, Ty.SHAPE dd] => let          fn [Ty.DIFF k,Ty.DIFF k2, Ty.DIM d, Ty.SHAPE dd] => let
189          val f = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.ShapeVar dd}          val f = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.ShapeVar dd}
# Line 187  Line 192
192              [f,s] --> f              [f,s] --> f
193          end))          end))
194
val div_ss = polyVar(N.op_mul, all([DK,NK],
fn [Ty.DIFF k, Ty.DIM d] => let
val t = Ty.T_Field{diff = Ty.DiffVar(k, 0), dim = Ty.DimVar d, shape = Ty.Shape []}
in
[t, t] --> t
end))

195    (* exponentiation; we distinguish between integer and real exponents to allow x^2 to be compiled    (* exponentiation; we distinguish between integer and real exponents to allow x^2 to be compiled
196     * as x*x.     * as x*x.
197     *)     *)
# Line 425  Line 423
423                  [Ty.T_Tensor(Ty.ShapeVar s1), Ty.T_Tensor(Ty.ShapeVar s2)]                  [Ty.T_Tensor(Ty.ShapeVar s1), Ty.T_Tensor(Ty.ShapeVar s2)]
424                    --> Ty.T_Tensor(Ty.ShapeVar s3)))                    --> Ty.T_Tensor(Ty.ShapeVar s3)))
425
426      val op_inner_ff = polyVar (N.op_dot, all([DK,DK, SK,NK, SK,SK],      val op_inner_tf = polyVar (N.op_dot, all([DK ,NK, SK, SK, SK],
427          fn [Ty.DIFF k,Ty.DIFF k1,Ty.SHAPE dd1, Ty.DIM d, Ty.SHAPE dd2,Ty.SHAPE dd3] => let            fn [Ty.DIFF k, Ty.DIM d, Ty.SHAPE dd1, Ty.SHAPE dd2, Ty.SHAPE dd3] => let
428              val k0=Ty.DiffVar(k, 0)                val k = Ty.DiffVar(k, 0)
429              val k1=Ty.DiffVar(k1, 0)                val d = Ty.DimVar d
430              val d' = Ty.DimVar d                val t1 = Ty.T_Tensor(Ty.ShapeVar dd1)
431              val t1 = Ty.T_Field{diff = k0, dim = d', shape = Ty.ShapeVar dd1}                val t2 = Ty.T_Field{diff = k, dim = d, shape = Ty.ShapeVar dd2}
432              val t2 = Ty.T_Field{diff = k1, dim = d', shape = Ty.ShapeVar dd2}                val t3 = Ty.T_Field{diff = k, dim = d, shape = Ty.ShapeVar dd3}
val t3 = Ty.T_Field{diff = k0, dim = d', shape = Ty.ShapeVar dd3}
433              in              in

434                  [t1,t2] --> t3                  [t1,t2] --> t3
435              end))              end))
436
437      val op_inner_ft = polyVar (N.op_dot, all([DK,NK,SK,SK, SK],      val op_inner_ft = polyVar (N.op_dot, all([DK,NK,SK,SK, SK],
438          fn [Ty.DIFF k0,Ty.DIM d1,Ty.SHAPE dd1, Ty.SHAPE dd2,Ty.SHAPE dd3] => let            fn [Ty.DIFF k, Ty.DIM d, Ty.SHAPE dd1, Ty.SHAPE dd2, Ty.SHAPE dd3] => let
439              val k0=Ty.DiffVar(k0, 0)                val k = Ty.DiffVar(k, 0)
440              val d' = Ty.DimVar d1                val d = Ty.DimVar d
441              val t1 = Ty.T_Field{diff = k0, dim = d', shape = Ty.ShapeVar dd1}                val t1 = Ty.T_Field{diff = k, dim = d, shape = Ty.ShapeVar dd1}
442              val t2 = Ty.T_Tensor(Ty.ShapeVar dd2)              val t2 = Ty.T_Tensor(Ty.ShapeVar dd2)
443              val t3 = Ty.T_Field{diff = k0, dim = d', shape = Ty.ShapeVar dd3}                val t3 = Ty.T_Field{diff = k, dim = d, shape = Ty.ShapeVar dd3}

444              in              in
445                  [t1,t2] --> t3                  [t1,t2] --> t3
446              end))              end))
447
448        val op_inner_ff = polyVar (N.op_dot, all([DK, NK, SK, SK, SK],
449              fn [Ty.DIFF k, Ty.DIM d, Ty.SHAPE dd1, Ty.SHAPE dd2, Ty.SHAPE dd3] => let
450                  val k = Ty.DiffVar(k, 0)
451                  val d = Ty.DimVar d
452                  val t1 = Ty.T_Field{diff = k, dim = d, shape = Ty.ShapeVar dd1}
453                  val t2 = Ty.T_Field{diff = k, dim = d, shape = Ty.ShapeVar dd2}
454                  val t3 = Ty.T_Field{diff = k, dim = d, shape = Ty.ShapeVar dd3}
455                  in
456                    [t1, t2] --> t3
457                  end))
458
459    (* the colon (or double-dot) product operator is treated as a special case in the    (* the colon (or double-dot) product operator is treated as a special case in the
460     * typechecker.  It is not included in the basis environment, but we define its type     * typechecker.  It is not included in the basis environment, but we define its type

Legend:
 Removed from v.2925 changed lines Added in v.2926