Skip to content

Conversation

@tkonolige
Copy link
Contributor

Convert division by a scalar constant into multiplication by the inverse of the constant. Multiplication is faster than division and also allow for more optimization opportunities. Only applies to float32 and float64.

I wrote this as a separate pass. Is there a better way to do it?

@AndrewZhaoLuo

@tvm-bot
Copy link
Collaborator

tvm-bot commented Oct 24, 2022

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: relay See #10317 for details
  • Built docs for commit adeb084 can be found here.

Generated by tvm-bot

Copy link
Contributor

@AndrewZhaoLuo AndrewZhaoLuo left a comment

Choose a reason for hiding this comment

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

LGTM, some comments though.

@AndrewZhaoLuo
Copy link
Contributor

@tvm-bot rerun

@github-actions
Copy link
Contributor

Failed to re-run CI in https://github.com/apache/tvm/actions/runs/3316738778

Details
Traceback (most recent call last):
  File "/home/runner/work/tvm/tvm/ci/scripts/git_utils.py", line 121, in _request
    with request.urlopen(req, data) as response:
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ci/scripts/github_tvmbot.py", line 574, in comment_failure
    raise item
  File "ci/scripts/github_tvmbot.py", line 685, in run
    pr.rerun_github_actions()
  File "ci/scripts/github_tvmbot.py", line 563, in rerun_github_actions
    raise e
  File "ci/scripts/github_tvmbot.py", line 555, in rerun_github_actions
    actions_github.post(f"actions/runs/{workflow_id}/rerun-failed-jobs", data={})
  File "/home/runner/work/tvm/tvm/ci/scripts/git_utils.py", line 143, in post
    return self._request(self.base + url, data, method="POST")
  File "/home/runner/work/tvm/tvm/ci/scripts/git_utils.py", line 126, in _request
    raise RuntimeError(f"Error response: {msg}\n{error_data}")
RuntimeError: Error response: HTTP Error 403: Forbidden
{"message":"This workflow is already running","documentation_url":"https://docs.github.com/rest/reference/actions#re-run-workflow-failed-jobs"}

@tkonolige
Copy link
Contributor Author

tkonolige commented Oct 24, 2022

@tvm-bot re-run

@github-actions
Copy link
Contributor

Failed to re-run CI in https://github.com/apache/tvm/actions/runs/3316749317

Details
Traceback (most recent call last):
  File "/home/runner/work/tvm/tvm/ci/scripts/git_utils.py", line 121, in _request
    with request.urlopen(req, data) as response:
  File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.8/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.8/urllib/request.py", line 640, in http_response
    response = self.parent.error(
  File "/usr/lib/python3.8/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 502, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.8/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ci/scripts/github_tvmbot.py", line 574, in comment_failure
    raise item
  File "ci/scripts/github_tvmbot.py", line 685, in run
    pr.rerun_github_actions()
  File "ci/scripts/github_tvmbot.py", line 563, in rerun_github_actions
    raise e
  File "ci/scripts/github_tvmbot.py", line 555, in rerun_github_actions
    actions_github.post(f"actions/runs/{workflow_id}/rerun-failed-jobs", data={})
  File "/home/runner/work/tvm/tvm/ci/scripts/git_utils.py", line 143, in post
    return self._request(self.base + url, data, method="POST")
  File "/home/runner/work/tvm/tvm/ci/scripts/git_utils.py", line 126, in _request
    raise RuntimeError(f"Error response: {msg}\n{error_data}")
RuntimeError: Error response: HTTP Error 403: Forbidden
{"message":"This workflow is already running","documentation_url":"https://docs.github.com/rest/reference/actions#re-run-workflow-failed-jobs"}

@AndrewZhaoLuo
Copy link
Contributor

@tvm-bot merge

Tristan Konolige added 4 commits October 24, 2022 17:50
Convert division by a scalar constant into multiplication by the inverse
of the constant. Multiplication is faster than division and also allow
for more optimization opportunities. Only applies to float32 and
float64.
@AndrewZhaoLuo AndrewZhaoLuo merged commit e41d0ed into apache:main Oct 25, 2022
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 10, 2022
* [Relay] Rewrite division by constant to multiply

Convert division by a scalar constant into multiplication by the inverse
of the constant. Multiplication is faster than division and also allow
for more optimization opportunities. Only applies to float32 and
float64.

* formatting

* handle division by zero

* handle float16
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
* [Relay] Rewrite division by constant to multiply

Convert division by a scalar constant into multiplication by the inverse
of the constant. Multiplication is faster than division and also allow
for more optimization opportunities. Only applies to float32 and
float64.

* formatting

* handle division by zero

* handle float16
@Johnson9009
Copy link
Contributor

@tkonolige you forgot to judge the operand of divide is "a scalar constant". @AndrewZhaoLuo

@AndrewZhaoLuo
Copy link
Contributor

Oops sorry about that.

#14382

Fixes it by moving to using standard relay semantics so we have to think less of the two cases.

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.

4 participants