Skip to content

Commit

Permalink
remove annotation helper
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiics committed Jan 14, 2020
1 parent 8cd31b7 commit 703ab73
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 449 deletions.
16 changes: 0 additions & 16 deletions include/tvm/relay/op_attr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,6 @@ using FTVMLegalize = runtime::TypedPackedFunc<
const Array<Expr>& args,
const Array<tvm::relay::Type>& arg_types)>;

/*!
* \brief Annotates an expression to indicate which compiler an op
* should be used for codegen.
*
* \param attrs The attribute of the original expr.
* \param args The arguments of the original expr.
* \param compiler The compiler that is used to compile the op.
*
* \return true if this op should be registered to invoke a specific compiler
* for codegen, otherwise, false.
*/
using FTVMAnnotateCompiler = runtime::TypedPackedFunc<
bool(const Attrs& attrs, // NOLINT(*)
const Array<Expr>& args,
const std::string& compiler)>;

/*!
* \brief Forward rewriting rule for a specific op.
*
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/relay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from . import adt
from . import analysis
from . import transform
from .build_module import build, create_executor, optimize, build_extern_compiler
from .build_module import build, create_executor, optimize
from .transform import build_config
from . import prelude
from . import parser
Expand Down
29 changes: 0 additions & 29 deletions python/tvm/relay/build_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from .module import Module as _Module
from .backend import interpreter as _interpreter
from .backend.vm import VMExecutor
from . import transform as _transform

def _update_target(target):
target = target if target else _target.current_target()
Expand Down Expand Up @@ -297,34 +296,6 @@ def optimize(mod, target=None, params=None):
return mod, params


def build_extern_compiler(mod, compiler):
"""Helper function that annotates a Relay module and patitions the
expression init into various regions. These regions will be handled
by either default compilers in TVM stack or the provided external compiler.
Parameters
----------
mod : relay.Module
The module to build. Using relay.Function is deprecated.
compiler : str
The name of the external compiler.
Returns
-------
mod : relay.Module
The relay module contains partitioned program regions (e.g. functions)
that will be compiled using different compilers.
"""
if isinstance(mod, _expr.Function):
mod = _Module.from_expr(mod)

seq = _transform.Sequential([_transform.AnnotateCompiler(compiler),
_transform.PartitionGraph()])
mod = seq(mod)
return mod


class GraphExecutor(_interpreter.Executor):
"""Wrapper around Executor interface.
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/relay/op/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# operator defs
from .op import get, register, register_schedule, register_compute, register_gradient, \
register_pattern, register_alter_op_layout, register_legalize, \
register_annotate_compiler, schedule_injective, Op, OpPattern, debug
schedule_injective, Op, OpPattern, debug

# Operators
from .reduce import *
Expand Down
1 change: 0 additions & 1 deletion python/tvm/relay/op/contrib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@
"""Neural network related operators."""
from __future__ import absolute_import as _abs
from .contrib import *
from .annotate_compiler import *
from . import _contrib
119 changes: 0 additions & 119 deletions python/tvm/relay/op/contrib/annotate_compiler.py

This file was deleted.

20 changes: 0 additions & 20 deletions python/tvm/relay/op/contrib/ccompiler/__init__.py

This file was deleted.

34 changes: 0 additions & 34 deletions python/tvm/relay/op/contrib/ccompiler/annotate_compiler.py

This file was deleted.

20 changes: 0 additions & 20 deletions python/tvm/relay/op/contrib/dnnl/__init__.py

This file was deleted.

50 changes: 0 additions & 50 deletions python/tvm/relay/op/contrib/dnnl/annotate_compiler.py

This file was deleted.

20 changes: 0 additions & 20 deletions python/tvm/relay/op/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ def register_pattern(op_name, pattern, level=10):
"""
return register(op_name, "TOpPattern", pattern, level)


def register_gradient(op_name, fgradient=None, level=10):
"""Register operator pattern for an op.
Expand Down Expand Up @@ -284,25 +283,6 @@ def register_shape_func(op_name, data_dependant, shape_func=None, level=10):
get(op_name).set_attr("TShapeDataDependant", data_dependant, level)
return register(op_name, "FShapeFunc", shape_func, level)

def register_annotate_compiler(op_name, fannotate=None, level=10):
"""Register the compiler for an op.
Parameters
----------
op_name : str
The name of the operator.
fannotate : function (attrs: Attrs, args: List[Expr], compiler: str)
-> new_expr: Expr
The function for wrapping a call expr with compiler_begin and
compiler_end.
level : int
The priority level
"""
return register(op_name, "FTVMAnnotateCompiler", fannotate, level)


_init_api("relay.op", __name__)

@register_func("relay.op.compiler._lower")
Expand Down
18 changes: 0 additions & 18 deletions python/tvm/relay/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,24 +508,6 @@ def Legalize(legalize_map_attr_name="FTVMLegalize"):
return _transform.Legalize(legalize_map_attr_name)


def AnnotateCompiler(compiler):
"""Annotate ops in an experession with a provied compiler and then use it
for codegen.
Parameters
----------
compiler : str
The compiler used for codegen.
Returns
-------
ret : tvm.relay.Pass
The annotated pass that wrapps ops with subgraph_start and
subgraph_end.
"""
return _transform.AnnotateCompiler(compiler)


def RewriteAnnotatedOps(fallback_device):
"""Rewrite the annotated program where annotation operators, e.g.
`on_deivce`, mark which device an expression should be scheduled to.
Expand Down
Loading

0 comments on commit 703ab73

Please sign in to comment.