Giter Site home page Giter Site logo

a8e5 / lean-mlir Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opencompl/lean-mlir-old

0.0 0.0 0.0 1.32 MB

embedding MLIR in LEAN

License: Apache License 2.0

Lean 97.83% Makefile 0.39% Shell 0.68% Nix 0.32% Dockerfile 0.14% MLIR 0.29% Haskell 0.34%

lean-mlir's Introduction

mlir-lean: embedded MLIR in LEAN

This provides infrastructure for:

  • An embedding of the MLIR AST in lean (MLIR/AST.lean)
  • A lightweight pretty printer library to pretty print the MLIR AST and parse errors (MLIR/Doc.lean)
  • A embedded-domain-specific language to build MLIR generic operations via macros (MLIR/EDSL.lean)
  • A parser from MLIR generic into LEAN data structures (MLIR/MLIRParser.lean)
  • A lightweight parser combinator library with error tracking (MLIR/P.lean)
def opRgnAttr0 : Op := (mlir_op_call%
 "module"() (
 {
  ^entry:
   "func"() (
    {
     ^bb0(%arg0:i32, %arg1:i32):
      %zero = "std.addi"(%arg0 , %arg1) : (i32, i32) -> i32
      "std.return"(%zero) : (i 32) -> ()
    }){sym_name = "add", type = (i32, i32) -> i32} : () -> ()
   "module_terminator"() : () -> ()
 }) : () -> ()
)
#print opRgnAttr0

As a research project, we explore:

  • How to provide formal semantics for MLIR, especially in the presence of multiple dialects.
  • What default logics are useful, and how best to enable them for MLIR? Hoare logic? Separation logic?
  • Purely functional, immutable rewriter with a carefully chosen set of primitives to enable reasoning and efficient rewriting.

Build instructions

$ lake build
$ ./build/bin/MLIR <path-to-generic-mlir-file.mlir>

Nix

Start a "lean shell" per the Nix Setup documentation for lean:

After installing (any version of) Nix (https://nixos.org/download.html), you can easily open a shell with the particular pre-release version of Nix needed by and tested with our setup (called the "Lean shell" from here on):

$ nix-shell https://github.com/leanprover/lean4/archive/master.tar.gz -A nix

Ensure that these extra options are active in the nix you are running. Under NixOS, this means putting this in top-level config. Under a non OS level isntall, this means putting this in the .nix-profile and restarting the nix daemon.

  nix = {
      package = pkgs.nixUnstable; # or versioned attributes like nix_2_4
      extraOptions = ''
        experimental-features = nix-command flakes
        max-jobs = auto  # Allow building multiple derivations in parallel
        keep-outputs = true  # Do not garbage-collect build time-only dependencies (e.g. clang)
        # Allow fetching build results from the Lean Cachix cache
        trusted-substituters = https://lean4.cachix.org/
        trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= lean4.cachix.org-1:mawtxSxcaiWE24xCXXgh3qnvlTkyU7evRRnGeAhD4Wk=
        allow-import-from-derivation = true
      '';
  };

Test instructions

$ cd examples; lit -v . # run all examples, report failures.

Documentation

Other projects of interest

lean-mlir's People

Contributors

bollu avatar anurudhp avatar itihas 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.