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

[TOPI][CUDA] Enable vectorization on fp16 type #4867

Merged
merged 1 commit into from
Feb 14, 2020

Conversation

wpan11nv
Copy link
Contributor

  • This allows to better utilize the memory bandwidth

  • Note that not all cases are vectorized for fp16 datatype. For
    instance, when the size is not a multiple of 1024, the inner loop
    may be an expression that cannot be vectorized. In this case, a
    small inner loop is still benefical for latency hidding.

Signed-off-by: Wei Pan [email protected]

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.

@tqchen
Copy link
Member

tqchen commented Feb 12, 2020

Please request reviews from reviewers

@wpan11nv
Copy link
Contributor Author

Kindly ping. Thanks!

@tqchen
Copy link
Member

tqchen commented Feb 12, 2020

@vinx13 @Laurawly please help to review the PR

if not tvm.runtime.enabled(device):
print("Skip because %s is not enabled" % device)
return
with tvm.target.create(device):
Copy link
Member

Choose a reason for hiding this comment

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

@@ -87,12 +87,12 @@ def _prelu_numpy(x, W):
tvm.testing.assert_allclose(b.asnumpy(), out_np, rtol=1e-5)

def test_relu():
verify_relu(10, 128)
verify_relu(128, 128, "float32")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you keep a test case as before where m and n have different values?

check_device(device)

def test_vectorization():
verify_vectorization(128, 128, "float16")
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@wpan11nv
Copy link
Contributor Author

Thanks all for the suggestions! Tests updated.

from common import get_all_backend

def verify_relu(m, n):
A = tvm.placeholder((m, n), name='A')
def skipTest(dtype, device):
Copy link
Member

Choose a reason for hiding this comment

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

nit: we prefer skip_test style naming

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

- This allows to better utilize the memory bandwidth

- Note that not all cases are vectorized for fp16 datatype. For
  instance, when the size is not a multiple of 1024, the inner loop
  may be an expression that cannot be vectorized. In this case, a
  small inner loop is still benefical for latency hidding.

Signed-off-by: Wei Pan <[email protected]>
@tqchen tqchen merged commit 7013fc9 into apache:master Feb 14, 2020
@tqchen
Copy link
Member

tqchen commented Feb 14, 2020

Thanks @vinx13 @wpan11nv !

@wpan11nv wpan11nv deleted the topi_fp16 branch February 14, 2020 17:21
alexwong pushed a commit to alexwong/tvm that referenced this pull request Feb 26, 2020
- This allows to better utilize the memory bandwidth

- Note that not all cases are vectorized for fp16 datatype. For
  instance, when the size is not a multiple of 1024, the inner loop
  may be an expression that cannot be vectorized. In this case, a
  small inner loop is still benefical for latency hidding.

Signed-off-by: Wei Pan <[email protected]>
alexwong pushed a commit to alexwong/tvm that referenced this pull request Feb 28, 2020
- This allows to better utilize the memory bandwidth

- Note that not all cases are vectorized for fp16 datatype. For
  instance, when the size is not a multiple of 1024, the inner loop
  may be an expression that cannot be vectorized. In this case, a
  small inner loop is still benefical for latency hidding.

Signed-off-by: Wei Pan <[email protected]>
zhiics pushed a commit to neo-ai/tvm that referenced this pull request Mar 2, 2020
- This allows to better utilize the memory bandwidth

- Note that not all cases are vectorized for fp16 datatype. For
  instance, when the size is not a multiple of 1024, the inner loop
  may be an expression that cannot be vectorized. In this case, a
  small inner loop is still benefical for latency hidding.

Signed-off-by: Wei Pan <[email protected]>
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