You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/06/24 12:14:50 UTC
[GitHub] [tvm] rafzi opened a new pull request, #11880: [USMP] Improve algorithm extensibility
rafzi opened a new pull request, #11880:
URL: https://github.com/apache/tvm/pull/11880
This allows a user to easily provide a registered TVM function for example on the Python side and have it accessible to USMP without changing any C++ code and recompiling.
The existing algorithms are already registered functions.
@manupa-arm @d-smirnov
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] manupa-arm commented on pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
manupa-arm commented on PR #11880:
URL: https://github.com/apache/tvm/pull/11880#issuecomment-1168840672
Thanks @rafzi!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] manupa-arm commented on pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
manupa-arm commented on PR #11880:
URL: https://github.com/apache/tvm/pull/11880#issuecomment-1167293678
I think we need a test too.
Maybe some bespoke fixed assignment algorithm to showcase this user facing functionality is working ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] manupa-arm commented on pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
manupa-arm commented on PR #11880:
URL: https://github.com/apache/tvm/pull/11880#issuecomment-1167787946
@rafzi the test LGTM!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] manupa-arm merged pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
manupa-arm merged PR #11880:
URL: https://github.com/apache/tvm/pull/11880
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] driazati commented on pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
driazati commented on PR #11880:
URL: https://github.com/apache/tvm/pull/11880#issuecomment-1167527694
@tvm-bot rerun
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] manupa-arm commented on pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
manupa-arm commented on PR #11880:
URL: https://github.com/apache/tvm/pull/11880#issuecomment-1167059873
Hi @rafzi,
Alright, that seems reasonable. sg!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] rafzi commented on pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
rafzi commented on PR #11880:
URL: https://github.com/apache/tvm/pull/11880#issuecomment-1166356065
@manupa-arm Thank you for your swift feedback.
Do you mean something like this?
```
transform::PassContext::Current()->GetConfig<PackedFunc>("tir.usmp.algo.custom")
```
Unfortunately that would not work with TVMC out-of-the-box, because it only maps these config types:
https://github.com/apache/tvm/blob/main/python/tvm/driver/tvmc/pass_config.py#L150
However we could work around that as follows:
```
Optional<String> opt_custom_algo = transform::PassContext::Current()->GetConfig<String>("tir.usmp.algo.custom");
if (opt_custom_algo) {
String algo_func_name = "tir.usmp.algo." + opt_custom_algo.value();
const runtime::PackedFunc* pfAlgo = runtime::Registry::Get(algo_func_name);
// ...
} else {
// existing map lookup
}
```
That way we only interact with packed functions when the user explicitly requested it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] rafzi commented on pull request #11880: [USMP] Improve algorithm extensibility
Posted by GitBox <gi...@apache.org>.
rafzi commented on PR #11880:
URL: https://github.com/apache/tvm/pull/11880#issuecomment-1167499812
How about the following in the file "tests/python/unittest/test_tir_usmp_algo.py"?
``` python
def test_custom_algo():
target = Target("c")
global_workspace_pool = usmp_utils.PoolInfo(
pool_name="global_workspace",
target_access={target: usmp_utils.PoolInfo.READ_WRITE_ACCESS},
)
tir_mod = ResnetStructure
tir_mod = _assign_targets_to_primfuncs_irmodule(tir_mod, target)
tir_mod = _assign_poolinfos_to_allocates_in_irmodule(tir_mod, [global_workspace_pool])
tir_mod = tir_mod.with_attr("executor", tvm.relay.backend.Executor("aot"))
tir_mod = tir_mod.with_attr("runtime", tvm.relay.backend.Runtime("crt"))
tir_mod["__tvm_main__"] = tir_mod["tvmgen_default_fused_cast_subtract_fixed_point_multiply_add_clip_cast_cast"]
algo_called = False
@tvm.register_func("tir.usmp.algo.trivial")
def _trivial_algo(buf_infos, mem_pressure):
nonlocal algo_called
algo_called = True
out_layout = {}
offset = 0
for buf_info in buf_infos:
pool_info = buf_info.pool_candidates[0]
out_layout[buf_info] = usmp_utils.PoolAllocation(pool_info, offset)
offset += buf_info.size_bytes
return out_layout
usmp_pass = tvm.get_global_func("tir.transform.UnifiedStaticMemoryPlanner")
usmp_pass()(tir_mod)
assert not algo_called
with tvm.transform.PassContext(config={"tir.usmp.custom_algorithm": "trivial"}):
usmp_pass()(tir_mod)
assert algo_called
with pytest.raises(tvm.TVMError, match="The selected custom USMP algorithm : invalid is not defined"):
with tvm.transform.PassContext(config={"tir.usmp.custom_algorithm": "invalid"}):
usmp_pass()(tir_mod)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org