• Stars
    star
    205
  • Rank 191,264 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created about 8 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Symbolic Expression and Statement Module for new DSLs

HalideIR: Symbolic Arithmetic IR Module

HalideIR is a base module for building symbolic expression and arithmetic simplification for building new DSLs. It is isolated and refactored from part of Halide project (credit should go to the original authors). It was used in earlier versions of the tvm project.

Note that some portions of the TVM compiler outside of this folder are also adapted from Halide codebase, where we needed similar logic (e.g loop vectorization). These are commented where they occur.

Motivation

We build this component during the development of TVM project. Symbolic expression data structure and simplification libary is essential to for such compiler stack project.

Unfortunately there is no standalone module that fits our need at the moment. We find that the IR and simplification module of Halide project fits such purposes nicely. So we isolated and refactor the coresponding module into this repo.

The major goal is minimum and interpolatable with more front-end languages. HalideIR is used in TVM project. Here are the few major improvements.

  • An isolated dependency free symbolic IR and simplification (no LLVM dependency).
  • The project modularized into logical components.
  • All IR structure are serializable and publically accessible from front-end language(e.g. python)
    • This supports ease of development and proptyping in python
  • Think of re-usablity when adding new DSL structure.
    • A runtime dispatching mechanism is introduced to allow ease of add new IR node.
  • Simplified variable defintiion rule: change from match by string to match by pointer
    • This ensures each variable to have single define location (like SSA)

Besides these changes, we also re-factored the code to resolve some of the issues in the codebase. Some of these changes addresses the pain point raised in Halide project. The detailed change are listed in the later part of the project.

Project Structure

Based on code from Halide(release_2017_05_03). The code is componetized into four logical components

  • tvm: TVM container code for interpolation, basic data structures.
  • base: base utilities and type.
  • ir: The IR data structure
  • arithmetic: Arithemetic simplification.

Code Style

We keep old files in old code style, but use Google C style in the newly added files.

List of Changes

  • Replace implmentation of Float16.cpp with a simpler version that does not depend on LLVM
  • IntrusivePtr
    • Remove IntrusivePtr, change everything to base on std::shared_ptr
    • See tvm/node.h
    • Add support for IR reflection via NodeRef.VisitAttrs
    • All the IR is constructable from python via TVM
      • This enables quick proptyping and debuging from python
  • Call
    • Remove Parameter, BufferPtr from Variable, Call, Load
    • This simplifies dependency, we also find it is cleaner to simply use Variable for Parameter.
  • AssertStmt
    • Add body field to AssertStmt, which represents the scope where the assert condition holds
    • This makes it easier to do Visitor pattern that take benefit of the scope assert information.
  • AttrStmt
    • This is a new Stmt that can be used to annotate attribute of certain things (e.g. content type of buffer). This removes the need of string matching for properties and hacks around string matching in Let.
    • We use this extensively to add new hints in the environment scope.
  • FunctionContent
    • Make FunctionBaseNode abstract, to replace FunctionContent
  • Provide, Realize, Prefetch, ProducerConsumer, Call
    • Remove use of string name matching of function
    • When place where function is needed, use FunctionRef
    • FunctionRef is uniqued matched by internal pointer.
  • Variable, Store, Allocate, Free, For, Load, Let, LetStmt
    • Remove use of string name matching of Variable
    • When place where variable is needed, use VarExpr
    • VarExpr is uniqued matched by internal pointer.
  • Variable
    • Rename Variable.name -> Variable.name_hint, to avoid confusion.
    • Variable.name_hint is not used to uniquely identify the variable.
    • By default, each Variable should be only defined once
      • This is in analog to SSA, and can make ir pass simplier(remove need of scoping)
  • Provide, Realize, Prefetch
    • Change Provide and Realize to associate with value_index.
    • Original Provide/Realize with multiple values can be represented by several Provide and Realize chained together
    • This allows outputs of a Function to have different shapes.
  • Make every field the IR reflectable and accessible from python
    • std::vector<> - > Array<>(tvm/container.h)
    • struct Range -> Range(Range.h)
  • Range
    • Remove constructor Range(min, extent) to Range::make_with_min_extent(min, extent)
    • The original constructor could make new user confuse since a typical way is range(begin, end) in both c++ and python
  • Simplify Visitor
    • Remove use of string name mapping in the Scope
    • Remove Scope in Substitute to check name conflicts because we use variable pointer matching
    • Add Expr&/Stmt& to visit interface in the IRVisitor and IRMutator
  • Add a more flexible RTTI and dynamic dispatch support, see src/tvm/node.h
    • IRFunctor allows plugin of new IR Node more easily, without chaning interface

More Repositories

1

xgboost

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
C++
26,028
star
2

dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
Python
13,511
star
3

gluon-cv

Gluon CV Toolkit
Python
5,821
star
4

gluon-nlp

NLP made easy
Python
2,553
star
5

decord

An efficient video loader for deep learning with smart shuffling that's super easy to digest
C++
1,772
star
6

nnvm

C++
1,657
star
7

ps-lite

A lightweight parameter server interface
C++
1,525
star
8

minpy

NumPy interface with mixed backend execution
Python
1,109
star
9

mshadow

Matrix Shadow:Lightweight CPU/GPU Matrix and Tensor Template Library in C++/CUDA for (Deep) Machine Learning
C++
1,106
star
10

cxxnet

move forward to https://github.com/dmlc/mxnet
C++
1,025
star
11

dlpack

common in-memory tensor structure
Python
885
star
12

dmlc-core

A common bricks library for building scalable and portable distributed machine learning.
C++
862
star
13

treelite

Universal model exchange and serialization format for decision tree forests
C++
729
star
14

minerva

Minerva: a fast and flexible tool for deep learning on multi-GPU. It provides ndarray programming interface, just like Numpy. Python bindings and C++ bindings are both available. The resulting code can be run on CPU or GPU. Multi-GPU support is very easy.
C++
698
star
15

parameter_server

moved to https://github.com/dmlc/ps-lite
C++
648
star
16

mxnet-notebooks

Notebooks for MXNet
Jupyter Notebook
615
star
17

rabit

Reliable Allreduce and Broadcast Interface for distributed machine learning
C++
505
star
18

mxnet.js

MXNetJS: Javascript Package for Deep Learning in Browser (without server)
JavaScript
435
star
19

MXNet.jl

MXNet Julia Package - flexible and efficient deep learning in Julia
371
star
20

tensorboard

Standalone TensorBoard for visualizing in deep learning
Python
369
star
21

wormhole

Deprecated
C++
338
star
22

mxnet-memonger

Sublinear memory optimization for deep learning, reduce GPU memory cost to train deeper nets
Python
308
star
23

difacto

Distributed Factorization Machines
C++
296
star
24

XGBoost.jl

XGBoost Julia Package
Julia
288
star
25

mxnet-model-gallery

Pre-trained Models of DMLC Project
266
star
26

GNNLens2

Visualization tool for Graph Neural Networks
TypeScript
232
star
27

mxnet-gtc-tutorial

MXNet Tutorial for NVidia GTC 2016.
Jupyter Notebook
131
star
28

experimental-lda

C++
127
star
29

MXNet.cpp

C++ interface for mxnet
C++
114
star
30

experimental-mf

cache-friendly multithread matrix factorization
C++
87
star
31

web-data

The repo to host all the web data including images for documents in dmlc projects.
Jupyter Notebook
83
star
32

nnvm-fusion

Kernel Fusion and Runtime Compilation Based on NNVM
C++
70
star
33

dmlc.github.io

HTML
27
star
34

tl2cgen

TL2cgen (TreeLite 2 C GENerator) is a model compiler for decision tree models
C++
21
star
35

cub

Cuda
19
star
36

mxnet-deepmark

Benchmark speed and other issues internally, before push to deep-mark
Python
7
star
37

mxnet-examples

MXNet Example
6
star
38

xgboost-bench

Python
4
star
39

drat

Drat Repository for DMLC R packages
4
star
40

nn-examples

1
star
41

gluon-nlp-notebooks

1
star
42

docs-redirect-for-mxnet

redirect mxnet.readthedocs.io to mxnet.io
Python
1
star