1
1
#!/usr/bin/env python3
2
+ # encoding: UTF-8
2
3
3
4
import os
4
5
import subprocess
5
6
from pygit2 import Repository
6
7
from typing import List
7
8
8
9
9
- ''''
10
- Helper for getting paths for Python
11
- '''
12
10
def list_dir (path : str ) -> List [str ]:
13
- return subprocess .check_output (["ls" , "-1" , path ]).decode ().split ("\n " )
11
+ ''''
12
+ Helper for getting paths for Python
13
+ '''
14
+ return subprocess .check_output (["ls" , "-1" , path ]).decode ().split ("\n " )
14
15
15
16
16
- '''
17
- Using ArmComputeLibrary for aarch64 PyTorch
18
- '''
19
17
def build_ArmComputeLibrary (git_clone_flags : str = "" ) -> None :
18
+ '''
19
+ Using ArmComputeLibrary for aarch64 PyTorch
20
+ '''
20
21
print ('Building Arm Compute Library' )
21
22
os .system ("cd / && mkdir /acl" )
22
23
os .system (f"git clone https://github.com/ARM-software/ComputeLibrary.git -b v23.05.1 { git_clone_flags } " )
23
24
os .system ('sed -i -e \' s/"armv8.2-a"/"armv8-a"/g\' ComputeLibrary/SConscript; '
24
25
'sed -i -e \' s/-march=armv8.2-a+fp16/-march=armv8-a/g\' ComputeLibrary/SConstruct; '
25
26
'sed -i -e \' s/"-march=armv8.2-a"/"-march=armv8-a"/g\' ComputeLibrary/filedefs.json' )
26
- os .system (f"cd ComputeLibrary; export acl_install_dir=/acl; " \
27
- f"scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux openmp=1 cppthreads=0 arch=armv8.2-a multi_isa=1 build=native build_dir=$acl_install_dir/build; " \
28
- f"cp -r arm_compute $acl_install_dir; " \
29
- f"cp -r include $acl_install_dir; " \
30
- f"cp -r utils $acl_install_dir; " \
31
- f"cp -r support $acl_install_dir; " \
32
- f"cp -r src $acl_install_dir; cd /" )
33
-
34
-
35
- '''
36
- Complete wheel build and put in artifact location
37
- '''
27
+ os .system ("cd ComputeLibrary; export acl_install_dir=/acl; "
28
+ "scons Werror=1 -j8 debug=0 neon=1 opencl=0 os=linux openmp=1 cppthreads=0 arch=armv8.2-a multi_isa=1 build=native build_dir=$acl_install_dir/build; "
29
+ "cp -r arm_compute $acl_install_dir; "
30
+ "cp -r include $acl_install_dir; "
31
+ "cp -r utils $acl_install_dir; "
32
+ "cp -r support $acl_install_dir; "
33
+ "cp -r src $acl_install_dir; cd /" )
34
+
35
+
38
36
def complete_wheel (folder : str ):
37
+ '''
38
+ Complete wheel build and put in artifact location
39
+ '''
39
40
wheel_name = list_dir (f"/{ folder } /dist" )[0 ]
40
41
41
42
if "pytorch" in folder :
@@ -54,10 +55,10 @@ def complete_wheel(folder: str):
54
55
return repaired_wheel_name
55
56
56
57
57
- '''
58
- Parse inline arguments
59
- '''
60
58
def parse_arguments ():
59
+ '''
60
+ Parse inline arguments
61
+ '''
61
62
from argparse import ArgumentParser
62
63
parser = ArgumentParser ("AARCH64 wheels python CD" )
63
64
parser .add_argument ("--debug" , action = "store_true" )
@@ -67,11 +68,10 @@ def parse_arguments():
67
68
return parser .parse_args ()
68
69
69
70
70
- '''
71
- Entry Point
72
- '''
73
71
if __name__ == '__main__' :
74
-
72
+ '''
73
+ Entry Point
74
+ '''
75
75
args = parse_arguments ()
76
76
enable_mkldnn = args .enable_mkldnn
77
77
repo = Repository ('/pytorch' )
@@ -80,26 +80,25 @@ def parse_arguments():
80
80
branch = 'master'
81
81
82
82
git_clone_flags = " --depth 1 --shallow-submodules"
83
- os .system (f"conda install -y ninja scons" )
84
83
85
84
print ('Building PyTorch wheel' )
86
85
build_vars = "CMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=0x10000 "
87
- os .system (f "python setup.py clean" )
86
+ os .system ("python setup.py clean" )
88
87
89
88
if branch == 'nightly' or branch == 'master' :
90
- build_date = subprocess .check_output (['git' ,'log' ,'--pretty=format:%cs' ,'-1' ], cwd = '/pytorch' ).decode ().replace ('-' ,'' )
91
- version = subprocess .check_output (['cat' ,'version.txt' ], cwd = '/pytorch' ).decode ().strip ()[:- 2 ]
89
+ build_date = subprocess .check_output (['git' , 'log' , '--pretty=format:%cs' , '-1' ], cwd = '/pytorch' ).decode ().replace ('-' , '' )
90
+ version = subprocess .check_output (['cat' , 'version.txt' ], cwd = '/pytorch' ).decode ().strip ()[:- 2 ]
92
91
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={ version } .dev{ build_date } PYTORCH_BUILD_NUMBER=1 "
93
92
if branch .startswith ("v1." ) or branch .startswith ("v2." ):
94
93
build_vars += f"BUILD_TEST=0 PYTORCH_BUILD_VERSION={ branch [1 :branch .find ('-' )]} PYTORCH_BUILD_NUMBER=1 "
95
94
if enable_mkldnn :
96
95
build_ArmComputeLibrary (git_clone_flags )
97
96
print ("build pytorch with mkldnn+acl backend" )
98
97
build_vars += "USE_MKLDNN=ON USE_MKLDNN_ACL=ON " \
99
- "ACL_ROOT_DIR=/acl " \
100
- "LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build:$LD_LIBRARY_PATH " \
101
- "ACL_INCLUDE_DIR=/acl/build " \
102
- "ACL_LIBRARY=/acl/build "
98
+ "ACL_ROOT_DIR=/acl " \
99
+ "LD_LIBRARY_PATH=/pytorch/build/lib:/acl/build:$LD_LIBRARY_PATH " \
100
+ "ACL_INCLUDE_DIR=/acl/build " \
101
+ "ACL_LIBRARY=/acl/build "
103
102
else :
104
103
print ("build pytorch without mkldnn backend" )
105
104
0 commit comments