@@ -129,12 +129,45 @@ def get_object_file_path(src: Path) -> Path:
129
129
FLASHINFER_INCLUDE_DIR ,
130
130
FLASHINFER_CSRC_DIR ,
131
131
FLASHINFER_TVM_BINDING_DIR ,
132
- Path (tvm_home ).resolve () / "include" ,
133
- Path (tvm_home ).resolve () / "ffi" / "include" ,
134
- Path (tvm_home ).resolve () / "ffi" / "3rdparty" / "dlpack" / "include" ,
135
- Path (tvm_home ).resolve () / "3rdparty" / "dmlc-core" / "include" ,
136
132
] + CUTLASS_INCLUDE_DIRS
137
133
134
+ if "TVM_SOURCE_DIR" in os .environ or "TVM_HOME" in os .environ :
135
+ tvm_home = (
136
+ os .environ ["TVM_SOURCE_DIR" ]
137
+ if "TVM_SOURCE_DIR" in os .environ
138
+ else os .environ ["TVM_HOME" ]
139
+ )
140
+ include_paths += [
141
+ Path (tvm_home ).resolve () / "include" ,
142
+ Path (tvm_home ).resolve () / "ffi" / "include" ,
143
+ Path (tvm_home ).resolve () / "ffi" / "3rdparty" / "dlpack" / "include" ,
144
+ Path (tvm_home ).resolve () / "3rdparty" / "dmlc-core" / "include" ,
145
+ ]
146
+ else :
147
+ tvm_package_path = Path (tvm .__file__ ).resolve ().parent
148
+ if (tvm_package_path / "include" ).exists ():
149
+ import tvm_ffi
150
+
151
+ tvm_ffi_package_path = Path (tvm_ffi .__file__ ).resolve ().parent
152
+ include_paths += [
153
+ tvm_package_path / "include" ,
154
+ tvm_package_path / "3rdparty" / "dmlc-core" / "include" ,
155
+ tvm_ffi_package_path / "include" ,
156
+ ]
157
+ elif (tvm_package_path .parent .parent / "include" ).exists ():
158
+ include_paths += [
159
+ tvm_package_path .parent .parent / "include" ,
160
+ tvm_package_path .parent .parent / "ffi" / "include" ,
161
+ tvm_package_path .parent .parent / "ffi" / "3rdparty" / "dlpack" / "include" ,
162
+ tvm_package_path .parent .parent / "3rdparty" / "dmlc-core" / "include" ,
163
+ ]
164
+ else :
165
+ # warning: TVM is not installed in the system.
166
+ print (
167
+ "Warning: Include path for TVM cannot be found. "
168
+ "FlashInfer kernel compilation may fail due to missing headers."
169
+ )
170
+
138
171
# ------------------------------------------------------------------------
139
172
# 3) Function to compile a single source file
140
173
# ------------------------------------------------------------------------
0 commit comments