[Relay] Legalize pass (#3672)
authorAnimesh Jain <anijain@umich.edu>
Tue, 6 Aug 2019 22:23:41 +0000 (15:23 -0700)
committerYizhi Liu <liuyizhi@apache.org>
Tue, 6 Aug 2019 22:23:41 +0000 (15:23 -0700)
commit79922bd39fe3ca9e4f88a9b494e92bea69a5fe68
treefc6113c3725c1cb5892998d9f0770f0f9856cd8d
parent831b32e74b4ecf1cae25b8d5bad745ce863045ee
[Relay] Legalize pass (#3672)

* [Relay] Rewrite pass.

This pass transforms an expression to other expression.

This pass has many usecases
 * Replace a expr to another expr, if the other expr has faster performance.
 * For ASICs, we might want to modify the inputs to adapt to the HW support.
 * Alter op layout can work in conjunction with this pass.

The supporting usecase is the Intel i8 x i8 conv. Intel HW supports u8 x i8 conv
in HW. Using this pass, we can replace an i8 x i8 conv to a sequence of
operators where one of the operators is now u8 x i8 conv. This will also help
automatic quantizaion performance.

* Better API name.

* Removing the conv2d legalization for x86. Will send a separate PR.

* Test name changes.

* Registering one funtion to register FTVMLegalize.

* Better comments.
include/tvm/relay/op_attr_types.h
include/tvm/relay/transform.h
python/tvm/relay/op/__init__.py
python/tvm/relay/op/nn/_nn.py
python/tvm/relay/op/op.py
python/tvm/relay/transform.py
src/relay/backend/build_module.cc
src/relay/pass/legalize.cc [new file with mode: 0644]
tests/python/relay/test_pass_legalize.py [new file with mode: 0644]