Skip to content

Commit

Permalink
[Bugfix][CUTLASS] CUTLASS path finding (#15480)
Browse files Browse the repository at this point in the history
[Bugfix][CUTLASS] CUTLASS path finding (#15476)

This PR fixes the path finding for `3rdparty/cutlass` by trying out
different combinations. It is helpful when TVM is packaged differently.
  • Loading branch information
junrushao committed Aug 4, 2023
1 parent 5438383 commit 2f09064
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 7 additions & 2 deletions python/tvm/_ffi/libinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# specific language governing permissions and limitations
# under the License.
"""Library information."""
import sys
import os
import sys


def split_env_var(env_var, split):
Expand Down Expand Up @@ -169,7 +169,12 @@ def find_include_path(name=None, search_path=None, optional=False):
source_dir = os.environ["TVM_HOME"]
else:
ffi_dir = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
source_dir = os.path.join(ffi_dir, "..", "..", "..")
for source_dir in ["..", "../..", "../../.."]:
source_dir = os.path.join(ffi_dir, source_dir)
if os.path.isdir(os.path.join(source_dir, "include")):
break
else:
raise AssertionError("Cannot find the source directory given ffi_dir: {ffi_dir}")
third_party_dir = os.path.join(source_dir, "3rdparty")

header_path = []
Expand Down
15 changes: 8 additions & 7 deletions python/tvm/contrib/cutlass/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def has_cutlass():


def _get_cutlass_path():
tvm_root = os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../../")
cutlass_path = os.path.join(tvm_root, "3rdparty/cutlass")
assert os.path.exists(cutlass_path), (
f"The CUTLASS root directory not found in {cutlass_path}. Currently, using CUTLASS "
f"requires building TVM from source."
)
return cutlass_path
invalid_paths = []
for rel in ["../../../../", "../../../", "../../"]:
tvm_root = os.path.join(os.path.dirname(os.path.realpath(__file__)), rel)
cutlass_path = os.path.join(tvm_root, "3rdparty/cutlass")
if os.path.exists(cutlass_path):
return cutlass_path
invalid_paths.append(cutlass_path)
raise AssertionError(f"The CUTLASS root directory not found in: {invalid_paths}")


def _get_cutlass_compile_options(sm, threads, use_fast_math=False):
Expand Down

0 comments on commit 2f09064

Please sign in to comment.