File: apple_accelerate.py

package info (click to toggle)
python-numpy 1%3A1.16.2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 25,116 kB
  • sloc: ansic: 158,812; python: 115,039; cpp: 1,112; makefile: 502; sh: 314; f90: 289; sed: 140; fortran: 121; perl: 68
file content (28 lines) | stat: -rw-r--r-- 956 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import division, absolute_import, print_function

import os
import sys
import re

__all__ = ['uses_accelerate_framework', 'get_sgemv_fix']

def uses_accelerate_framework(info):
    """ Returns True if Accelerate framework is used for BLAS/LAPACK """
    # If we're not building on Darwin (macOS), don't use Accelerate
    if sys.platform != "darwin":
        return False
    # If we're building on macOS, but targeting a different platform,
    # don't use Accelerate.
    if os.getenv('_PYTHON_HOST_PLATFORM', None):
        return False
    r_accelerate = re.compile("Accelerate")
    extra_link_args = info.get('extra_link_args', '')
    for arg in extra_link_args:
        if r_accelerate.search(arg):
            return True
    return False

def get_sgemv_fix():
    """ Returns source file needed to correct SGEMV """
    path = os.path.abspath(os.path.dirname(__file__))
    return [os.path.join(path, 'src', 'apple_sgemv_fix.c')]