Alternative Computing Technologies (ACT) Lab

School of Computer Science

Georgia Institute of Technology

Tabla is an accelerator generator framework for geometric machine learning algorithms. It is an open source project under the Apache license.


TABLA Language Specifications


TABLA provides a Domain Specific Language, specifically designed to make the implementaion of geometric machine learning algorithms easier.


Language Rules

Grammar

  • Every statement ends with a semicolon(;).
  • There are five data types supported in TABLA:
    • model_input
    • model_output
    • model
    • gradient
    • iterator
  • Variables of these data types must be declared. Multiple variables of the same data type can be decalred in the same line, even if they have different dimensions. For example, the following is legal:
        model_input i[x], j[y][z];
    On the other hand, if a declared variable does not have a data type declared with it, it does not have to be declared. For example,
        m = 10;
    This is a valid statement, even though the variable m does not have a data type associated with it explicitly. The following code snippet is legal:
        m = 15; model_input x[m];
    However, the following is not legal, since n is not declared:
        model_output y[n];
  • Iterator data type has a special syntax associated with its variables. A variable name is immediately followed by a left bracket, a starting point and an end point, delimited by a colon, and a right bracket. In other words,
    (data type) (variable name)(left bracket)(digit or an integer variable)(colon)(digit or an integer variable)(right bracket)
    Using a token notation,
    ITERATOR ID LEFT_BRACK (ID | INTLIT) COLON (ID | INTLIT) RIGHT_BRACK SEMI
    This is because iterator data type serves the same functionality as a for loop. The range of values to be looped is expressed inside the brackets. These are integer values incrementing by 1. Either raw values or variables containing an integer value (or both) can be used for this.
    Here are examples of valid iterator declartion:
        iterator i[0:10]; // all iterator arguments as integer literals
        iterator j[m:n]; // all iterator arguments as integer variables (that should havebeen decalred before this statment)
        iterator k[m:10]; // one iterator argument as an integer variable, the other as an integer literal
        iterator l[0:n]; // same as before, but the other way around
    The following is illegal, since it does not give the range of values to be looped:
        iterator x;
  • '->' notation is used to associate each gradient variable with corresponding model variable.
  • Click here for the EBNF form of the grammar.

Lexical Rules

Variable names follow the similar rules as the ones in C. The properties are:

  • Variable names start with either an upper case letter or an upper case letter, followed by an arbitrary length of alphanumeric characters including underscore (_), and it can end with a single quote (').
  • Variables can be of any dimension. For example, the following are all legal:
    a b[m] c[x][y] d[i][j][k]

Operator Precedence

The basic operators follow the following precedence from highest to lowest:

  1. (), []
  2. *
  3. +,-
  4. <,>
  5. =

Functions

Aside from the basic operators, there are two types of operations: group and non linear. In group operations, pi and sum operates on two arguments, whereas norm operates on one argument. However, even though pi and sum operates on two arguments, this is only in a semantic manner. Syntatically, it appears they take in one. In other words, in between the parentheses, pi and sum operators do not require an argument followed by a comma and then another argument, as one would normally expect from other languages. For example, if one would write a sum function in C, it would look like:
    sum(2, 3);
However, in TABLA, it would look something like this:
    sum[i](x[i] * w[j][i]);
where i and j are iterators. Notice there is no comma (,) inside the parentheses.
Also, since pi and sum are operated group-wise, they require an iterator. This is wrapped inside square brackets, as shown above in the sum operator. Syntatically, sum and pi operators come in the following format:
    (SUM | PI) LEFT_BRACK ID RIGHT_BRACK LEFT_PAREN expr RIGHT_PAREN SEMI
whereas the rest of the operators are expressed in the following format:
    (NORM | GAUSSIAN | SIGMOID | SIG_SYM | LOG) LEFT_PAREN expr RIGHT_PAREN SEMI


TABLA Language EBNF


    <program> ::= <data_decl_list> <stat_list> EOF

    <data_decl_list> ::= <data_decl> <data_decl_list>
    |   ""

    <data_decl> ::= <data_type> ";"

    <data_type> ::= <non_iterator> <var_list>
    |	"gradient" <var_with_link_list>
    |	<iterator> <var_list_iterator>
    |	<id> "=" <intlit>

    <non_iterator> ::= "model_input"
    |   "model_output"
    |   "model"

    <iterator> ::= "iterator"

    <id> ::= (<lower> | <upper>) , {(<lower> | <upper> | <digit> | "-")} , <prime>

    <prime> ::= "'" | ""

    <lower> ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k' | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z"

    <upper> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"

    <digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

    <intlit> ::= "0" | <digit> - "0" , {<digit>}

    <var_with_link_list> ::= <var> "->" <var_with_link_list_tail>

    <var_with_link_list_tail> ::= "," <var_with_link_list> <var_with_link_list_tail>
    | ""

    <var_list> ::= <var> <var_list_tail>

    <var> ::= <var_id>

    <var_id> ::= <id> <id_tail>

    <id_tail> ::= "[" (<id> | <intlit>) "]" <id_tail>
    | ""

    <var_list_tail> ::= "," <var_list>
    | ""

    <var_list_iterator> ::= <id> "[" (<id> | <intlit>) COLON (<id> | <intlit>) "]"

    <stat_list> ::= <stat> <stat_list>
    | ""

    <stat> ::= <var> "=" <expr> ";"

    <expr> ::= <term2> <term2_tail>

    <function> ::= "pi"
    |   "sum"
    |   "norm"
    |   "gaussian"
    |   "sigmoid"
    |   "sig_sym"
    |   "log"

    <function_args> ::= "[" <id> "]" "(" <expr> ")"
    |   "(" <expr> ")"

    <term2_tail> ::= <compare_op> <term2> <term2_tail>
    |

    <term2> ::= <term1> <term1_tail>

    <term1_tail> ::= <add_op> <term1> <term1_tail>
    |

    <term1> ::= <term0> <term0_tail>

    <term0_tail> ::= <mul_op> <term0> <term0_tail>
    |

    <term0> ::= <var>
    |   "(" <expr> ")"
    |   <intlit>
    |   <function> <function_args>

    <mul_op> ::= "*"

    <add_op> ::= "+"
    |   "-"

    <compare_op> ::= "<"
    |	 ">"
  

License

This source code is published under the terms specified in the Apache license.

Copyright 2016 Hadi Esmaeilzadeh

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Patrons