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

[DOC] Add doc for Relay op strategy #5078

Merged
merged 5 commits into from
Mar 19, 2020
Merged

Conversation

icemelon
Copy link
Member

Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.

cc @tqchen @kevinthesun @comaniac @tmoreau89 @yzhliu

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

Thanks for the document. I feel it might be vague for new users who attempt to add operators to Relay after reading the code example (e.g., "my_new_op"). Maybe it's better to use a real op that has been already well-defined in Relay, so that it's more like you are explaining how one of the well-implemented ops was done. In this case, you just need to copy paste the code snippet from Relay op strategy and refer readers to the real code. Users can also copy paste the required functions and modify them for their new ops.

docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved

.. code:: python

def add_implementation(self, compute, schedule, name="default", plevel=10)
Copy link
Contributor

Choose a reason for hiding this comment

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

The API here seems a bit confuse. Specifically, it doesn't use any keywords mentioned in the above paragraph. My feeling is this section focuses on components on C++ backend, so would that be better to move this API intro to the next section along with other Python interfaces?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with sticking to the keywords here

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to the later part.

docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@tmoreau89 tmoreau89 left a comment

Choose a reason for hiding this comment

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

@icemelon9 awesome doc overall! I left some comments; and agree with @comaniac about trying to make the paragraphs and API use consistent terminology overall. I think that the fact that this also applies to non-symbolic input shapes should be stated upfront rather than in the last paragraph.

docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved

.. code:: python

def add_implementation(self, compute, schedule, name="default", plevel=10)
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with sticking to the keywords here

docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Show resolved Hide resolved
docs/dev/relay_op_strategy.rst Outdated Show resolved Hide resolved
@icemelon
Copy link
Member Author

@comaniac I replaced "my_new_op" with some real ops now. Could you take a look again?

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

Have some thoughts for the strategy implementation section, but I'm open for discussion and not necessary to commit all of them.

Register Strategy for An Operator
---------------------------------

There are three methods to register a strategy function for an operator,
Copy link
Contributor

@comaniac comaniac Mar 17, 2020

Choose a reason for hiding this comment

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

Some thoughts to this section:

  • It's better to define "strategy function" first. Something like "a strategy function is used to determine which pair of compute and schedule function should be used by given a workload".

  • The third method described at the end of this section (add_implement) is not a method of registering a strategy function to me. Instead, it is more like how to implement a strategy function. It might be better to have a separate section called "Implement a Strategy for An Operator", or just change this section title to "Implement and Register a Strategy for An Operator".

  • My understanding is that the first approach is a simple one because we can reuse the compute function for those patterns. In this case, it might be better to switch the order of first and second methods. That is, we first introduce a method of implementing and registering a strategy function for dense. After that, we mention if your operator fits certain patterns you can simplify your work.

  • In the description of strategy function implementation, I think it might be better to mention topk only. As a result, in the beginning of the next section "Advanced Strategy Function", you can say some operators like dense require a more complicate strategy so it cannot be implemented like topk.

Copy link
Contributor

@tmoreau89 tmoreau89 left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the changes, the PR LGTM!

@icemelon
Copy link
Member Author

I have thought about @comaniac comments and they make a lot of sense. I plan to separate the "Register Strategy for An Operator" into two parts, first describe how to define a strategy function, and second how to do the registration. I'll work on the update today. So let's keep the PR open for now.

@icemelon
Copy link
Member Author

made an update. @comaniac @tmoreau89 could you take a look again?

Copy link
Contributor

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

It looks much better now and I don't have other comments. Thanks for the efforts!

@tmoreau89
Copy link
Contributor

Nice this tutorial has better clarity now.

@tmoreau89 tmoreau89 merged commit a11391e into apache:master Mar 19, 2020
@tmoreau89
Copy link
Contributor

Thanks @icemelon9 @comaniac the PR has been merged.

@icemelon icemelon deleted the strategy-doc branch March 20, 2020 20:58
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Apr 16, 2020
* [DOC] Add doc for Relay op strategy

* update

* address more comments

* update

* update
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Apr 17, 2020
* [DOC] Add doc for Relay op strategy

* update

* address more comments

* update

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

Successfully merging this pull request may close these issues.

4 participants