Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Target] Remove deprecated parameters from target #12416

Merged
merged 20 commits into from
Aug 24, 2022

Conversation

mehrdadh
Copy link
Member

@mehrdadh mehrdadh force-pushed the refactor_depricated_target_configs branch from 1becc10 to 4f21a7b Compare August 12, 2022 23:43
@mehrdadh mehrdadh marked this pull request as draft August 12, 2022 23:55
@mehrdadh mehrdadh force-pushed the refactor_depricated_target_configs branch from 41de1c8 to f436301 Compare August 13, 2022 00:06
Runtime("crt", {"system-lib": True}),
],
],
test_target = tvm.testing.parameter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably keep using pytest.mark.parametrize to aid in linting this file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

assert runtime == actual_runtime

def test_deprecated_target_parameters(test_target, target):
unsupported_config = test_target.split(" ")[1].replace("=", " ").split(" ")[0][1:]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty complex, would be better to have test_target and unsupported_config in a tuple.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@mehrdadh mehrdadh force-pushed the refactor_depricated_target_configs branch from f436301 to 7364b8c Compare August 15, 2022 16:21
@mehrdadh mehrdadh force-pushed the refactor_depricated_target_configs branch from 7364b8c to e76f9dc Compare August 15, 2022 16:24
@mehrdadh mehrdadh requested a review from Mousius August 15, 2022 21:06
@mehrdadh mehrdadh marked this pull request as ready for review August 15, 2022 23:20
Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @mehrdadh, broadly looks good but we should check on system-lib, because that changes the way code is loaded on the target.

@@ -72,7 +72,7 @@ def build_graph_lib(opt_level):
shape_dict = {input_name: img_data.shape}

mod, params = relay.frontend.from_onnx(onnx_model, shape_dict)
target = "llvm -mtriple=wasm32-unknown-unknown -mattr=+simd128 --system-lib"
target = "llvm -mtriple=wasm32-unknown-unknown -mattr=+simd128"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to keep --system-lib passed to Executor config here. can you audit the other places you removed --system-lib and ensure the Executor passed to relay.build has it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked places that I removed and added to the executor as needed. Please let me know if I missed anything

@mehrdadh
Copy link
Member Author

@Mousius PTAL, thanks!

@mehrdadh mehrdadh force-pushed the refactor_depricated_target_configs branch from 1513baa to 4200527 Compare August 16, 2022 22:35
Copy link
Member

@Mousius Mousius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! The failing test seems unrelated, thanks for picking this up @mehrdadh 😸

@masahi
Copy link
Member

masahi commented Aug 18, 2022

So --link-params=1 in target is deprecated now? I am about to send a PR that depends on link-params option in target...

What I'm going to do is to fix the behavior of FuseOps and meta schedule task extraction when link-params = 1.
The issue is that FuseOps looks up link-params from Executor here

link_params = executor.defined()
? executor->attrs.GetAttr<Bool>("link-params").value_or(Bool(link_params))
: link_params;
while FuseOps can be called from a context where there is no executor. One of such places is meta schedule task extraction,
pass_seqs.push_back(transform::FuseOps());
.

FuseOps thinks link-params is False when it is called by task extraction, while when called from relay.build(..., executor), it sees that link-params is True. So subgraphs extracted by task extraction would never match those that are actually generated during relay.build when link-params is True.

My fix is to look up link-params option from target and enable relay.FuseOps.link_params, before calling FuseOps from task extraction.
https://github.com/masahi/tvm/blob/f1f395cb66ba6d3b6fe488b6dda376e33f51b8e4/src/relay/backend/task_extraction.cc#L47-L52

if link-params option in target is deprecated, I need to thread through executor in task extraction, which will cause some breaking API changes.

@areusch
Copy link
Contributor

areusch commented Aug 18, 2022

@masahi I see...I think perhaps we might need to arrange to thread the Executor through. at the moment the way we model memory in the compiler doesn't guarantee that Constant will wind up in any particular location, so link-params is mainly an executor-level thing. what do you think? the change that caused this was also a relay.build API change as well.

@masahi
Copy link
Member

masahi commented Aug 18, 2022

@areusch Since most common use cases do not need link-params, I hesitate to break API and impose executor argument to all users of meta schedule task extraction. Instead, I'm leaning toward pushing the responsibility to users if they want to use link-params together with meta schedule, by requiring the following usage:

    with tvm.transform.PassContext(config={"relay.FuseOps.link_params": 1}):
         meta_schedule.extract_task_from_relay(...)

@masahi masahi merged commit c15cc5e into apache:main Aug 24, 2022
@mehrdadh mehrdadh deleted the refactor_depricated_target_configs branch August 25, 2022 20:59
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
* remove depricated parameters in target

* lint

* fix cpp tests

fix

* remove more configs in test files

* address comments

* fix error

* fix hexagon

* fix micro tutorial

* fix integration tests

* fix hexagon

* lint

* fix unittest

* fix readme

* fix assert executor in target

* address comments

* fix tutorials

* fix hexagon target

* fix tutorial

* fix for tutorials

* hexagon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] _reconstruct_from_deprecated_options creates incorrect executor
4 participants