Git Product home page Git Product logo

cs3423-compilers-nabla's Introduction

Nabla

Lexer Build Status Parser Build Status Semantic Build Status

Nabla Image

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.

Table of Contents

Example

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

Computational graph

Installation

Requirements

Steps

  1. Clone the repository
git clone https://github.com/IITH-COMPILERS2/compilers-2-project-team-9-aug22.git
  1. Run the makefile
cd compilers-2-project-team-9-aug22
make
  1. Run the tests (optional)
make test

Documentation

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

Stages

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.

Class Hierarchy


Class Hierarchy

To see the class Hierarchy please switch to the branch AST and see files ast.h and ast.cpp

Testing


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

Acknowledgements


cs3423-compilers-nabla's People

Contributors

tanmaygar avatar ganesh-rb avatar kartiksrinivas007 avatar aayush2492 avatar ketan3007 avatar gauthambellamkonda avatar tyagio avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.