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

SCM Repository

[diderot] View of /branches/vis15/src/compiler/ein/ein.sml
ViewVC logotype

View of /branches/vis15/src/compiler/ein/ein.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3978 - (download) (annotate)
Wed Jun 15 19:07:40 2016 UTC (3 years, 7 months ago) by cchiw
File size: 2403 byte(s)
changed ein expressions, rewrote matchEps, added translation
(* ein.sml
 *
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 *)

structure Ein =
  struct

    datatype param_kind
      = TEN of bool * int list	(* the boolean specifies if the parameter is substitutable *)
      | FLD of int
      | KRN
      | IMG of int * int list

    (* placement in argument list *)
    type param_id= int
    (* variable index *)
    type index_id = int
    (* binding of variable index *)
    type index_bind = int

    datatype ein = EIN of {
	params : param_kind list,
	(* Parameters to equation are either tensors or fields *)
	(* These variables are named using de Bruijn indexing *)
(* QUESTION: why is this index_bind list and not index_id list?
* Answer: index_bind is the range of the index_ids.
* Both ints but ultimately different types
*)
	index : index_bind list,	(* Index variables in the equation. *)
	body : ein_exp
      }

    and mu
      = V of index_id
      | C of int

    and unary
      = Neg
      | Exp
      | Sqrt
      | Cosine
      | ArcCosine
      | Sine
      | ArcSine
      | Tangent
      | ArcTangent
(* QUESTION: should the int be IntInf.int? *)
      | PowInt of int

    and binary = Sub | Div

    and opn = Add | Prod

(* FIXME: we should reuse the BorderCtl.ctl type, but that will require moving the file into common *)
    and border = Default | Clamp | Mirror | Wrap | None

    and ein_exp
    (* Basic terms *)
      = Const of int
(* QUESTION: should this be RealLit.t? *)
      | ConstR of Rational.t
      | Tensor of param_id * alpha
      | Delta of index_id * index_id
      | Epsilon of index_id * index_id * index_id
      | Eps2 of index_id * index_id
    (* High-IL Terms *)
      | Field of param_id * alpha
      | Lift of ein_exp
      | Conv of param_id * alpha * param_id * alpha
      | Partial of alpha
      | Apply of ein_exp * ein_exp
      | Probe of ein_exp * ein_exp
    (* Mid-IL Terms *)
      | Value of index_id (* Lift index *)
      | Img of param_id * alpha * pos list * int * border
      | Krn of param_id * (mu * mu) list * int
    (* Ops *)
      | Sum of sumrange list * ein_exp
      | Op1 of unary * ein_exp
      | Op2 of binary * ein_exp * ein_exp
      | Opn of opn * ein_exp list

    withtype alpha = mu list
	and pos = ein_exp
	and sumrange = index_id * int * int

  end

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