RepositoryC++
roastduck

roastduck/FreeTensor

A language and compiler for irregular tensor programs.

153stars
12forks
4issues
4views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: jit

#1 Repository of the month

1
TINIX TRENDING·Topic: tensor

#1 Repository of the month

1
TINIX TRENDING·Topic: openmp

#1 Repository of the month

logo

Get Started | Contributing | Publication | License

Write and optimize high-performance native loop-based tensor programs in Python.

Features

  • Compiling loop-based tensor programs in Python to native code
  • Dynamic tensor shapes supported
  • Accept explicit transformations to programs for optimization, including parallelization, loop transformations and memory optimizations
  • Parallelization with OpenMP or CUDA
  • Reverse-mode Automatic Differentiation

Features by Example

Code Structure

ffi/ ------------------------------------------------------- Interface between C++ and Python
grammar/ --------------------------------------------------- ANTLR grammar files used for serialization
include/ --------------------------------------------------- C++ headers
|- ref.h --------------------------------------------------- A smart pointer, based on std::shared_ptr, used all around the code
|- ast.h --------------------------------------------------- Base class for AST (IR of FreeTensor) nodes
|- stmt.h -------------------------------------------------- Statement nodes of an AST
|- expr.h -------------------------------------------------- Expression nodes of an AST
|- visitor.h ----------------------------------------------- Inherit Visitor in this file to examine an AST
|- mutator.h ----------------------------------------------- Inherit Mutator in this file to modify an AST
|- schedule.h ---------------------------------------------- All user specified transformations (schedules). Main interface. Details are in schedule/
|- frontend/ ----------------------------------------------- C++ utilities used in Python API
|- math/ --------------------------------------------------- Math utilities
|- schedule/ ----------------------------------------------- All user specified transformations (schedules)
|- pass/ --------------------------------------------------- All user agnostic transformations (used inside or after schedules)
|- analyze/ ------------------------------------------------ Passes to extract information from an AST
|- codegen/ ------------------------------------------------ Passes to generate a target code from an AST
`- driver/ ------------------------------------------------- Infrastructure to run a generated target code
src/ ------------------------------------------------------- C++ sources (the structure is almost same with include/)
python/ ---------------------------------------------------- Python API
runtime/ --------------------------------------------------- (Minimal) runtime code to be compiled into target exexutables
test/ ------------------------------------------------------ Unit tests

Acknowledgement

Many designs in FreeTensor are inspired by TVM. Thank the TVM community for their contributions on tensor program compiling.

Similar Projects

Discover other similar projects and AI models.

RepositoryCuda
flashinfer-ai/flashinfer

FlashInfer: Kernel Library for LLM Serving

7.0k
Dec 1, 2026
RepositoryPython
pytorch/pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration

105.8k
Dec 1, 2026
RepositoryC++
NVIDIA/cutlass

CUDA Templates and Python DSLs for High-Performance Linear Algebra

10.8k
Nov 30, 2026
RepositoryC++
NVIDIA/cudf

cuDF - GPU DataFrame Library

9.8k
Dec 1, 2026
RepositoryC++
NVIDIA/nccl

Optimized primitives for collective multi-GPU communication

5.3k
Dec 1, 2026
RepositoryC++
OpenNMT/CTranslate2

Fast inference engine for Transformer models

4.8k
Nov 28, 2026
RepositoryC++
asmjit/asmjit

Low-latency machine code generation

4.6k
Nov 25, 2026
RepositoryTypeScript
bendlang/bend

Bend 2: a fast language that blocks AI mistakes via proof. Install: curl -fsSL https://bend-lang.com/install.sh | sh

26.1k
Dec 2, 2026
RepositoryPython
apache/tvm

Open Machine Learning Compiler Framework

13.9k
Nov 24, 2026