@@ -15,6 +15,21 @@ def list_dir(path: str) -> List[str]:
15
15
return check_output (["ls" , "-1" , path ]).decode ().split ("\n " )
16
16
17
17
18
+ def build_OpenBLAS () -> None :
19
+ '''
20
+ Building OpenBLAS, because the package in many linux is old
21
+ '''
22
+ print ('Building OpenBLAS' )
23
+ openblas_build_flags = ["NUM_THREADS=128" , "USE_OPENMP=1" , "DYNAMIC_ARCH=1" , "TARGET=ARMV8" , "CFLAGS=-O3" ]
24
+ openblas_checkout_dir = "OpenBLAS"
25
+
26
+ check_call (["git" , "clone" , "https://github.com/OpenMathLib/OpenBLAS.git" , "-b" , "v0.3.25" ,
27
+ "--depth" , "1" , "--shallow-submodules" ])
28
+
29
+ check_call (["make" , "-j8" ] + openblas_build_flags ,
30
+ cwd = openblas_checkout_dir )
31
+ check_call (["make" , "-j8" ] + openblas_build_flags + ["install" ], cwd = openblas_checkout_dir )
32
+
18
33
def build_ArmComputeLibrary () -> None :
19
34
'''
20
35
Using ArmComputeLibrary for aarch64 PyTorch
@@ -27,7 +42,7 @@ def build_ArmComputeLibrary() -> None:
27
42
os .makedirs (acl_install_dir )
28
43
check_call (["git" , "clone" , "https://github.com/ARM-software/ComputeLibrary.git" , "-b" , "v23.08" ,
29
44
"--depth" , "1" , "--shallow-submodules" ])
30
- check_call (["scons" , "Werror=1 " , "-j8" , f"build_dir=/{ acl_install_dir } /build" ] + acl_build_flags ,
45
+ check_call (["scons" , "Werror=0 " , "-j8" , f"build_dir=/{ acl_install_dir } /build" ] + acl_build_flags ,
31
46
cwd = acl_checkout_dir )
32
47
for d in ["arm_compute" , "include" , "utils" , "support" , "src" ]:
33
48
shutil .copytree (f"{ acl_checkout_dir } /{ d } " , f"{ acl_install_dir } /{ d } " )
@@ -95,14 +110,17 @@ def parse_arguments():
95
110
elif branch .startswith (("v1." , "v2." )):
96
111
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={ branch [1 :branch .find ('-' )]} PYTORCH_BUILD_NUMBER=1 "
97
112
113
+ build_OpenBLAS ()
98
114
if enable_mkldnn :
99
115
build_ArmComputeLibrary ()
100
116
print ("build pytorch with mkldnn+acl backend" )
101
117
build_vars += "USE_MKLDNN=ON USE_MKLDNN_ACL=ON " \
102
118
"ACL_ROOT_DIR=/acl " \
103
119
"LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build:$LD_LIBRARY_PATH " \
104
120
"ACL_INCLUDE_DIR=/acl/build " \
105
- "ACL_LIBRARY=/acl/build "
121
+ "ACL_LIBRARY=/acl/build " \
122
+ "BLAS=OpenBLAS " \
123
+ "OpenBLAS_HOME=/OpenBLAS "
106
124
else :
107
125
print ("build pytorch without mkldnn backend" )
108
126
0 commit comments