Commit Graph

2523 Commits

Author SHA1 Message Date
Wang Yucheng 4bbbfe894e [Fix] Fix conv2d HWNC type strategy (#8147)
* fix conv2d strategy

* fix style

* fix style

Co-authored-by: wangyucheng <wangyucheng@sensetime.com>
2021-05-30 09:38:04 -04:00
Lunderberg e535ec8a3b [VM] Avoid round-trip Target->str->Target conversions (#8161)
Currently, in some cases this round-trip cannot be completed.  For
example, if an Integer value has a value outside a 32-bit signed
integer range, or if a String value contains spaces.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
2021-05-30 12:08:24 +09:00
Andrey Malyshev 8b5d843e75 Fix tvmc tuner for cases when uTVM is not enabled (#8153) 2021-05-30 12:07:42 +09:00
Josh Fromm e26990fa49 [AutoTVM][AutoScheduler] Add workaround to alter op layout bug in task extraction. (#8143)
* Add workaround to alter op layout bug in task extraction.

* Only copy mod.
2021-05-30 12:07:04 +09:00
masahi 27e44eee21 [Relay] Support dynamic indices size in gather_nd and scatter_nd (#8105)
* add gather_nd shape func

* refactor gather_nd ref funcs

* add dynamic gather_nd test

* gather_dim -> num_indices_per_tuple

* support dynamic scatter nd

* minor fix

* fix pylint

* rename to index_rank and make it Optional

* pylint, do not use -1 for default value
2021-05-30 12:06:22 +09:00
zackcquic ece644c5ed [IR][Pass][Instrument] Pass instrument framework (#7952)
* [IR][Pass][Instrument] Pass instrument framework

This commit provides utilies to instrument passes:
  1. Add a new namespace tvm.instrument
  2. Introduce PassInstrument and PassInstrumentor to PassContext

     Example
     -------
    passes_mem = #... Impl of memory instrument
    passes_time = tvm.instrument.PassesTimeInstrument()

    with tvm.transform.PassContext(
        pass_instrumentor=PassInstrumentor([passes_mem, passes_time])):

        tvm.relay.build(mod, 'llvm')

        passes_mem.rendor()
        passes_time.rendor()

  3. Integrate existing PassContext::Trace() and timing profile

* [IR][Pass][Instrument] Fix python test_pass_manager.py

* Fix comment

* Fix lint

* Fix test_pass_annotation

* Fix test_pass_annotation.py

* Fix lint

* Fix test_pass_annotation.py

* Fix test_pass_annotation.py

* Fix review comments

* Fix tutorial use_pass_infra.py

* Fix review comments

* Fix review comments

* Fix typo

* Fix review comments

* Fix review comments

* Fix unittest error: test_cow_pass

* Fix unittest error

* Add more test cases for exceptions

* Fix nit

* Doc override_instruments()

* Fix review comments

* Fix lint

* Fix EnterContext exception behavior
2021-05-28 13:44:09 -04:00
Nicola Lancellotti f0aedc4bcb Pin black version (#8139)
This commit pins the black version to provide stability.
It is expected that the pinned version will be moved forward periodically.

Change-Id: Ied866bff85a1a832959bc1d4673a7fdec68128a7
2021-05-28 10:16:46 -07:00
Mehrdad Hessar dad59be176 [microTVM] AOT Demo (#8075)
* initial

* remove compare

* temp fix

* debugging

* hack

* hack for testing

* both test pass

* cleanup

* fix tests and tutorials

* restructure

* cleanup

* cleanup

* fix check files

* fixed for physical devices

* address comments

* reduce nrf stack size

* update sample url

* format
2021-05-28 10:13:17 -07:00
Elen Kalda 23a95f6adc [lint] Fix black whitespace errors (#8124)
Change-Id: I927b43df95a8db8b042bc3cf2a1f23739d102b9d
2021-05-27 06:13:09 +09:00
Chenfan 4344540ad4 [FastMath] Add fast_softmax support in fast_math pass (#8138)
* Add fast_softmax support in fast_math pass

* Lintfix

* Update
2021-05-26 09:29:15 -07:00
Lunderberg c02cafb657 [Vulkan] Add device capabilities to Target, use in codegen (#8127)
* [Vulkan] Enable instance/device extensions

- Vulkan requires that extensions be explicitly enabled if used.
  Explicitly list out which extensions are required (currently none)
  and which are optional.

* [Vulkan] Extract device information from vulkan API.

- Based on vkGetPhysicalDeviceProperties and
  vkGetPhysicalDeviceFeatures, determine which Vulkan capabilities are
  supported, pack into a Target.

* [Vulkan] Query instance-supported apiVersion before creating instance

- Previously, vkCreateInstance was called to initialize Vulkan 1.0.

* [Vulkan] Moved options for dedicated allocation and push descriptors to environment variables

- Query support for dedicated allocation and push descriptors along
  with the rest of the device support.  Move the options to disable
  their use from compile-time variables to environment variables
  `TVM_VULKAN_DISABLE_PUSH_DESCRIPTOR` and
  `TVM_VULKAN_DISABLE_DEDICATED_ALLOCATION`.

* [Vulkan] Move option for vulkan validation layers to environment variable

- Moved to enable faster use as a debug tool.  If
  `TVM_VULKAN_ENABLE_VALIDATION_LAYERS` is a non-empty string,
  validation layers will be enabled.

* [Vulkan] Explicitly enable vulkan features in device creation

- Vulkan requires that features be explicitly enabled before use.  For
  each feature that the device supports and a shader might use,
  declare it in the call to `vkCreateDevice`.

* [Vulkan] Avoid repeated queries for device attributes.

- Implement `VulkanDeviceAPI::GetAttr` based on the per-device values
  stored in the Target.  This pulls all logic for querying device
  parameters is in a single location.

* [Vulkan] Implement "from_device" flag for the vulkan target.

- With the number of device capabilities that may or may not be
  supported by a vulkan driver, it can be tedious to input them.
  Specifying "-from_device=0" now indicate that any unspecified values
  should be read from the device.

* [Vulkan][Codegen] Read vulkan device capabilities/limits from Target

- Previously, the codegen assumed that all device features were
  present.  Now, the codegen reads device capabilities from the
  Target, and throws an error if codegen would require use of an
  unsupported feature.

Co-authored-by: Eric Lunderberg <elunderberg@octoml.ai>
2021-05-26 23:50:24 +09:00
Junru Shao 03c8a6f461 [TensorIR][M2a] Structural Error Reporting (#8121)
This PR is part of the TensorIR upstreaming effort (#7527), stage M2a.

In this PR, we implemented ScheduleError, an error reporting mechanism for schedule primitives to report user-face error messages, with the functionality of rendering the TIR out in the TVM script syntax.

This set of APIs allows future improvement of error location rendering, e.g. more colorful rendering mechanisms like synr does.

Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Wuwei Lin <wuwei@apache.org>
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>

Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Wuwei Lin <wuwei@apache.org>
Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>
2021-05-25 18:50:14 -04:00
Zilin Zhu 6f82e98aac [Relay][PRNG] Support generating data of any shape in threefry_generate (#8085) 2021-05-25 10:44:45 -04:00
Gustavo Romero 7da97b9c91 [TVMC] Add support for the MLF to 'compile' command (#8086)
* [TVMC] Add support for the MLF to 'compile' command

Add support for the Model Library Format (MLF) to 'tvmc' so users can
output compilation artifacts to a MLF archive passing the new flag
'--output-format mlf'. For instance:

$ python3 -m tvm.driver.tvmc compile ./sine_model.tflite --target="c" --output sine.tar --output-format mlf

will generate a sine.tar archive that is serialized accordingly to the
MLF.

Since the MLF is currently meant to be used only on micro targets, an
error is generated if one tries to run a MLF outside a micro context.

The micro context does not exist yet but will be later introduced as
part of the [RFC] "TVMC: Add support for µTVM".

That commit also adds 3 pytest tests to test tvmc + MLF.

Finally, it also fixes some missing periods in the 'compile' command
help sections and renames export_format to output_format so there is
no confusion with flag '--dump-code', which contains "formats to export"
in its help section.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* Fix missing importorskip in the import_package test

Fix missing importorskip() in the import_package test allowing the
test in question to be skipped when 'tflite' is not installed in the
test environment, otherwise the test will fail with:

[...]
>       archive_path = exported_tvmc_package.package_path
E       AttributeError: 'str' object has no attribute 'package_path'
2021-05-25 14:13:38 +01:00
hzshao 0cf7ac3e43 [Relay][TOPI] Fix compute and schedule bugs for conv2d_winograd_nhwc on mali device. (#8091)
1. add argument `auto_scheduler_rewritten_layout=""` in conv2d_winograd_nhwc_mali;
2. add `need_auto_scheduler_layout=True` for conv2d_strategy_mali and
conv2d_winograd_without_weight_transfrom_strategy_mali.

Signed-off-by: haizhu.shao <haizhu.shao@gmail.com>
2021-05-25 16:45:47 +08:00
Rohan Mukherjee 65cd19facf [Frontend] [Tensorflow2] Added test infrastructure for TF2 frozen models (#8074)
* added test infrastructure for frozen TF2 models

* linting with black

* removing some comments

* change in comment in sequential test

* addressed the comments

* refactored to place vmobj_to_list in a common file

* Added helper function in python/tvm/relay/testing/tf.py

Co-authored-by: David Huang <davhuan@amazon.com>
Co-authored-by: Rohan Mukherjee <mukrohan@amazon.com>
Co-authored-by: Xiao <weix@amazon.com>

* Refactor tf according to CI error

Co-authored-by: David Huang <davhuan@amazon.com>
Co-authored-by: Rohan Mukherjee <mukrohan@amazon.com>
Co-authored-by: Xiao <weix@amazon.com>

* Added docstring

Co-authored-by: David Huang <davhuan@amazon.com>
Co-authored-by: Rohan Mukherjee <mukrohan@amazon.com>
Co-authored-by: Xiao <weix@amazon.com>

* removing print

Co-authored-by: David Huang <davhuan@amazon.com>
Co-authored-by: Xiao <weix@amazon.com>
2021-05-24 21:39:17 -07:00
Junru Shao 47c8e47a48 [TensorIR][M2a] Verification of cached flags (#8114)
* [TensorIR][M2a] Verification of cached flags

Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Wuwei Lin <wuwei@apache.org>

* Address comments

* Update src/tir/schedule/analysis/verify.cc

Co-authored-by: Cody Yu <comaniac0422@gmail.com>

Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
Co-authored-by: Bohan Hou <32121147+spectrometerHBH@users.noreply.github.com>
Co-authored-by: Ruihang Lai <lairuihangdongdong@qq.com>
Co-authored-by: Hongyi Jin <3231950289@qq.com>
Co-authored-by: Wuwei Lin <wuwei@apache.org>
Co-authored-by: Cody Yu <comaniac0422@gmail.com>
2021-05-24 17:08:58 -07:00
Muyang Li d8fd5bd6bb Fix some typos (#8101)
* fix bugs in the auto scheduler record:

* reformat the code

* reformat the code

* use the os.path.abspath

* change error to warning

* reformat the warning code

* fix some typos

* fix some typos

* fix some typos

* fix the port number typo
2021-05-21 09:30:02 -07:00
Rafael Stahl 3b8715df7e doc: fix description of stop_fusion annotation (#8095) 2021-05-21 09:28:46 -04:00
Haichen Shen 720e7b1ebd [Refactor] Rename asnumpy -> numpy in NDArray (#8083) 2021-05-21 08:32:27 -04:00
Vincent Abriou 5a7c08154b [TVMC] add the support of the cross compiler options (#7922)
Add the possibility to provide the cross compiler options when using the
tvmc compile functionality.
With some cross compiler, toolchains --sysroot option (at least) need to be
defined.

tvmc/test_compile.py as been updated to introduce simple tests to validate
the cross options functionnality.

Signed-off-by: Vincent ABRIOU <vincent.abriou@st.com>
2021-05-21 13:22:27 +01:00
masahi 0d38a92bcf [Relay, ONNX] Support gather_nd batch_dims attribute for TF/ONNX (#8084)
* Add GatherND batch_dim support

* adding tests

* test working

* improved reference code

* refactor ref func

* batch dim 2 tests from tf all passed

* batch_dim -> batch_dims

* add example

* minor change

* add onnx test

* fix onnx version

* fix lint

* remove move on batch_dims

* fix pylint

* fix compiler warning

* add shape constraint for batch_dim and update doc

* make the output shape doc clearer
2021-05-21 13:50:49 +09:00
Zilin Zhu e438a739a7 [Relay][PRNG] Add uniform distribution generator wrt threefry PRNG (#8041)
* Add uniform distribution generator wrt threefry PRNG

* fix lint

* remove the redundant print

* modifications based on review

* update docs

* update uniform algorithm to use bit operations only

* add type restrictions

* minor fix upon review

* update test and error information
2021-05-21 11:15:21 +08:00
Tristan Konolige 28ea03c83b [TOPI] Custom schedule for standalone transpose in cuda (#8030)
* [TOPI] Custom schedule for standalone transpose in cuda

* check if input is not Any

* fix vta test

* check input shape

* fix injective

* move transpose out of sparse.py

* update comments, use warp size

* missspelled transform

* formatting

* rename test

* comment

* fix tests
2021-05-20 16:59:07 -07:00
Nicola Lancellotti ec3b16094b Add support for the quantized TANH operator to relay TFLite frontend (#8024)
Change-Id: I70df765e1562fa586ed0ffd0e07b8858f7fbb831
2021-05-20 14:03:51 +01:00
Siyuan Feng 1203d732d4 [TensorIR] change IntRV to ExprRV (#8077) 2021-05-20 08:20:42 -04:00
masahi 0d96f9553e [Relay, TOPI] Support dynamic slicing on first few axes, keeping the rest static (#8068)
* Supporting dynamic slice on first few axes

* fix index normalization

* update dynamic slice tests

* pylint fix

* fix loop index dtype

* fix more dtype issue
2021-05-20 11:06:39 +09:00
apeskov 052231969b Custom dyld linker for iOS mach-o executable files (#7875)
* [IOS-RPC] Fix compilation iOS_PRC app

Signed-off-by: Alexander Peskov <peskovnn@gmail.com>
2021-05-19 12:22:44 -04:00
liyuchao 17bbf02095 [Autoscheduler] Add sparse conv2d(1*1) support for auto_scheduler (#8065)
* add sparse conv2d support for auto_scheduler

* add description

* fix bug

* fix annotation

* Lint fix

Co-authored-by: laiyin.lyc <laiyin.lyc@alibaba-inc.com>
2021-05-19 18:52:56 +08:00
Muyang Li 53c3456095 [AutoScheduler] Make RecordReader error-free (#8066)
* fix bugs in the auto scheduler record:

* reformat the code

* reformat the code

* use the os.path.abspath

* change error to warning

* reformat the warning code
2021-05-19 18:50:35 +08:00
Trevor Morris e8045b1f2b Only allow 4d or 5d inputs to TRT nn.pad (#8073) 2021-05-19 14:11:33 +08:00
Tristan Konolige 476f0ff13f [CONTAINER] Add default python iterator for Map. (#8061)
* [CONTAINER] Add default python iterator for Map.

* formatting

* add keys(), values()
2021-05-19 14:10:53 +08:00
Krzysztof Parzyszek 94f009ee9f [Frontend][TFLite] Use axis.size instead of len(axis) (#8060)
The variable axis is an ndarray.
2021-05-18 18:30:00 -04:00
Trevor Morris 93f3010593 Move infer_value to _get_list_param (#8051) 2021-05-18 14:25:25 -07:00
Chris Sullivan c510c2b72e [IR] Add storage scope to PointerType (#8017)
* Add storage scope to PointerType.

* Apply suggestions from code review

Co-authored-by: Siyuan Feng <Hzfengsy@sjtu.edu.cn>
2021-05-18 09:27:00 -04:00
XuanAnyvision 365484e054 allow module exits without del (#8063) 2021-05-18 08:58:56 -04:00
Andrey Malyshev f3b1586f53 Fix recast of relay ops without attributes (#8043)
* Fix recast of ops without attributes

* fix test for pylint pass
2021-05-17 09:05:32 -07:00
Siyuan Feng 711a603db8 [TensorIR][M1c] Lower and build TensorIR (#8044) 2021-05-15 16:35:17 -04:00
Yuchen Jin c083ac73d8 [Tests] Fix requires_gpu (#8050) 2021-05-15 10:33:03 -04:00
Tianqi Chen dfe4cebbda [RUNTIME] Improve signal handling in python env. (#7919)
* [RUNTIME] Improve signal handling in python env.

Python execution environment handles the signal by caching
the signal a state and invokes the handler when execution
goes into the python interpreter.

This model can cause problem when runnning a long running
c++ function. As keyboard interrupt can only be caught in the end.

Additionally, because python registered special signal handlers.
Socket operations can return EINTR that needs to be explicitly
retried when the interrupt is not a KeyboardInterrupt.

This PR adds the following changes to resolve these problems.

- Allow execution env(python) to register CheckSignals function
  to the TVM runtime.
- Add runtime::EnvCheckSignals to check the signal error.
- Add retry when EINTR is encountered in socket.
- Register the python C API functions in cython mode.

To testout the EnvCheckSignals, run the following code

```python
import tvm.testing
tvm.testing.run_check_signal(10)
```

Note that the C API functions are only registered in cython FFI mode
because ctypes have problems invoking these functions. This however
won't affect the correctness, but will defer the interrupt handling
to function return sites.

Co-authored-by: Andrew Reusch <areusch@octoml.ai>
Co-authored-by: Robert Kimball <bobkimball@gmail.com>

* Address comments

* Alternative implementation that preserves python exception.

* Address comments

* Update check signals

Co-authored-by: Andrew Reusch <areusch@octoml.ai>
Co-authored-by: Robert Kimball <bobkimball@gmail.com>
2021-05-14 21:17:14 -04:00
chiwwang e52b8172e9 Fix AttributeError when TEST_DATA_ROOT_PATH is set (#8047)
Initiate a Path object from TEST_DATA_ROOT_PATH to fix the error:
AttributeError: 'str' object has no attribute 'mkdir'
2021-05-14 17:51:23 -04:00
Jeffrey-Sima aa7bfe73d9 Pytorch Conv Transpose Padding Fix (#7958)
* fix conv transpose import from TF

* fix String::fromwe() to String::from()

* * fixing pytorch converter to take into account the output_padding parameter for conv transpose operations
* updating pytorch converter to correctly convert conv1d to conv1d in tvm inestead of a flattened conv2d unless under circumstances of grouped convolution
* updating pytorch converter to correctly convert conv1d transpose to conv1d transpose in tvm instead of a flattened conv2d transpose
* added tests to cover these latest additions

* * removing print statements used for debugging

* * fixing typos and formatting

* * fixing formatting

* * fixing grammar

* * formatting fixes

* * updated formatting after running pylint and python_format checks

Co-authored-by: Mikael Sevenier <mikael.sevenier@sima.ai>
2021-05-15 06:34:25 +09:00
Manupa Karunaratne 9272c023a9 [uTVM][AOT] Adding workspace byte alignment (#8019)
* Adding workspace byte alignment

* This commit adds byte alignment support for workspaces
* Updating AoT tests to use calculate workspaces

Change-Id: I88380d875269e1ffa4a51a9cceefd51b3042f1a7

* Adding workspace byte alignment

* fixed aot_memory cpp tests
* add new error type for stack allocator bad frees

Change-Id: Iadb4770ac761ef5edb80308e18120443d269c83d

* Adding workspace byte alignment

* addressing comments + LIFO change

Change-Id: I1e8ad47e11e220f879bf936da2abb3d111db89f0

* Adding workspace byte alignment

* addressing comments further

Change-Id: Idb07d28b55520d8897d7dbcb9ef4aad5e3e7b35c

* Adding workspace byte alignment

* addressing comments - add a default constant to alignment

Change-Id: Id3f486bfdc0bd57d54b3c4097885cb54675196ca
2021-05-14 10:54:12 -07:00
Nadav Eidelstein 6069a70760 Fix minor issues in the tvmc tune CLI (#8039)
* [TVMC] convert timeout flag to int

fixes Check failed: type_code_ == kDLInt (11 vs. 0) : expected int but got str
when setting the timeout option using the cli flag.

* [TVMC] fix typo in tvmc tune help
2021-05-14 10:07:06 -07:00
Yuchen Jin bd7cda9ad9 Rename gpu to cuda in java/rust/typescript (#8036)
* rename gpu to cuda in java/rust/typescript

* fix rpc test to call cuda
2021-05-14 08:07:45 -04:00
Josh Fromm c999a840cb [Relay][AlterOpLayout] Fix strided slice type change. (#8022)
* Fixed strided_slice alteroplayout bug.

* add test for non standard int8 conv2d padding.

* Add test for large index slices.

* Us same dtype as input in strided slice.
2021-05-13 10:26:27 -06:00
LiangLiu 158aeddd7f [ONNX] QLinearConv Support (#8007)
* Add QLinearConv for onnx frontend

* Reformat

* Squeeze 1D tensor for weight_scale & weight_zero_point

* Doing dequatize -> quantize if y_scale is not constant
2021-05-13 09:58:27 -06:00
Robert Kimball b81f3f7a7f Remove warning which is adding too much noise (#7975) 2021-05-13 10:00:15 -04:00
Zilin Zhu 39fa759906 fix docs of threefry_split and threefry_generate (#8035) 2021-05-13 09:22:07 -04:00
Yuchen Jin 43c2ea72bc Rename gpu to cuda, and bump dlpack to v0.5 (#8032) 2021-05-13 09:11:40 -04:00