Skip to content

Commit 49339d7

Browse files
committed
[intel] fix knobs after 5cd69f2
Signed-off-by: Anatoly Myachev <[email protected]>
1 parent 5cd69f2 commit 49339d7

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

python/triton/knobs.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def from_path(path: str) -> Optional[IntelTool]:
207207
if version is None:
208208
return None
209209
return IntelTool(path, version.group(1))
210-
except subprocess.CalledProcessError:
210+
except (subprocess.CalledProcessError, FileNotFoundError):
211211
return None
212212

213213

@@ -242,33 +242,27 @@ class env_intel_tool(env_base[str, IntelTool]):
242242
def __init__(self, binary: str) -> None:
243243
binary += sysconfig.get_config_var("EXE")
244244
self.binary = binary
245-
super().__init__(f"TRITON_{binary.upper().replace('-', '_')}_PATH", lambda: os.path.join(
246-
os.path.dirname(__file__),
247-
"backends",
248-
"intel",
249-
"bin",
250-
self.binary,
251-
))
245+
self.default_path = os.path.join(os.path.dirname(__file__), "backends", "intel", "bin", binary)
246+
super().__init__(f"TRITON_{binary.upper()}_PATH")
247+
248+
def get(self) -> IntelTool:
249+
return self.transform(getenv(self.key))
252250

253251
def transform(self, path: str) -> IntelTool:
254-
paths = [
255-
path,
256-
# We still add default as fallback in case the pointed binary isn't
257-
# accessible.
258-
self.default(),
259-
shutil.which(self.binary) or "",
260-
]
252+
# We still add default as fallback in case the pointed binary isn't
253+
# accessible.
254+
if path is not None:
255+
paths = [path, self.default_path]
256+
else:
257+
paths = [self.default_path]
258+
if shutil_path := shutil.which(self.binary):
259+
paths += [shutil_path]
261260
for path in paths:
262-
if not path or not os.access(path, os.X_OK):
263-
continue
264261
if tool := IntelTool.from_path(path):
265262
return tool
266263

267264
raise RuntimeError(f"Cannot find {self.binary}")
268265

269-
def from_env(self, val: str) -> str:
270-
return val
271-
272266

273267
# Separate classes so that types are correct
274268
class env_opt_str(env_base[Optional[str], Optional[str]]):

0 commit comments

Comments
 (0)