Commit Graph

3773 Commits

Author SHA1 Message Date
Krzysztof Parzyszek cf15375e20 Several type mismatch fixes and checks (#12041)
* Compute common type for shape elements in BroadcastHelper

The corresponding dimensions in the input/output tensors in a broadcast
operations may have the same value, but different types (e.g. int32 vs
int64).
When the broadcast helper tries to unify the dimensions it also needs
to compute the common type to hold the dimension.

* Cast and simplify both members of `Range`

Only the `min` member was type-casted, which could lead to ranges with
different types for `min` and `extent`.
Move the casts to the argument of Simplify, so that they can be eliminated
if they aren't needed.

* Type-check iv domain ranges, use cast only if needed in MakeLoopNest

In some cases the domain ranges had the `min` and the `extent` values
be of different types (e.g. [(int64)0, 32)). This is an error, and it
can lead to compilation failures later on. Add a check for equal types
here to catch this early.
Also, only add the cast operation when the desired type differs from
the current one to keep the expressions simpler.

* Check that variable and substituted expression have same types

Add a check to IRSubstitute to detect when the type of a variable and
the type of the expression to replace it with have different types.

* Add testcase

* [TVMScript] Use void for lambda parameters, allow mismatch in Substitute

When the script parser deals with lambdas, it creates Var objects for each
parameter. Their actual types are not known at the time, and the properly
typed variables are subtituted in the body later. Since the default dtype
of a Var is "int32", this could lead to a type mismatch in Substitute.
To deal with this scenario, use "void" for newly created Vars in the
parser, and add an exception to Substitute to allow replacing void Vars
with expressions of any type.

* Fix type error in test_reduce_combiner_simplify

* Restart CI

Co-authored-by: Jiawei Liu <jaway.liu@gmail.com>
2022-07-11 10:05:21 +09:00
Ivy Zhang 927620e20f [BYOC-DNNL] support more post-ops (#12002)
* support post-op swish

* support post-op clip

* enhance get_shape and get_dtype in dnnl.py to support efficientnet

* add checks for with_eltwise whether in supported list

* fix lint

* fix test
2022-07-11 09:55:57 +09:00
Junru Shao 99d42b2238 [MetaSchedule][Testing] Test search space of conv1d (#12032)
* [MetaSchedule][Testing] Test search space of conv1d

* Add checks for trace roundtripping
2022-07-07 14:05:59 -07:00
Xiyou Zhou 013d5e8fcb [MetaSchedule][Minor] Stability Improvements (#12014)
* Fix tuning util for uint8.

* Change to check runner_result.

* Revert change to let cost model learn.
2022-07-07 12:44:18 -07:00
Zhengqiang Yin af4373f2fb [Fix] fix python setup.py file bug (#12000)
* fix setup.py bug

Signed-off-by: Zhengqiang Yin <codle@outlook.com>

* remove data_files field

* keep a init setup_kwargs
2022-07-07 14:38:27 -05:00
abhikran-quic c76d8e2bdb [TOPI] [Hexagon] Reshape slice op (#11983)
* Reshape slice op. This patch adds the initial python implementation reshape slice op for hexagon.

* Add tests for reshape op
2022-07-07 11:19:01 -07:00
Xiyou Zhou 7874bf806e [MetaSchedule] Support ApplyHistoryBest Direct Dispatch (#12016)
This PR introduced a new argument for `ApplyHistoryBest`'s `Query` interface to allow direct dispatch without querying the database, would be useful for debugging and benchmarking without interference.
2022-07-07 09:31:41 -07:00
yuanfz 40d242a3c8 [Pytorch] add aten::rnn_tanh, aten::rnn_relu (#12017)
* emptycommit 2nd try

* dev

* comments

* format

* format

Co-authored-by: yuanfz <42092999+FZYUAN-1@users.noreply.github.com>
2022-07-07 15:37:48 +09:00
Lite Ye 9f4bf38b57 [TVMScript] Doc Base Class & DocPrinter Scaffolding (#11971)
This PR addes:
- Doc base class
- DocPrinter base class
- PythonDocPrinter
- LiteralDoc and its support in DocPrinter

Tracking issue: #11912
2022-07-06 22:11:10 -07:00
Luke Hutton cfe8318990 [microNPU] Calculate memory pressure for microNPU external functions (#11209)
* [microNPU] Calculate memory pressure for microNPU external functions

During the microNPU compilation stage, the "used_memory" annotations on
external microNPU functions are read to determine a memory pressure
value. This value is passed to the cascader to better approximate the
memory available for the optimization.

Change-Id: I11a311b0005e785637014cb451f4aed96edcda26

* fix get size from memory region

Change-Id: I41acfc83f05b2204075edb99f86a0eecaba00f71

* add test case for full offload

Change-Id: If3e672d402ab237fa82e34761bb972d2e9483ba9
2022-07-06 16:46:29 +01:00
Anirudh Sundar 95f578912f [Topi] [Hexagon] Conv2d slice op initial version (#11489) 2022-07-06 09:52:44 -05:00
Yuanjing Shi 5bc6684c9d add aten::randn (#11994) 2022-07-06 09:11:57 +09:00
Gavin Uberti 3cca6465ba [microTVM] Autotuning performance tests (#11782)
* Common autotuning test

* Autotuned model evaluation utilities

* Bugfixes and more enablement

* Working autotune profiling test

* Refactoring based on PR comments

Bugfixes to get tests passing

Refactor to remove tflite model for consistency

Black formatting

Linting and bugfixes

Add Apache license header

Use larger chunk size to read files

Explicitly specify LRU cache size for compatibility with Python 3.7

Pass platform to microTVM common tests

Better comment for runtime bound

Stop directory from being removed after session creation

* Use the actual Zephyr timing library

Use unsigned integer

Additional logging

Try negation

Try 64 bit timer

Use Zephyr's timing library

Fix linting

Enable timing utilities
2022-07-05 10:36:26 -07:00
Ivy Zhang b7e299f4a4 [BYOC-DNNL]rewrite downsize blocks for rensetv1 to get better performance (#11822)
* rewrite downsize blocks for rensetv1 to get better performance

* fix lint
2022-07-05 16:41:25 +09:00
Black 83b310d5a4 [Frontend][TFLite] Add support for NonMaxSuppressionV5 op (#12003)
* add nms_v5 op for TFLite

* add a test for the TFLite nms_v5 op
2022-07-05 15:17:16 +09:00
Andrey Malyshev ef08c36294 [Adreno] Modify default AutoTVM params for conv2d (#12005) 2022-07-05 13:04:02 +09:00
Junru Shao f8186d8c7d [TIR] Add sugar method Schedule.work_on (#11999)
This PR introduces `Schedule.work_on`, which instructs
`Schedule.get_block` to find the correct PrimFunc to retrieve from
without having to specify `func_name` in every time if the PrimFunc's
name is not `main`.
2022-07-03 13:16:18 -07:00
Yuanjing Shi 1787cca3f9 [Relay] [PyTorch] Add aten::tril and aten::triu (#11890)
* add trilu

* update triu and tril; fix empty

* fix lint
2022-07-02 07:24:52 +09:00
Mark Shields d2a14a6880 [BYOC] Switch TensorRT BYOC integration to IRModule-at-a-time using RelayToTIR hook (#11979)
* [BYOC] Switch TensorRT BYOC integration to IRModule-at-a-time using RelayToTIR hook

This does for the TensorRT integration what #11631 did for the CUTLASS integration.

- All compilation options are captured within the attributes of a Target of
  kind "tensorrt" (instead of the "relay.ext.tensorrt.options" attribute in
  PassContext). This means all BYOC configurations options needed by Collage can
  be captured uniformly by a list-of-Targets. It also means RPC boundaries (as used
  internally at OctoML) only need to worry about maintaining the fidelity of the
  Target instance(s) rather than reaching into the PassContext.

- Compilation is switched from function-at-a-time (relying on the TECompiler) to
  IRModule-at-a-time (using the RelayToTIR target-specific hook mechanism). Though
  not strictly necessary for Collage I want to check the path is now clear to
  deprecate the support for BYOC in TEComplier.

- Get all the TensorRT tests going again, except for a few I've disabled with
  x-link to a new issue #11765. CAUTION: The TensorRT runtime is not supported in
  CI so many of these tests are cosmetic.

- While trying to track down a 'free(): invalid pointer' error in test_tensorrt_int8_exp.py
  made the TensorRT allocs/frees more robust, but turns out its also broken in main.
  No harm leaving these changes in though.

* - Lints

* - Woops, fix test

* - lints

* - Use default tensorrt target if none given in targets list

* - fix free error

* - accidentally introduced 'transforms' namespace
- can't use default Target("tensorrt") arg

* - D'oh! Include ended up #if protected

* - restore mark for test_dynamic_offload
- handle missing runtime in versioning
- turn test_maskrcnn_resnet50 back on now that we have the
  import-torch-first workaround.

* - wibble
2022-07-02 07:09:06 +09:00
joshherr-quic 50cd4d635c [Hexagon] Enable int8 vlut codegen for Relay take (LUT) operator (#11693)
* Working 8 bit vlut for relay take operator

* Formatting

* More formatting

* clang-format on codegen_hexagon.cc

* Update for llvm api

* Add return to VisitExpr(BufferLoadNode) function

* different llvm api
2022-07-01 15:50:35 -05:00
Krzysztof Parzyszek c97895e0ff [Hexagon] Fix use of subprocess.run in _check_call_verbose (#11985)
It uses parameters that are not present in Python 3.6, plus it
catches generic exception, which may not have `stdout` or `stderr`
members.
2022-07-01 14:00:43 -05:00
xndcn 2f8b008730 [tests] Fix changed var name from 'target_str' to 'target_names', NFC (#11982) 2022-07-01 17:06:51 +01:00
Kathryn (Jinqi) Chen 395e91ff54 [MetaSchedule] Extract workload embedding (#11975)
This PR enables extracting the embeddings of the workload in a tuning context, which further strengthens the feature extracting process. Workload embeddings are extracted based on names of each block in the IR module. If `extract_workload` is enabled, the extracted feature vectors will have length 164 + 8 = 172.
2022-06-30 19:36:13 -07:00
Yuanjing Shi ec39199edb [PyTorch] [Relay] Add l1 and mse loss function for pytorch frontend (#11978)
* add l1 and mse loss function for pytorch frontend

* fix CI
2022-07-01 09:07:43 +09:00
Junru Shao beea0d2d6a [MetaSchedule] Fix Task Extraction (#11954) 2022-06-30 16:24:42 -07:00
Florin Blanaru 288b983b82 [CI] Skip some additional tests that are failing in the wheel (#11969)
This PR skips some additional tests that are failing in the nightly wheel.
2022-06-30 12:50:21 -07:00
Mark Shields 985680ee1a [BYOC] Handle constants in IRModule-at-a-time external codegen (#11770)
I tried to do to the TensorRT integration what #11631 did to the CUTLASS integration, viz:
 - Make sure all compilation options are passed in Target instances. This helps Collage.
 - Use a custom pass invoked via RelayToTIRTargetHooks instead of the relay.ext.$toolchain mechanism.
   This helps use decouple external codegen from lowering.

This PR collects the prep for that change:
 - TensorRT uses the JSONSerializer visitor to encode each partition function. Previously, when the
   visitor encountered a Constant it simply generated and recorded a name for the constant. Then,
   completely separately, and via a callback in TECompiler, the function is visited again in the
   same order and with the same name generation convention by a ConstantUpdater to actually collect the
   bindings, which are then encoded into a ConstLoaderModule to be made available at runtime.

   However if all TensorRT compilation is to be done by a stand-alone pass there's no TECompiler callback
   hackery available. So I've added a "const_name_to_ndarray" attribute to the IRModule of type
   Map<String, runtime::NDArray> so that named constants can be accumulated throughout compilation by
   any pass which needs to do so. Then the Graph, AOT and VM executors are all updated to merge those
   constants into the final runtime artifact

   (Compare with "Constants", the equivalent attribute for extracting TIR AllocateConsts.)

 - The TensorRT tests use the create_executor interface but it wasn't quite ready for the
   new more general form of passing list-of-targets.

 - I want TensorRT compilation to work out of the box without the need for any special targets if
   all the default options should apply. Go back and make the CUTLASS integration I did follow the
   same convention.

 - To test this I also switched the 'demo' "ccompiler" external codegen target to IRModule-at-a-time
   style. This means we can test most of external codegen machinery in one place without depending on
   any target which may not be enabled in CI (eg TensorRT):
     - Target instances are plumbed correctly so compile-time options are available.
     - External modules are conveyed to the final export library.
     - Constant bindings are conveyed to the metadata module.
2022-06-30 10:27:21 -07:00
driazati c0f4bf72b6 [ci] Redirect sphinx-gallery URLs to S3 (#11839)
Co-authored-by: driazati <driazati@users.noreply.github.com>
2022-06-30 09:10:12 -07:00
abhikran-quic 915c23b61b [TOPI] [Hexagon] Batch flatten slice op initial version (#11522)
* [TOPI] [Hexagon] Batch flatten slice op initial version

* Fix lint errors

* Fix more lint errors

* Fix lint warnings

* Fix review comments

* Update tests to use util functions

* Update __init__.py

* Fix review comments
2022-06-30 09:36:27 -05:00
Luke Hutton 80a0c6c53d [microNPU] Fix offloading incompatible average pool (#11469)
Fixes offloading a few corner cases of average pooling. Specifically
not offloading nn.avg_pool2d when:
* The attribute count_include_pad=True
* Padding exceeds the dimensions [3, 3, 4, 4]
* The pool size is greater than [8, 8] when the pool uses padding

Change-Id: I7be546e28ebe1f17482f3ed3cee56996a71bfcd1
2022-06-30 13:40:09 +01:00
TerranceLiang 522c8cc955 typo fix (#11958)
Co-authored-by: Terrance Liang <tailin.liang@outlook.com>
2022-06-30 00:15:26 -07:00
Xiyou Zhou 558ba99c7c [MetaSchedule] Tuning Script Upgrade (#11797)
* Support uint8.

* Modify tuning functions.

* Follow legacy setting, use int32 for uint8.

* Add vm support.

* Fix vm usage.

* Use vm in rpc run module.

* Fix lint & stuff.

* Fix backend.

* Fix ftimer.

* Fix lint.

* Limit backend choice.

* Add try catch.

* Display name in rpc try catch.

* Support ahb from tune_relay.

* Modify scripts.

* Fix typo.

* Minor fix.

* Fix try catch & func name.

* Fix utils.

* Move utils to tune_utils.

* Fix tune_utils.
2022-06-29 21:11:41 -07:00
Altan Haan 898946fec6 support any shape and axis for log softmax (#11951) 2022-06-30 09:43:48 +09:00
Yuanjing Shi 41c94b27ef [Relay][Pytorch] Add aten::new_ones, aten::new_full, aten::fill_, aten::pad, aten::reshape_as and atem::empty_like (#11896)
* add new ops

* fix pad

* fix pad

* remove pad

* fix CI

* remove doc

* fix fill_

* add tests
2022-06-30 08:53:36 +09:00
Xiyou Zhou da2ad2d44b [RPC] Add Data & Time For RPC Tracker / Server Logging (#11950) 2022-06-29 15:07:38 -07:00
arangasa a84c54efe5 [TOPI][Hexagon] Implement Argmax Slice Op (#11847)
* [TOPI][Hexagon] Implement Argmax Slice Op

* run through black

* Address initial review comments

* Fix variable names in tests

* Fix lint issue

Co-authored-by: arangasa (generated by with_the_same_user script) <arangasa@hu-arangasa-hyd.qualcomm.com>
2022-06-29 14:22:35 -07:00
Christian Convey b552bcf1d0 [testing][hexagon] Better subproc errors (#11853)
When a subprocess completes with a non-zero exit code, include
its stdout and stderr text in the Python exception's error message.
2022-06-29 14:20:31 -07:00
Yuanjing Shi a7b89071c7 [PyTorch][Relay] Add aten::cross_entropy_loss (#11935)
* add cross entropy loss

* fix cross entropy args

* fix typo

* add class indices

* fix CI

* fix naming

* fix typo
2022-06-30 04:02:18 +09:00
Mark Shields a17bfc05cc [Relay] CaptureIndexInSpans debugging pass (#11926)
* [Relay] CaptureIndexInSpans debugging pass

This pass will update (most) expression nodes to capture their post-dfs
indexes. That makes it easy to connect pretty-printed fragments back to
the overall model, and is very handy for Collage which uses post-dfs indexes
extensively.

* - rename
- add header decl
2022-06-29 08:05:18 +09:00
Rafael Stahl 6c433d2309 [Relay][VirtualDevice] Expose WithFields to Python to do proper copy in ExprMutator (#11882)
* [Relay][VirtualDevice] Expose WithFields to Python to do proper copy in ExprMutator

* [Relay] give FunctionWithFields optional arguments

* [lint] fix wrong line length

* [lint] missing newline

* [doc] add doc string to FunctionWithFields
2022-06-29 04:07:45 +09:00
Xiyou Zhou 0e23122846 [MetaSchedule] Enable Adapative Training For XGBoost Cost Model (#11892)
CostModel retraining is a time consuming part for MetaSchedule tuning, similar to AutoScheduler, we can alleviate it with an adapative way of increasing waiting period between each retraining. This PR introduced an argument called `adpative_training` in `TuneConfig` and the constructor of `XGBoostModel` to enable the capability. Testing tuning scripts are also updated.
2022-06-28 11:04:13 -07:00
zhaoyang-star 97b3076c35 [QNN] Add hardswish int8 impl using table lookup (#11700)
* v1

* [QNN] Add hardswish int8 impl using table lookup

* format

* format

* fix

* fix utest

* fix ci error

* jostle ci

* triggle ci

* remote nn

* jostle ci

* fix
2022-06-28 10:10:51 -07:00
Alexey Voronov 6c8a353099 Add cooldown interval logic for the profiling functional (#11465)
* Add cooldown interval logic for the profiling functional.

* Remove string serialize hack from RunIndividual functions

* Update src/runtime/graph_executor/debug/graph_executor_debug.cc

Co-authored-by: Tristan Konolige <tristan.konolige@gmail.com>
2022-06-28 09:10:09 -07:00
Manupa Karunaratne b733aa3ec8 [microNPU] enable striping for network tests. (#11883)
This commit enables the striping for network tests.
Currently it requires, storage_rewrite to be run if
striping is enabled to produce correct results.

Change-Id: I12b976bb77d339771f8b5a554817d192e7c99723
2022-06-28 16:47:40 +01:00
Dmitriy Smirnov 08723d0ce6 [usmp] U3 use case (#11015)
* U3

Change-Id: Ibc088f19ad1dc9466fc368f8523baa30ee88b7d0

* addressed upstream comments

* Unit test added

Added unit test for InterfaceCNode::EmitConstantPool method
2022-06-28 12:02:21 +01:00
Sergey c87ebefcfd Concatenation corner case fix. (#11907)
* Concatenation corner case fix.

* lint fixes.
2022-06-28 18:22:07 +09:00
Egor Churaev 39ce4d985e [OpenCL] Change winograd priority and extend split (#11908) 2022-06-28 15:52:32 +09:00
Qianshui a063404812 [DNNL] Add bfloat16 type support for dnnl conv2d kernel (#11902) 2022-06-27 20:16:20 -07:00
Yuanjing Shi 993f72877d [PyTorch] [Relay] Add aten::pad (#11922)
* add aten::pad

* fix

* fix CI
2022-06-28 09:13:10 +09:00
Mark Shields 62b21a18a8 [BYOC] InlineCompilerFunctions helper pass (#11923)
* [BYOC] InlineCompilerFunctions helper pass

The TensorRT BYOC integration needs to 'undo' partitionings in some situations. Add an
InlineCompilerFunctions pass to make that robust. In particular, it must undo both the
'partitioning' (ie separating out the "Compiler" function) and any 'compositing' (ie separating
out small sub-graphs as "Composite" functions).

Fix misspelled nn.bias_add while there.

Note that the current implementation is broken but untested in CI. I have all the tests
fixed in a follow-up PR.

* - Lints

* - Only AOT compilation paths ensure "executor" is provided as a Target attribute.
2022-06-28 07:48:47 +09:00