-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Fix tutorial 18584 #18696
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
Fix tutorial 18584 #18696
Changes from all commits
a65fb44
8d74f25
fceb7da
2201b99
ec83753
b0fdc94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| # Licensed to the Apache Software Foundation (ASF) under one | ||||||
| # Licensed to the Apache Software Foundation (ASF) under one | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line contains a Unicode Byte Order Mark (BOM)
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls take a look |
||||||
| # or more contributor license agreements. See the NOTICE file | ||||||
| # distributed with this work for additional information | ||||||
| # regarding copyright ownership. The ASF licenses this file | ||||||
|
|
@@ -55,6 +55,12 @@ | |||||
| from tvm import IRModule, relax | ||||||
| from tvm.relax.frontend import nn | ||||||
|
|
||||||
| # Note: This tutorial requires TVM to be built with CUDA support. | ||||||
| # If you encounter 'No module named ''tvm_ffi''' error, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tvm_ffi can be installed with |
||||||
| # you need to build TVM from source with CUDA enabled. | ||||||
| # Build instructions: https://tvm.apache.org/docs/install/from_source.html | ||||||
|
|
||||||
|
|
||||||
| ###################################################################### | ||||||
| # Composable IRModule Optimization | ||||||
| # -------------------------------- | ||||||
|
|
@@ -103,9 +109,17 @@ def forward(self, x): | |||||
|
|
||||||
|
|
||||||
| # Import cublas pattern | ||||||
| import tvm.relax.backend.cuda.cublas as _cublas | ||||||
|
|
||||||
|
|
||||||
| try: | ||||||
| import tvm.relax.backend.cuda.cublas as _cublas | ||||||
| except ImportError as e: | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably we don't have to handle the tvm_ffi specifically here |
||||||
| if "tvm_ffi" in str(e): | ||||||
| import sys | ||||||
| print("Error: TVM needs to be built with CUDA support.", file=sys.stderr) | ||||||
| print("Please build TVM from source with CUDA enabled.", file=sys.stderr) | ||||||
| print("See: https://tvm.apache.org/docs/install/from_source.html", file=sys.stderr) | ||||||
| sys.exit(1) | ||||||
| else: | ||||||
| raise | ||||||
| # Define a new pass for CUBLAS dispatch | ||||||
| @tvm.transform.module_pass(opt_level=0, name="CublasDispatch") | ||||||
| class CublasDispatch: | ||||||
|
|
@@ -223,3 +237,6 @@ def transform_module(self, mod: IRModule, _ctx: tvm.transform.PassContext) -> IR | |||||
| # of the computation graph. The flexibility of the optimization pipeline enables us to quickly | ||||||
| # iterate the optimization and improve the performance of the model. | ||||||
| # | ||||||
|
|
||||||
|
|
||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LICENSE update isn’t related to this PR. I’d suggest we avoid changing it here and handle it in a separate PR if needed.