Commit Graph

110 Commits

Author SHA1 Message Date
Tianqi Chen 0a0e58bfa4 [REFACTOR][TIR] Introduce PrimFuncPass. (#5139)
* [REFACTOR][TIR] Introduce PrimFuncPass.

- Introduce PrimFuncPass
- Convert one pass to the unified Pass API.

* Address comments

* Fix comments
2020-03-24 08:15:54 -07:00
Mahesh Ambule 9037f4ec98 [Relay, Topi, TF Frontend] Isfinite operator (#4981)
* isfinite doc update

* isfinit expr

* isfinit expr

* isfinite schedule reg

* isfinite python binding

* isfinite python binding

* relay register isfinite

* isfinite type relation

* intrin isfinite

* topi isfinite

* testcase topi isfinite

* tf frontend isfinite

* tf frontend isfinite testcase

* test case relay isfinite

* small fixes

* test forward tf isfinite

* test cases injective for cuda

* remove float16 test case

* add support for isinf

* remove unwanted import

* fix conflict
2020-03-23 20:17:12 +09:00
Mahesh Ambule fdc8b0dd17 [Relay, Topi] [TF, MXNet] Unravel Index operator (#5082)
* first cut unravel_index

* merge fixes

* change rates to dilations

* unravel_index op relay, topi, mxnet, tf

* doc changes

* small changes

* remove empty unravel and argwhere attrs

* remove empty unravel and argwhere attrs
2020-03-23 10:40:54 +09:00
Zhi 36a83c7f05 [docs] Update relay docs (#5112)
* Update relay docs

* any -> py:func

* make clean
2020-03-20 19:58:48 -07:00
masahi 2b6612317b [TOPI, Relay refactor] Move Dilation2d from nn to image namespace (#5110) 2020-03-20 15:20:13 -07:00
Zhi 7ca3212f06 create function.py (#5087) 2020-03-18 08:56:55 -07:00
Zhi 4aff8dc13f [Refactor][Relay] Refactor Relay Python to use new FFI (#5077)
* refactor relay python

* revert relay/ir/*.py to relay

* Address comments

* remove direct access to analysis and transform namespace
2020-03-17 08:33:10 -07:00
Mahesh Ambule 646cfc6371 [Relay, TF Frontend] Dilation2D operator support (#5033)
* update docs for dilation 2d

* dilation2d compute

* dilation2d register

* dilation2d rel compute

* dilation2d strategy

* dilation2d attrs

* dilation2d generic schedule

* dilation2d tf frontend support

* dilation2d tf frontend test case

* dilation2d test cases

* pylint fixes

* add exception for cuda target

* Update docstring

* Update docstring

* change rates to dilations

* removed unused param

* merge master

* Update nn.py

* Update nn.py
2020-03-16 23:54:32 -07:00
Tianqi Chen 1dbdcfb5e0 [DOCS] Sphinx -- Introduce alias detection. (#4954)
* [DOCS] Sphinx -- Introduce alias detection.

Background: some of our namespaces import function from another
namespace. For example tvm.te imports most of the operators from tvm.tir.

Previously we manually exclude these aliases from the doc.
However that means we can not link them by the alias name.

This PR adds a sphinx callback plugin to detect such aliases, and create a rubric block
on the button of its current docstring `Alias of the original class`.
It is done in a way so that we can refer to the generated docs.

We also fixed a few docs errors.

* Fix most of the issues
2020-02-27 14:27:37 -08:00
Tianqi Chen 9816efc2df [REFACTOR][PY][API-CHANGE] Remove legacy python files. (#4943)
* [REFACTOR][PY][API-CHANGE] Remove legacy python files.

Remove legacy python files.
Use the te namespace for most of the tensor expression primitives.

- tvm.create_schedule -> tvm.te.create_schedule
- tvm.placeholder -> tvm.te.placeholder
- tvm.compute -> tvm.te.compute

* Remove top-level exposures.
2020-02-26 21:10:47 -08:00
Neo Chien b598c545b4 [DOCS] Fix Sphinx Warning: the target found for cross-reference (#4925)
* [DOCS] Fix Sphinx Warnings: the target found for cross-reference warnings

* Fix the warning: undefined label
2020-02-25 20:23:27 -08:00
Alex Wong 87c20bb2b2 [Relay] Add a PyTorch to Relay Parser (#4497)
* Add a PyTorch to Relay parser

* Add alexnet, googlenet, mnasnet, shufflenet wip

* Fix lint

* Remove fix for shufflenet

* Lower check

* Pull changes from neo-ai/tvm changes

* Remove commented out section

* Use infer_shape everywhere

* Change back to using trace instead of path in from_pytorch

* Parse state_dict to add param names

* Umbrella single_op under test_forwards

* Remove print and cleanup call

* Check if update to test broke CI

* Retrigger CI

* Add back in updated tests

* Try splitting up tests

* First pass at flexible typing, implemented for ones

* Add int32 for all ops

* Remove print statements

* Fix lint

* Broad except

* Add other tensor types

* Temporarily use old tests

* Retrigger CI

* Lower type names

* Use numpy to convert in dense op

* Fix lint

* Remove print

* Need to cleanup but verify int32 works for add

* Rough tests for different types, a lot of types are not supported on CPU

* Probably doesn't build, need to save work as I have to switch branches (constantly)

* Parse param type

* Remove print stmt in parser

* Clean up some code

* Working on flaot32 for bn

* Add resnet18 double type

* Fix lint

* Temporarily move PT tests first

* Temporarily add back refactored tests to fix mem issue

* Add more type test and temp remove some tests

* Comment out tests, hopefully CI prints a trace

* Get stack trace

* Remove operator dict key, rename op_name to node_id, remove dead code

* Make relay map a list

* Remove some hacky string stuff

* Move to PyTorch 1.4

* Remove input_type as param

* Remove _get_fill_value, fix full ops

* Remove unused code and combine ops for identity and none

* Remove fn_param

* Clean up main loop

* Remove useless if/else for outputs

* Remove ir_names, only used once

* Remove some string hacking

* Remove string parsing to get output name

* Fix bug with output sizes of nodes

* Use attributeNames in parse ops

* Remove continue and add_op in parse_op

* Do this everywhere, use assert instead of explciitly type casting

* Remove unnecessary swap

* Slight refactor for elemwise input parse

* Use a copy of graph everywhere

* Rename nid_to_node_name

* Refactor parse import prereqs

* Clean up input node kind check

* Clean up conditionals

* Clean up add_op

* Cleanup type for ones and zeros op

* Fix lint

* Add torch install to CI

* Actually use torch

* Try moving import torch to only where it's needed

* Import torch for CI

* Use take op for select

* Temporarily add ignore for jit inline pass for CI

* Use CompleteTensorType, might be a PT 1.2 only thing

* Use different types in elemwise op

* Use float16 ones

* Fix float16 test

* Remove the temp docker changes

* Remove temp test

* Temporarily comment out original tests

* Remove file

* Empty cache after each test

* Add some prints and lower input sizes

* Try using no grad

* Trying to globally set grad off

* Use no grad for torchvision

* Remove xfail tests

* Remove VGG and AlexNet due to some issues

* Combine pooling tests

* Remove extra test file

* Remove single op, remove larger pooling tests

* Remove maxpool3

* Remove debug prints

* Remove inference call and add no_grad in measure latency

* Use standard string start char

* Remove redundant infer_shape in slice

* Convert most to checks to just expr

* Remove extra paren

* More refactor of isinstance

* Add helper for creating typed constants

* Assert instead of return when no matching type

* Remove network variants

* Add no_grad when forward, remove deatch, fix lint

* Change isinstance to expr in transpose

* Use opnotimplemented, refactor

* Fix full ops, remove duplicate tests

* Never use shape field unless we know the type

* Remove comma, retrigger CI

* Add paren, retrigger CI

* Use inline if-else for flags

* Throw exception instead of assert

* Remove version check for CI

* Check version when doing inline pass

* Fix lint

* Lower more input sizes

* Add new line, conv2d only accepts weight as expr

* Use tvm.runtime.ndarray

* Remove change to torch version install

* Try no grad for mobilenet

* Fix lint

* Fix lint again

* Revert to last passing

* Delete test files

* Ignore lint

* Revert back

* Comment out mobilenet

* Clean up compare compiled and baseline outputs

* Use IRModule

* Add todos

* Refactor use_bias

* Add todo for fix conv op channels

* Change input to data type

* Remove todo

* Handle channel multiplier > 1
2020-02-24 20:14:45 -08:00
Cody Yu 98e7709ff9 [DOCS] Fix Sphinx Warnings (RST indent, cross-ref, and image scale) (#4920)
* fix indents

* Fix image scale and cross-ref
2020-02-20 14:09:34 -08:00
Cody Yu fd6d7837ed [DOCS] Fix sphinx warnings (#4917)
* Fix Python docstrings

* More fixes

* Fix lint
2020-02-20 09:24:37 -08:00
Tianqi Chen d2ae8c95d5 [DOCS] Update API docs to reflect the status after the refactor. (#4907) 2020-02-18 15:39:59 -08:00
Tianqi Chen 0b2d11a574 [DOCS] Introduce how to add hardware backend to FAQ (#4898) 2020-02-17 10:53:05 -08:00
tqchen 51a265af01 [REFACTOR][PY][API-CHANGE] Establish tvm.target
Move the related target modules into tvm.target.

API change:
- tvm.target.current_target -> tvm.target.Target.current
- tvm.datatype -> tvm.target.datatype
2020-02-12 16:36:23 -08:00
tqchen 176ffe5058 [DOCS][PY] Sphinx docs about tvm.ir 2020-02-12 08:01:22 -08:00
Tianqi Chen a566161147 [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding files (#4862)
* [REFACTOR][PY][API-CHANGE] establish tvm.ir, migrate corresponding relay files.

This PR establishes tvm.ir and migrates the corresponding relay
files into the new folder.

API Change:
- relay.Module -> tvm.IRModule

* Update with ADT

* Migrate transform

* address comments

* Migrate module

* Migrate json_compact

* Migrate attrs

* Move LoweredFunc to stmt temporarily

* temp migrate container

* Finish migrate container
2020-02-11 20:01:36 -08:00
Tianqi Chen e0122c0ea6 [REFACTOR][PY][API-Change] Polish tvm.runtime, tvm.runtime.module API update (#4837)
* [REFACTOR][PY-API] Polish tvm.runtime, tvm.runtime.module API update

This PR updates the tvm.runtime to use the new FFI style.

- Remove top-level tvm.module to avoid confusion between runtime.Module and IRModule
- API changes wrt to runtime.Module
  - tvm.module.load -> tvm.runtime.load_module
  - tvm.module.enabled -> tvm.runtime.enabled
  - tvm.module.system_lib -> tvm.runtime.system_lib
- Remove dep on api_internal from runtime.

* Update module.load in the latest API
2020-02-07 09:15:08 -08:00
Yizhi Liu 3a672e3eba [Arith] add SizeVar representing non-neg valued variable in a tensor shape (#4684)
* [arith] add ShapeVar representing non-neg valued variable in a tensor shape

* bounder remover; deal with div in int_set differently

* fix bounder_remover

* migrate unittest to use shape_var

* use tvm.shape_var in integration & relay tests

* add test case; fix Var register

* fix lint

* fix lint again

* add default ShapeVar visitor in Relay

* fix override

* fix ShapeVar visit bug

* revert IntervalSet for shape_var

* remove bound_remover

* remove is_var; use constructor for shapevar/var instead

* ShapeVar -> SizeVar; add constructor comments

* shape_var -> size_var in doc

* tindex -> size
2020-01-15 22:07:40 -08:00
Yong Wu 56416ed084 [TOPI][RELAY][OP] add op crop_and_resize (#4417)
* [TOPI][RELAY][OP] add op crop_and_resize

* fix pylint

* incorporate comments

* fix ci
2020-01-10 19:52:52 -08:00
Zhi 86092de0b6 [REFACTOR] Replace TensorObj and TensorValue with NDArray (#4643)
* replace TensorObj and TensorValue with NDArray

* NodeBase to Object in Python

* rebase
2020-01-10 16:44:16 -08:00
Haichen Shen baae28b269 [Autotvm] Use VM compile to extract autotvm tasks (#4328)
* [AutoTVM] Use vm compile in extracting task from relay

* update

* restructure vm compiler to reduce task extraction time

* x

* fix

* update doc

* udpate doc

* lint
2020-01-08 17:15:55 -08:00
Tianqi Chen e6ff3f701b [TEST] Remove nnvm related code in topi and test script (#4562)
* [TEST] Remove nnvm related code in topi and test script

* Remove docs dep
2019-12-22 09:47:34 -08:00
Yao Wang a226973ba7 [Frontend]Add TensorFlow FloorMod (#4308)
* Add tf FloorMod

* Add floor_div/mod into topi and relay

* Add to rst

* Fix test
2019-11-18 09:24:34 +05:30
Philip Hyunsu Cho 23691b8e34 Add topi.nn.fifo_buffer to TVM doc (#4343) 2019-11-14 19:42:53 -08:00
Jon Soifer b07b195264 [Relay][Topi][TensorFlow][ONNX][Lang] Add support for Any op (#4205)
* Add support for Any op

* Support ONNX frontend

* Add doc

* Add to relay docs

* Dummy change to retrigger CI
2019-10-30 11:43:09 -07:00
Tianqi Chen 2ded2d8caf [ARITH] Use explicit div mode in python. (#4014) 2019-09-27 07:45:25 -07:00
Kimish Patel 17c2c0a12b Expose llvm.nearbyint intrinsic. This is a faster alternate to rounding. (#4001)
* Expose llvm.nearbyint intrinsic. This is a faster alternate to rounding.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

* Added python binding. Added test.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
2019-09-25 11:22:54 -07:00
Jon Soifer ed9fdfb092 [Relay] Add new IR pass CombineParallelDense (#3862)
* Refactor to create abstract ParallelOpCombiner

* First draft of CombineParallelDense

* Begin to work on tests

* Test

* Refactor to move out more common code

* Clean up

* Fix

* Remove statics

* fix wording

* Start to add combine_parallel_op_batch

* Resolve PR comments

* Resolve PR comments

* dummy change to retrigger CI

* Change special case from bias_add to add

* Revert special case change

* Ignore units check

* dummy change to retrigger CI

* dummy change to re-trigger CI

* Improve docs

* Update docs

* Update docs
2019-09-24 01:12:11 -07:00
Huang, Guangtai 16d4da4d61 Add operator isnan (#3979)
* add expr `isnan`

* move to intrinsic

* doc & add to topi

* fix error from ci
2019-09-22 09:49:10 -07:00
Zhi 88cd1b1c54 Add docs for analysis namespace (#3985) 2019-09-22 02:44:07 +08:00
Neo Chien ab1853c289 [TOPI] operator support: logical_and, logical_or, logical_not (#3929)
* [TOPI] operator support: logical_and, logical_or, logical_not

* [TOPI] operator support: logical_and, logical_or, logical_not

* [TOPI] fix test cases for operator support: logical_and, logical_or, logical_not

* [TOPI] fix test cases for operator support: logical_not
2019-09-16 10:42:47 -07:00
Jon Soifer 554df21189 [TOPI][Relay][TensorFlow] Add OneHot operator (#3781)
* Add one-hot to Relay

* topi implementation

* Working

* add topi test

* Add TF test

* Fix check

* fix linting issues

* fix documentation

* Fix documentation

* Add support for on_value, off_value, axis, dtype

* Add full support for axis

* Fix compute and update test_forward

* Move on_value and off_value to inputs

* Add topi test

* Update tests

* Update docs

* Fix style

* re-enable tests

* Add one_hot to mxnet converter
2019-08-22 13:45:45 -07:00
Zhi 8a46444ffe fix some pass docs (#3767) 2019-08-13 15:23:50 -07:00
Andrew Tulloch 2ed31b24fe {relay,topi}.reinterpret support (#3599)
= Motivation

It's useful to expose the tvm::reinterpret functionality to Relay/TOPI users, as
this allows them to build (fused) operators leveraging the bitwise
reinterpretation of an operator. An example is approximate transcendental
functions, which can be implemented similar to:

```.py
    def C(x):
        return relay.expr.const(x, "float32")

    def approx_exp(x):
        x = relay.minimum(relay.maximum(x, C(-88.0)), C(88.0))
        x = C(127.0) + x * C(1.44269504)
        xf = relay.floor(x)
        i = relay.cast(xf, "int32")
        x = x - xf
        Y = C(0.99992522) + x * (C(0.69583354) + x * (C(0.22606716) + x * C(0.078024523)))
        exponent = relay.left_shift(i, relay.expr.const(23, "int32"))
        exponent = relay.reinterpret(exponent, "float32")
        return exponent * Y

    def approx_sigmoid(x):
        # <2.0e-5 absolute error over [-5, 5]
        y = approx_exp(x)
        return y / (y + C(1.0))

    def approx_tanh(x):
        # <4.0e-5 absolute error over [-5, 5]
        x = x * C(2.0)
        y = approx_exp(x)
        return (y - C(1.0)) / (y + C(1.0))
```

See unit tests for implementations of these approximate transendentals.
2019-07-23 14:43:27 -07:00
Yong Wu 313bc9de4d [TOPI][RELAY] Add op Size (#3094) 2019-07-19 15:06:34 -07:00
Zhi e3d6074a5b Clean up pass.h (#3312) 2019-07-02 09:14:52 -07:00
Xingjian Shi 8ef2217642 [RELAY] [OP] [MXNet Frontend] Add sequence_mask (#3437)
* Add sequence_mask

use exactly the same arguments as mxnet

fix

* fix lint

* fix lint

* add mxnet conversion + relay

* update

* update doc

* fix pylint

* fix doc

* address comment

* try to address comments

* try to enable shape check for valid_length

* fix

* try to fix

* fix bug

* try to fix

* address comment

* address comment
2019-06-27 21:51:04 -07:00
Haichen Shen 072f8cc75e [Relay/TOPI][Op] Add TopK operator (#3256)
* init impl for topk

* Fix cpu for topk

* init cuda impl for topk

* Add cuda for topk

* fix

* Add doc

* update doc

* lint

* lint

* lint

* x

* fix warning

* [Relay] Add TopK in tf converter

* Add frontend converter

* fix
2019-06-04 16:29:56 -07:00
Zhi 138ec7be78 [Relay][Transform] merge PassContext and BuildConfig (#3234) 2019-05-24 12:05:00 -07:00
Logan Weber 4b1d3d87a3 Add SkipVectorize pass (#3222) 2019-05-21 16:34:35 -07:00
Yong Wu 9fd8e3c513 [Relay][TOPI] operator All (#3124)
* [Relay][TOPI] operator All

* Update tests/python/frontend/tensorflow/test_forward.py

Co-Authored-By: yongwww <55wuyong@163.com>

* fix comments

* change to level 4
2019-05-20 11:56:22 -07:00
Yao Wang 147ea3b0ca [Relay][Op] Adaptive pooling (#3085)
* Add topi adaptive_pool

* Use adaptive_pool to compute global_pool

* Add relay adaptive pool2d

* Fix lint

* Fix typo

* Minor change

* Change support level to 10

* Add contrib

* Remove global pool schedule

* Add contrib module

* Fix lint

* Update doc

* Update doc
2019-05-08 17:21:41 -07:00
Hiroyuki Makino 9bfdc55c57 [Relay][TOPI] Add rsqrt operator (#2949) 2019-04-25 11:05:42 -07:00
Tianqi Chen cffb4fba03 [HEADER] Add Header to Comply with ASF Release Policy (#2982)
* [HEADER] ASF header dir=include

* [HEADER] ASF Header dir=src

* [HEADER] ASF Header -dir=python

* [HEADER] ASF header dir=topi

* [HEADER] ASF Header dir=nnvm

* [HEADER] ASF Header -dir=tutorials

* [HEADER] ASF Header dir=tests

* [HEADER] ASF Header -dir=docker

* fix whitespace

* [HEADER] ASF Header -dir=jvm

* [HEADER] ASF Header -dir=web

* [HEADER] ASF Header --dir=apps

* [HEADER] ASF Header --dir=vta

* [HEADER] ASF Header -dir=go

* temp

* [HEADER] ASF Header --dir=rust

* [HEADER] Add ASF Header --dir=cmake

* [HEADER] ASF Header --dir=docs

* [HEADER] Header for Jenkinsfile

* [HEADER] ASF Header to toml and md

* [HEADER] ASF Header to gradle

* Finalize rat cleanup

* Fix permission

* Fix java test

* temporary remove nnvm onnx test
2019-04-07 21:14:02 -07:00
Tianqi Chen f63631fc73 [RUNTIME] Scaffold structured error handling. (#2838) 2019-03-18 23:05:02 -07:00
Ashutosh Parkhi cc112c10c5 Support for sign (#2775) 2019-03-13 22:14:26 -07:00
Haichen Shen ee8058069a [Relay/TOPI][Op] Add shape op in Relay and TOPI (#2749)
* Add shapeof op in topi

* Add relay shape_of op

* Add constant folding for shape_of

* Allow shape op to specify dtype

* Add mxnet converter for shape_array

* lint

* lint

* Add doc
2019-03-13 16:14:48 -07:00