Commit bfe6d95e by Tianqi Chen Committed by GitHub

[DOC/TOPI] Add API doc for topi (#226)

* [DOC/TOPI] Add API doc for topi

* fix lint
parent 5fec5c5a
......@@ -15,3 +15,4 @@ Python API
function
contrib
dev
topi
TVM Operator Inventory
----------------------
.. automodule:: topi
Index
~~~~~
**List of operators**
.. autosummary::
topi.exp
topi.tanh
topi.log
topi.sqrt
topi.nn.relu
topi.nn.scale_shift
topi.nn.depthwise_conv2d
**List of schedules**
.. autosummary::
topi.cuda.schedule_depthwise_conv2d_map
topi
~~~~
.. autofunction:: topi.exp
.. autofunction:: topi.tanh
.. autofunction:: topi.log
.. autofunction:: topi.sqrt
topi.nn
~~~~~~~
.. autofunction:: topi.nn.relu
.. autofunction:: topi.nn.scale_shift
.. autofunction:: topi.nn.depthwise_conv2d
topi.cuda
~~~~~~~~~
.. automodule:: topi.cuda
.. autofunction:: topi.cuda.schedule_depthwise_conv2d_map
......@@ -23,8 +23,8 @@ from recommonmark.transform import AutoStructify
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
libpath = os.path.join(curr_path, '../python/')
sys.path.insert(0, libpath)
sys.path.insert(0, os.path.join(curr_path, '../python/'))
sys.path.insert(0, os.path.join(curr_path, '../topi/python'))
# -- General configuration ------------------------------------------------
......
# TVM Operator Inventory
topi is the operator collection library for TVM intended at sharing the effort of crafting and
optimizing tvm generated kernels. The goal
optimizing tvm generated kernels. The goal:
- Provide sugars for operator declaration
- Give common primitives for fused op creation.
......
# pylint: disable=redefined-builtin, wildcard-import
"""TVM Operator Inventory."""
"""TVM Operator Inventory.
TOPI is the operator collection library for TVM intended at sharing the effort of crafting and
optimizing tvm generated kernels.
"""
from __future__ import absolute_import as _abs
from .ewise import *
from .math import *
from . import nn
from . import cuda
# pylint: disable=redefined-builtin, wildcard-import
"""CUDA specific declaration and schedule."""
"""CUDA specific declaration and schedules."""
from __future__ import absolute_import as _abs
from .depthwise_conv2d_map import *
from .depthwise_conv2d_map import schedule_depthwise_conv2d_map
......@@ -4,8 +4,9 @@ import tvm
from ..nn.util import get_const_tuple
def schedule_depthwise_conv2d_map(op):
"""Schedule for depthwise_conv2d and auto fusion with
one-to-one-mapping operators, e.g. scale-shift and relu.
"""Schedule for depthwise_conv2d map ops.
This include scale-shift and relu.
Parameters
----------
......
......@@ -85,20 +85,3 @@ def sigmoid(x):
The result.
"""
return tvm.compute(x.shape, lambda *i: tvm.sigmoid(x(*i)))
@tvm.tag_scope(tag="ewise")
def relu(x):
"""Take relu of input x.
Parameters
----------
x : tvm.Tensor
Input argument.
Returns
-------
y : tvm.Tensor
The result.
"""
return tvm.compute(x.shape, lambda *i: tvm.max(x(*i), 0))
......@@ -2,6 +2,6 @@
"""Neural network operators"""
from __future__ import absolute_import as _abs
from .util import *
from .mapping import *
from .ewise import *
from .conv import *
......@@ -7,7 +7,7 @@ from .util import get_const_tuple
@tvm.tag_scope(tag="depthwise_conv2d")
def depthwise_conv2d(Input, Filter, Stride, padding):
"""Depthwise convolution operator, as depthwise_conv2d in tensorflow.
"""Depthwise convolution operator.
Parameters
----------
......
"""Elementwise operators"""
from __future__ import absolute_import as _abs
import tvm
@tvm.tag_scope(tag="ewise")
def relu(x):
"""Take relu of input x.
Parameters
----------
x : tvm.Tensor
Input argument.
Returns
-------
y : tvm.Tensor
The result.
"""
return tvm.compute(x.shape, lambda *i: tvm.max(x(*i), 0))
......@@ -55,7 +55,7 @@ def test_depthwise_conv2d_map():
# Declare
DepthwiseConv2d = topi.nn.depthwise_conv2d(Input, Filter, Stride, padding)
ScaleShift = topi.nn.scale_shift(DepthwiseConv2d, Scale, Shift)
Relu = topi.ewise.relu(ScaleShift)
Relu = topi.nn.relu(ScaleShift)
# Schedule
s1 = schedule_depthwise_conv2d_map(DepthwiseConv2d.op)
s2 = schedule_depthwise_conv2d_map(ScaleShift.op)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment