@@ -15,6 +15,21 @@ def list_dir(path: str) -> List[str]:
1515 return check_output (["ls" , "-1" , path ]).decode ().split ("\n " )
1616
1717
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+
1833def build_ArmComputeLibrary () -> None :
1934 '''
2035 Using ArmComputeLibrary for aarch64 PyTorch
@@ -27,7 +42,7 @@ def build_ArmComputeLibrary() -> None:
2742 os .makedirs (acl_install_dir )
2843 check_call (["git" , "clone" , "https://github.com/ARM-software/ComputeLibrary.git" , "-b" , "v23.08" ,
2944 "--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 ,
3146 cwd = acl_checkout_dir )
3247 for d in ["arm_compute" , "include" , "utils" , "support" , "src" ]:
3348 shutil .copytree (f"{ acl_checkout_dir } /{ d } " , f"{ acl_install_dir } /{ d } " )
@@ -95,14 +110,17 @@ def parse_arguments():
95110 elif branch .startswith (("v1." , "v2." )):
96111 build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={ branch [1 :branch .find ('-' )]} PYTORCH_BUILD_NUMBER=1 "
97112
113+ build_OpenBLAS ()
98114 if enable_mkldnn :
99115 build_ArmComputeLibrary ()
100116 print ("build pytorch with mkldnn+acl backend" )
101117 build_vars += "USE_MKLDNN=ON USE_MKLDNN_ACL=ON " \
102118 "ACL_ROOT_DIR=/acl " \
103119 "LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build:$LD_LIBRARY_PATH " \
104120 "ACL_INCLUDE_DIR=/acl/build " \
105- "ACL_LIBRARY=/acl/build "
121+ "ACL_LIBRARY=/acl/build " \
122+ "BLAS=OpenBLAS " \
123+ "OpenBLAS_HOME=/OpenBLAS "
106124 else :
107125 print ("build pytorch without mkldnn backend" )
108126
0 commit comments