Nabla is a Domain specific langauge built for the purpose of Tensor Operations and Automatic differentiation
It uses dynamically built computational graphs for back-propagation.
declare
{
var Tensor a[2][1] = [[1],[2]];
var Tensor b[1][2] = [[1,2]];
var Tensor c[1][2] = [[1,2]];
var Tensor d[1][2] = [[5,6]];
var Tensor e[1][2] = [[53,64]];
var Tensor g[1][2] = [[53,64]];
var Tensor fin[1][1];
}
operations
{
fin = sin(e+cos(2*b))*exp(d)@a;
}
gradient
{
backward(fin);
print(a);
print(b);
print(d);
print(e);
grad(a);
grad(b);
grad(d);
grad(e);
}
The code will be converted into a computational graph(internally) of the form:- After this we will be able to use the chain rule to calculate the gradients of the Final variable in terms of the beginning variables
- Clone the repository
git clone https://github.com/IITH-COMPILERS2/compilers-2-project-team-9-aug22.git
- Run the makefile
cd compilers-2-project-team-9-aug22
make
- Run the tests (optional)
make test
To generate the documentation for the project, run the following command in the root directory of the project
doxygen
The documentation for the project can be found here
The lexer is the first stage of the compiler. It takes the input file and converts it into a stream of tokens. The tokens are then passed to the parser.
The parser is the second stage of the compiler. It takes the stream of tokens from the lexer and converts it into an Abstract Syntax Tree (AST). The AST is then passed to the semantic analyzer.
The semantic analyzer is the third stage of the compiler. It takes the AST from the parser and performs semantic analysis on it. The AST is then passed to the code generator.
The transpiler is the fourth stage of the compiler. It takes the AST from the semantic analyzer and converts it into a C++ file. The C++ file is then compiled and executed.
To see the class Hierarchy please switch to the branch AST
and see files ast.h
and ast.cpp
Go inside the lexer folder and run these commands to test lexer
make
make test
Go inside the Parser folder and run these commands to test Parser
make
make test
Go inside the Semantic folder and run these commands to test semantic analysis
make
make test
- Dr Ramakrishna Upadrasta for his guidance and support