Commit Graph

1498 Commits

Author SHA1 Message Date
Tianqi Chen e68450dacf [PY][FFI] Introduce PyNativeObject, enable runtime.String to subclass str (#5426)
To make runtime.String to work as naturally as possible in the python side,
we make it sub-class the python's str object. Note that however, we cannot
sub-class Object at the same time due to python's type layout constraint.

We introduce a PyNativeObject class to handle this kind of object sub-classing
and updated the FFI to handle PyNativeObject classes.
2020-04-23 22:06:05 -07:00
MORITA Kazutaka 6c77195e9c [FRONTEND][MXNET] support elemwise logic ops (#5361) 2020-04-23 19:54:26 -07:00
Samuel 6faacc6f9e [MXNET]DepthToSpace & SpaceToDepth Operator (#5408) 2020-04-23 15:05:25 -07:00
Wei Pan 9c12ec8120 [cuDNN] Add cuDNN grouped convolutions support (#5319)
Signed-off-by: Wei Pan <weip@nvidia.com>
2020-04-23 11:59:03 -07:00
Zhao Wu a3b1397363 [Frontend] Asymmetric padding of convolution support (#4803) 2020-04-23 10:10:02 -07:00
MORITA Kazutaka 1acad98edc [RUNTIME][CONTRIB] CoreML Runtime (#5283)
* [RUNTIME][CONTRIB] CoreML Runtime

* fix lint

* fix CI

* use xcrun to compile coreml model
2020-04-23 15:35:43 +08:00
Tianqi Chen b8c23d660d [TIR][REFACTOR] Remove ir_pass in favor of analysis/transform. (#5415)
This PR removes ir_pass(old style pass functions) in favor
of analysis/transform(new style pass manager).
2020-04-22 20:44:25 -07:00
Andrew Reusch 8f433febea Don't remove() TempDirectory in __del__ after atexit hook runs. (#5414)
* Use atexit to remove TempDirectory before interpreter shutdown.
 * Can't rely on complex functions from __del__ anyway.
 * Fixes warning message on my box:
       Exception ignored in: <function TempDirectory.__del__ at 0x12be10680>
       Traceback (most recent call last):
        File ".../tvm/python/tvm/contrib/util.py", line 55, in __del__
        File ".../tvm/python/tvm/contrib/util.py", line 51, in remove
        File "/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/shutil.py", line 509, in rmtree
        AttributeError: 'NoneType' object has no attribute 'path'
2020-04-22 18:30:11 -07:00
Andrew Reusch f5c9bc9388 Customize SI prefix in logging (#5411)
* Customize SI prefix in logging

* Include unit test
2020-04-22 15:35:21 -07:00
Tianqi Chen 6cb5b882b1 [TIR] Enhance Substitute, python bindings for Substitute/PostOrderVisit/IRTransform. (#5400)
Substitute now takes a std::function to customize more replacing behaviors.

Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>

Co-authored-by: Siyuan Feng <hzfengsy@sjtu.edu.cn>
2020-04-22 13:25:36 -07:00
Ramana Radhakrishnan 3e3ccce113 Factor out import of common tflite.Operator in tflite frontend. (#5355)
* Restructure imports in tflite frontend.

These python modules are needed for every tflite file parsed.
Factorize out imports of the common most ones.

Now that the import of operator is common, asserts can be commonized.

Loses 473 lines of duplication.

* Only restrict to tflite.Operator
2020-04-22 14:09:11 +08:00
Samuel 24f6865385 [KERAS]Minimum & AlphaDropout op support (#5380) 2020-04-22 11:57:06 +08:00
Tianqi Chen d3277874a2 [PTYTHON] Migrate VTA TIR passes to the new pass manager. (#5397) 2020-04-21 14:23:18 -07:00
Animesh Jain b39bd83172 [Topi, ARM] Disbale Winograd for quantized tensors. (#5363)
* [Topi, ARM] Disbale Winograd for quantized tensors.

* Relaxing float
2020-04-21 20:06:13 +09:00
Josh Fromm 5ce2c2968a Add ability to have multiple copies of same input to onnx_inputs. (#5389) 2020-04-21 19:57:13 +09:00
Tianqi Chen d9cecdf501 [ARITH] Remove the legacy Simplify, migrate to Analyzer. (#5385)
The legacy Simplify/CanonicalSimplify are now a thin wrapper around the Analyzer.
This PR removes these functions and migrated every place that requires
simplification to enforce Analyzer creation.
The new API would encourage more Analyzer sharing and potentially enable
context-aware analyzer-based simplification.
2020-04-20 19:28:08 -07:00
Bing Xu 3f03869e6b [Blocksparse] Pipeline for lowering dense model to sparse-dense (#5377) 2020-04-20 01:15:37 -04:00
Tianqi Chen 4c0a53dc5b [TIR][REFACTOR] RewriteForTensorCore -> te/schedule (#5379)
* [TIR][REFACTIR] RewriteForTensorCore -> te/schedule

RewriteForTensor depends on the schedule information, which makes it differ
from a typical pass(which should get all the information from the input TIR).

As a result, we refactor it as a SchedulePostProc step for now.
We should revisit it later as we introduce more support for tensor core patterns in the TIR.

* Fix VTA to fit the new IR Pattern
2020-04-19 19:57:25 -07:00
Samuel 22db299b33 [PYTORCH]Unary Ops (#5378) 2020-04-20 10:48:51 +09:00
Tianqi Chen c3511c5e2c [TIR][REFACTOR] Remove te::Tensor dependencies from TIR passes. (#5372)
* [TIR][REFACTOR] Remove te::Tensor dependencies from TIR passes.

te::Tensor is an useful object for tensor expression, but brings
un-necessary reverse dependency in TIR nodes such as Provide and Realize.

This PR is a first step to remove this dependency. We will use Buffer in all the places
where the te::Tensor was used. The rough correspondence are:

- Provide -> BufferStore
- Realize -> BufferRealize
- HalideCall -> BufferLoad.

After this change, we can not use IRModule of PrimFuncs cleanly to represent TIR
at any point of the optimizations. Buffer will serve as the abstraction for the TIR data
models to represent the intermediate storages and their constraints.

We still keep Realize/HalideCall and Provide as TIR nodes for now to make the change minimum.
Right after ScheduleOps, we call SchedulePostProcToPrimFunc to canonicalize the temporary IR
generated by TE(which contains these nodes) to the TIR.

The TIR optimizations are now mostly migrated to to the pass manager.
Followup PRs are needed to migrate the remaining few passes.

* Fix dev tutorial
2020-04-19 15:26:51 -07:00
shoubhik a4902e0590 Remove developer facing api from frontend exports. (#5375) 2020-04-18 21:09:32 -07:00
Josh Fromm 4672dc7609 Add cuda target check to dense tensorcore schedule. (#5376) 2020-04-18 21:09:14 -07:00
Tianqi Chen 326489505d [TIR][REFACTOR] Migrate low-level passes in tvm.lower to the Unified IR pass manager. (#5364)
- Migrate BoundCheckers and Simplify
- Migrate RewriteUnsafeSelect and RemoveNoOp
- Migrate UnrollLoop and StorageRewrite
- Migrate InjectDoubleBuffer and InjectVirtualThread
- Migrate LoopPartition and Vectorize
- Migrate CoProcSync, LiftAttrScope, InjectCopyIntrin

We still keep ir_pass registerations for now.
Need a separate PR to refactor the parts before the StorageFlatten.
2020-04-18 12:33:58 -07:00
Samuel f49fc366ce [RELAY][PYTORCH]GroupNorm op support added (#5358) 2020-04-17 23:54:24 +09:00
Samuel 9bbee96fea [PYTORCH]Tensor creation ops support (#5347) 2020-04-17 10:24:55 +09:00
mbaret 84d1eec39a [RELAY][BYOC] Register pattern tables from external codegens (#5262)
* [RELAY][BYOC] Register pattern tables from external codegens

This adds utility functions to support registering
and retrieving pattern tables used by MergeComposite for
external codegens.

Change-Id: I5be165a321440e48b15ff6aff4970e0c67496aaa

* Updated DNNL tests to use pattern table mechanism

* Removed pattern table standalone test

* Change reg to _op
2020-04-16 17:36:38 +09:00
Samuel 6e36da3571 [TOPI][PYTORCH]Logical & Bitwise operator support (#5341) 2020-04-16 17:34:36 +09:00
Tianqi Chen cc8cacb144 [DOCS] Bring relay docs to the top-level flat view (#5343)
- Changes most of the relay docs to use autosummary.
- Bring relay API docs to the top-level flat view for easier discovery
- Removed a few cases of re-exports.
2020-04-15 15:32:59 -07:00
Tianqi Chen e8138f7d31 [TIR] Remove ProducerConsumer and AllocateNode::new_expr (#5333)
* [TIR] Remove ProducerConsumer and AllocateNode::new_expr

This PR removes two legacy IR parts in TIR that are deprecated.

ProducerConsumer node only serves as a hint markup and may no longer be
informative after extensive transformations in the pass.
If necessary, we can add related info via AttrStmt.

The new_expr field in the AllocateNode is deprecated since it can just be
replaced by a LetStmt.

- Remove dependencies of passes on ProducerConsumer.
- Remove ProducerConsumer from the IR.
- Remove the deprecated fields (new_expr, free_function) from AllocateNode.

* Fix additional testcases
2020-04-15 11:11:39 -07:00
Tianqi Chen f143881314 [PYTHON] Enhance with_attr API, cleanup MakeAPILegacy in testcases (#5335) 2020-04-15 11:11:28 -07:00
Leyuan Wang d81b006be8 [TOPI] Improve get_valid_count and nms performance for CUDA (#5339)
* get_valid_count updated to have correct results

* speedup nms

* update nms

* revert back nms

* recover one test for get_valid_count
2020-04-15 08:32:50 -07:00
Animesh Jain 1265983cf4 [TOPI] Using x86 schedules for ARM conv2d. (#5334) 2020-04-15 08:31:48 -07:00
Samuel b1364ebbed [PYTORCH]Take, Topk op support (#5332)
* [PYTORCH]take, topk op support

* Ci Failure fix
2020-04-15 19:18:03 +09:00
Jared Roesch 9a8ed5b7ab [Runtime][Relay][Cleanup] Clean up for memory pass to enable heterogenous execution support. (#5324)
* Cleanup type pack and unpack for tuples.

* Clean up the memory_pass using common helpers

* Clean up memory.cc

* Refactor pass

* Add doc strings

* Fix CPPlint

* Fix PyLint

* Fix

* Apply suggestions from code review

Co-Authored-By: Zhi <5145158+zhiics@users.noreply.github.com>

* Fix typo

Co-authored-by: Zhi <5145158+zhiics@users.noreply.github.com>
2020-04-14 17:10:00 -07:00
Tianqi Chen 275e317c56 [RELAY] Remove re-exports of tvm.transform (#5337) 2020-04-14 17:03:15 -07:00
Tianqi Chen f08d5d78ee [TIR] Refactor MakePackedAPI to target dependent stage. (#5326)
Previously MakePackedAPI was in the target independent stage,
but never the less requires the device_type information that will be
binded at a later target dependent stage.

The previous implementation was due to the limitation of LoweredFunc
which can not carry buffer_map info(so they have to be lowered right away).
This is no longer the case after the unified IR refactor.

This PR migrates MakePackedAPI to a target dependent stage
and removes the un-necessary BindDevice pass.
2020-04-14 07:48:14 -07:00
Samuel 4720cf8569 [RELAY][PYTORCH]isNan, isinf, isfinite, ceil, clamp, round ops (#5316)
* [RELAY][PYTORCH]isNan, isinf, isfinite, ceil, clamp, round ops

* Review comments
2020-04-14 18:45:02 +09:00
Wuwei Lin 1df6bb6d30 [TE][BuildModule] Fix import in dump pass ir (#5327) 2020-04-14 02:47:57 -04:00
Mahesh Ambule b7545eb5ca [Frontend|MXNet] SwapAxis operator support (#5246)
* MXNet swap axis

* MXNet swap axis

* swap axis review comment

* swap axis review comment
2020-04-13 23:09:21 -07:00
Tianqi Chen fc75de9d68 [RUNTIME][IR] Allow non-nullable ObjectRef, introduce Optional<T>. (#5314)
* [RUNTIME] Allow non-nullable ObjectRef, introduce Optional<T>.

We use ObjectRef and their sub-classes extensively throughout our codebase.
Each of ObjectRef's sub-classes are nullable, which means they can hold nullptr
as their values.

While in some places we need nullptr as an alternative value. The implicit support
for nullptr in all ObjectRef creates additional burdens for the developer
to explicitly check defined in many places of the codebase.

Moreover, it is unclear from the API's intentional point of view whether
we want a nullable object or not-null version(many cases we want the later).

Borrowing existing wisdoms from languages like Rust. We propose to
introduce non-nullable ObjectRef, and Optional<T> container that
represents a nullable variant.

To keep backward compatiblity, we will start by allowing most ObjectRef to be nullable.
However, we should start to use Optional<T> as the type in places where
we know nullable is a requirement. Gradually, we will move most of the ObjectRef
to be non-nullable and use Optional<T> in the nullable cases.

Such explicitness in typing can help reduce the potential problems
in our codebase overall.

Changes in this PR:
- Introduce _type_is_nullable attribute to ObjectRef
- Introduce Optional<T>
- Change String to be non-nullable.
- Change the API of function->GetAttr to return Optional<T>

* Address review comments

* Upgrade all compiler flags to c++14

* Update as per review comment
2020-04-13 10:49:48 -07:00
Josh Fromm 3df8d560f2 [Topi] Tensorcore support for Conv3D (#5284)
* one weird trick.

* Added schedule knob for different workloads.

* Initial conv3d tensorcore working.

* Added conv3d tensorcore strategy.

* Added layout conversion to tensorcore friendly format for conv2d and conv3d.

* Add target name check.

* Fixed bad names and depthwise check.

* Removed duplicated attribute assignment.
2020-04-13 10:49:17 -07:00
windclarion 0d48361a0b [REALY][OP] fix typo (#5315)
Signed-off-by: windclarion <windclarion@gmail.com>
2020-04-13 07:55:33 -07:00
Samuel 6805d54370 [PYTORCH]Reduce_ops support added (#5308)
* [PYTORCH]Reduce_ops support added

* Review comments updated

* typo bug in qnn test
2020-04-13 18:50:10 +09:00
masahi 0145cd5045 [Torch] Support Python list, more realistic recurrent networks (#5306)
* use funcs from prelude, pass around convert_map

* get relay input type from user ishape

* handle tuple unpack

* experimenting with static tensor array

* use prelude concat instead of cons + rev

* minor clean up

* fix layer norm conversion bug, unwrap tensor array

* add infer shape on tensor array

* pass around prelude for now

* compile worked but runtime error

* fix tensor array wrapping

* begin list dynamic test

* is_list_dynamic first version

* finish dynamic list test

* a few fix

* use shape_of function if Any is found

* improve size conversion

* working on adding free vars to loop block

* fixed inlined inner loop issue

* clean up free var handling

* add support for tensor array concat

* adding ta concat on last axis

* fix concat, but got runtime error

* disable concat on axis -1 for now

* add lstm tests

* revert unrelated change

* fix stacked bidir test

* minor fix to test

* relax tol a bit, revert dnnl change to avoid conflict

* simplify infer type, use input tensor shape rather than concat shape

* more shape fix
2020-04-12 23:11:57 -07:00
Junru Shao cd0d52daa6 [Intrinsic] Add log1p, ldexp, atan2, hypot, nextafter, copysign (#5312)
* [Intrinsic] Add log1p, ldexp, atan2, hypot, nextafter, copysign

* Lint
2020-04-12 09:32:23 -07:00
Tianqi Chen e4b80bda71 [IR][TRANSFORM] Enable CopyOnWrite for passes. (#5309)
This PR enables the copy on write optimizations passes:
- Enable COW for IRModule both TIR and relay passes.
- Enabled COW for PrimFunc in TIR passes.

Need more thoughts into whether/how to enable COW
for relay::Function, due to some function passes depend
on the presence of IRModule for context information,
and the std::move of the related function to nullptr
might affect the related behavior.
2020-04-11 17:42:42 -07:00
Samuel 5b37d4c153 [PYTORCH]Abs, Arange, Softplus ops (#5295)
* [PYTHON]Abs, Arange, Softplus ops

* Review comments updated
2020-04-11 14:02:58 +09:00
masahi 3616ebee68 [BYOC] Add example of Composite + Annotate for DNNL fused op (#5272)
* merge change from dev branch

* fix string issue

* bring comanic's change back
2020-04-11 12:29:20 +09:00
Yao Wang 4b27cd1460 [Frontend][TensorFlow]Improve TensorFlow Static Shape Tensor Array (#5243)
* Support TF Frontend Static TensorArray

* Fix pylint

* Fix lint

* Move get_tensor_array_shape into prelude

* Fix lint

* Fix common
2020-04-11 10:43:23 +09:00
Tianqi Chen b72dd9d935 [RUNTIME] Introduce RValue reference(move) support to TypedPackedFunc (#5271)
* [RUNTIME] Introduce RValue reference(move) support to TypedPackedFunc

This PR introduces RValue reference support the PackedFunc calling convention to address the above issue.
Specifically, when an argument is a r-value reference, we will use a assign a different type code(`kObjectRValueRefArg`),
and pass `Object**`  (the address to the Object pointer) instead through the values array.
The callee can choose to move out this Object pointer and set the original Object pointer from the caller side to be nullptr.

We also add an experimental move support to the python side(marked as _move so to indicate the dev nature).
This enhancement will enable copy on write optimizations through out the TVM stack.

* Address review comments

* fix compilation
2020-04-10 17:07:20 -07:00