Skip to content

Commit

Permalink
Add Accelerate framework blas__ldflags tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucianopaz committed Oct 31, 2024
1 parent 6132203 commit ae3c72d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions pytensor/link/c/cmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2873,9 +2873,21 @@ def check_libs(
)
except Exception as e:
_logger.debug(e)
try:
# 3. Mac Accelerate framework
_logger.debug("Checking Accelerate framework")
flags = ["-framework", "Accelerate"]
if rpath:
flags = [*flags, "-rpath", rpath]
validated_flags = try_blas_flag(flags)
if validated_flags == "":
raise Exception("Accelerate framework flag failed ")
return validated_flags
except Exception as e:
_logger.debug(e)
try:
_logger.debug("Checking Lapack + blas")
# 3. Try to use LAPACK + BLAS
# 4. Try to use LAPACK + BLAS
return check_libs(
all_libs,
required_libs=["lapack", "blas", "cblas", "m"],
Expand All @@ -2885,7 +2897,7 @@ def check_libs(
except Exception as e:
_logger.debug(e)
try:
# 4. Try to use BLAS alone
# 5. Try to use BLAS alone
_logger.debug("Checking blas alone")
return check_libs(
all_libs,
Expand All @@ -2896,7 +2908,7 @@ def check_libs(
except Exception as e:
_logger.debug(e)
try:
# 5. Try to use openblas
# 6. Try to use openblas
_logger.debug("Checking openblas")
return check_libs(
all_libs,
Expand Down
3 changes: 2 additions & 1 deletion pytensor/tensor/blas.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import logging
import os
import time
from pathlib import Path

import numpy as np

Expand Down Expand Up @@ -425,7 +426,7 @@ def _ldflags(

try:
t0, t1 = t[0], t[1]
assert t0 == "-"
assert t0 == "-" or t == "Accelerate" or Path(t).exists()
except Exception:
raise ValueError(f'invalid token "{t}" in ldflags_str: "{ldflags_str}"')
if libs_dir and t1 == "L":
Expand Down

0 comments on commit ae3c72d

Please sign in to comment.