-
Notifications
You must be signed in to change notification settings - Fork 64
/
build_ov.py
98 lines (85 loc) · 3.46 KB
/
build_ov.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
# ==============================================================================
# Copyright 2018-2020 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
from tools.build_utils import *
import os, shutil
import argparse
def main():
openvino_version = "releases/2021/2"
build_dir = 'build_cmake'
cxx_abi = "0"
print("openVINO version: ", openvino_version)
# Command line parser options
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument(
'--output_dir',
type=str,
help="Location where OpenVINO build will happen\n",
action="store",
required=True)
parser.add_argument(
'--target_arch',
help=
"Architecture flag to use (e.g., haswell, core-avx2 etc. Default \'native\'\n",
default="native")
parser.add_argument(
'--debug_build',
help="Builds a debug version of the components\n",
action="store_true")
arguments = parser.parse_args()
if not os.path.isdir(arguments.output_dir):
os.makedirs(arguments.output_dir)
os.chdir(arguments.output_dir)
if not os.path.isdir(os.path.join(arguments.output_dir, "openvino")):
# Download OpenVINO
download_repo(
"openvino",
"https://github.com/openvinotoolkit/openvino",
openvino_version,
submodule_update=True)
else:
pwd = os.getcwd()
os.chdir(os.path.join(arguments.output_dir, "openvino"))
call(["git", "fetch"])
command_executor(["git", "checkout", openvino_version])
call(["git", "pull"])
os.chdir(pwd)
openvino_src_dir = os.path.join(arguments.output_dir, "openvino")
print("OV_SRC_DIR: ", openvino_src_dir)
verbosity = False
artifacts_location = os.path.abspath(arguments.output_dir) + '/artifacts'
# Build OpenVINO
build_openvino(build_dir, openvino_src_dir, cxx_abi, arguments.target_arch,
artifacts_location, arguments.debug_build, verbosity)
print('\033[1;35mOpenVINO Build finished\033[0m')
print('When building ngraph-bridge using this prebuilt OpenVINO, use:')
print('\033[3;34mpython3 build_ngtf.py --use_openvino_from_location ' +
os.path.abspath(arguments.output_dir) + '/artifacts/openvino' +
'\033[1;0m')
if __name__ == '__main__':
main()
# Usage
# Build OV once
# ./build_ov.py --output_dir /prebuilt/ov/dir
#
# Reuse OV in different ngraph-bridge builds
# mkdir ngtf_1; cd ngtf_1
# git clone https://github.com/tensorflow/ngraph-bridge.git
# ./build_ngtf.py --use_openvino_from_location /prebuilt/ov/dir/artifacts/openvino
# cd ..; mkdir ngtf_2; cd ngtf_2
# git clone https://github.com/tensorflow/ngraph-bridge.git
# ./build_ngtf.py --use_openvino_from_location /prebuilt/ov/dir/artifacts/openvino