Skip to content

Commit

Permalink
Deprecation of Triton-C and Replacement by decorated Python functions (
Browse files Browse the repository at this point in the history
…triton-lang#86)

This PR implements a major overhaul of the frontend for Triton, and replaces Triton-C by a pure Python API in which kernels are defined as @triton.jit decorated functions. The documentation and tutorials have also been updated to accommodate these changes.

See documentations for more information on the new API
  • Loading branch information
ptillet committed Jul 27, 2021
1 parent 1fdb465 commit 39f4730
Show file tree
Hide file tree
Showing 91 changed files with 4,492 additions and 13,000 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif()

# Compiler flags
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS -fvisibility=default -std=gnu++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_FORMAT_MACROS -fvisibility=default -std=gnu++17")



Expand Down
7 changes: 7 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
# Math Jax
extensions += ['sphinx.ext.mathjax']

# Auto Doc
import sys
import os
sys.path.insert(0, os.path.abspath('../python/'))
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'sphinx.ext.coverage', 'sphinx.ext.napoleon']
autosummary_generate = True

# Sphinx gallery
extensions += ['sphinx_gallery.gen_gallery']
from sphinx_gallery.sorting import FileNameSortKey
Expand Down
22 changes: 16 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,32 @@ Getting Started
getting-started/installation
getting-started/tutorials/index

Programming Guide
Language Reference
-------------------

- Checkout the :doc:`Python API Documentation <language-reference/python-api/index>`


.. toctree::
:maxdepth: 1
:caption: Language Reference
:hidden:

language-reference/python-api/index


Going Further
------------------

Check out the following documents to learn more about Triton and how it compares against other DSLs for DNNs:

- Chapter 1: :doc:`Introduction <programming-guide/chapter-1/introduction>`
- Chapter 2: :doc:`Related Work <programming-guide/chapter-2/related-work>`
- Chapter 3: :doc:`The Triton-C Language <programming-guide/chapter-3/triton-c>`
- Chapter 4: :doc:`The Triton-IR Intermediate Representation <programming-guide/chapter-4/triton-ir>`

.. toctree::
:maxdepth: 1
:caption: Programming Guide
:hidden:

programming-guide/chapter-1/introduction
programming-guide/chapter-2/related-work
programming-guide/chapter-3/triton-c
programming-guide/chapter-4/triton-ir
programming-guide/chapter-2/related-work
117 changes: 117 additions & 0 deletions docs/language-reference/python-api/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
Python API
===========

.. currentmodule:: triton


Programming Model
-------------------

.. autosummary::
:toctree: generated
:nosignatures:

program_id
num_programs


Creation Ops
-------------

.. autosummary::
:toctree: generated
:nosignatures:

arange
zeros


Shape Manipulation Ops
-----------------------

.. autosummary::
:toctree: generated
:nosignatures:

broadcast_to
reshape
ravel



Linear Algebra Ops
-------------------

.. autosummary::
:toctree: generated
:nosignatures:

dot

Memory Ops
--------------------

.. autosummary::
:toctree: generated
:nosignatures:

load
store
atomic_cas
atomic_xchg


Indexing Ops
--------------

.. autosummary::
:toctree: generated
:nosignatures:

where


Math Ops
----------

.. autosummary::
:toctree: generated
:nosignatures:

exp
log
sigmoid
softmax


Reduction Ops
---------------

.. autosummary::
:toctree: generated
:nosignatures:

max
min
sum


Comparison ops
---------------

.. autosummary::
:toctree: generated
:nosignatures:

minimum
maximum


Compiler Hint Ops
-------------------

.. autosummary::
:toctree: generated
:nosignatures:

multiple_of
84 changes: 0 additions & 84 deletions docs/programming-guide/chapter-3/triton-c.rst

This file was deleted.

Binary file removed docs/programming-guide/chapter-4/broadcast-1.png
Binary file not shown.
Binary file removed docs/programming-guide/chapter-4/broadcast-2.png
Binary file not shown.
82 changes: 0 additions & 82 deletions docs/programming-guide/chapter-4/triton-ir.rst

This file was deleted.

29 changes: 15 additions & 14 deletions include/triton/codegen/pass.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
#ifndef _TRITON_CODEGEN_PASS_H_
#define _TRITON_CODEGEN_PASS_H_

#include <list>

#include <memory>

namespace triton{

namespace ir{
class module;
}
namespace driver{
class device;
class module;
class kernel;
}
}

namespace triton{
namespace codegen{

class pass {
public:
virtual void run(ir::module& m);
};

// TODO:
// There should be a proper pass manager there!
void add_passes_to_emit_bin(ir::module &ir, driver::device* dev, int num_warps,
driver::module*& mod, driver::kernel*& ker, size_t& shared_mem);

class pass_manager {
public:
void add(pass* p);
void run(ir::module& m);

private:
std::list<pass*> passes;
};

}
}

#endif
Loading

0 comments on commit 39f4730

Please sign in to comment.