@@ -65,16 +65,17 @@ def main():
6565 parser .add_argument (
6666 '--target_arch' ,
6767 help =
68- "Architecture flag to use (e.g., haswell, core-avx2 etc. Default \' native\' \n " )
68+ "Architecture flag to use (e.g., haswell, core-avx2 etc. Default \' native\' \n "
69+ )
6970
7071 parser .add_argument (
7172 '--build_tf_from_source' ,
7273 type = str ,
73- help = "Build TensorFlow from source and use the specified version.\n "
74- + "If version isn't specified, TF version " + tf_version +
74+ help = "Build TensorFlow from source and use the specified version.\n " +
75+ "If version isn't specified, TF version " + tf_version +
7576 " will be used.\n " +
76- "Note: in this case C++ API, unit tests and examples will be build for " +
77- "OpenVINO integration with TensorFlow" ,
77+ "Note: in this case C++ API, unit tests and examples will be build for "
78+ + "OpenVINO integration with TensorFlow" ,
7879 const = tf_version ,
7980 default = '' ,
8081 nargs = '?' ,
@@ -110,8 +111,7 @@ def main():
110111
111112 parser .add_argument (
112113 '--disable_packaging_openvino_libs' ,
113- help =
114- "Use this option to do build a standalone python package of " +
114+ help = "Use this option to do build a standalone python package of " +
115115 "the OpenVINO integration with TensorFlow Library without OpenVINO libraries" ,
116116 action = "store_true" )
117117
@@ -122,27 +122,23 @@ def main():
122122
123123 parser .add_argument (
124124 '--cxx11_abi_version' ,
125- help =
126- "Desired version of ABI to be used while building Tensorflow, \n " +
125+ help = "Desired version of ABI to be used while building Tensorflow, \n " +
127126 "OpenVINO integration with TensorFlow, and OpenVINO libraries" ,
128127 default = '0' )
129-
128+
130129 parser .add_argument (
131130 '--resource_usage_ratio' ,
132- help =
133- "Ratio of CPU / RAM resources to utilize during Tensorflow build" ,
131+ help = "Ratio of CPU / RAM resources to utilize during Tensorflow build" ,
134132 default = 0.5 )
135133
136134 parser .add_argument (
137135 '--openvino_version' ,
138- help =
139- "Openvino version to be used for building from source" ,
136+ help = "Openvino version to be used for building from source" ,
140137 default = '2021.3' )
141-
138+
142139 parser .add_argument (
143140 '--python_executable' ,
144- help =
145- "Use a specific python executable while building whl" ,
141+ help = "Use a specific python executable while building whl" ,
146142 action = "store" ,
147143 default = '' )
148144
@@ -166,23 +162,22 @@ def main():
166162
167163 assert not (
168164 arguments .use_tensorflow_from_location != '' and
169- arguments .build_tf_from_source != ''
170- ), ( "\" use_tensorflow_from_location\" and \" build_tf_from_source\" "
171- "cannot be used together." )
165+ arguments .build_tf_from_source != '' ), (
166+ "\" use_tensorflow_from_location\" and \" build_tf_from_source\" "
167+ "cannot be used together." )
172168
173- assert not (
174- arguments .openvino_version != "2021.3" and
175- arguments .openvino_version != "2021.2"
176- ), ("Only 2021.2 and 2021.3 are supported OpenVINO versions" )
169+ assert not (arguments .openvino_version != "2021.3" and
170+ arguments .openvino_version != "2021.2" ), (
171+ "Only 2021.2 and 2021.3 are supported OpenVINO versions" )
177172
178173 if arguments .use_openvino_from_location != '' :
179- ver_file = arguments .use_openvino_from_location + \
180- '/deployment_tools/inference_engine/version.txt'
181- with open (ver_file ) as f :
182- line = f .readline ()
183- assert line .find (arguments .openvino_version ) != - 1 , "OpenVINO version " + \
184- arguments .openvino_version + \
185- " does not match the version specified in use_openvino_from_location"
174+ ver_file = arguments .use_openvino_from_location + \
175+ '/deployment_tools/inference_engine/version.txt'
176+ with open (ver_file ) as f :
177+ line = f .readline ()
178+ assert line .find (arguments .openvino_version ) != - 1 , "OpenVINO version " + \
179+ arguments .openvino_version + \
180+ " does not match the version specified in use_openvino_from_location"
186181
187182 version_check ((arguments .build_tf_from_source == '' ),
188183 (arguments .use_tensorflow_from_location != '' ),
@@ -279,10 +274,9 @@ def main():
279274 command_executor (["pip" , "install" , "-U" , tf_whl ])
280275 tf_cxx_abi = get_tf_cxxabi ()
281276
282- assert (
283- arguments .cxx11_abi_version == tf_cxx_abi
284- ), ("Desired ABI version and user built tensorflow library provided with "
285- "use_tensorflow_from_location are incompatible" )
277+ assert (arguments .cxx11_abi_version == tf_cxx_abi ), (
278+ "Desired ABI version and user built tensorflow library provided with "
279+ "use_tensorflow_from_location are incompatible" )
286280
287281 cwd = os .getcwd ()
288282 os .chdir (tf_whl_loc )
@@ -301,31 +295,37 @@ def main():
301295 if arguments .build_tf_from_source == '' :
302296 print ("Using TensorFlow version" , tf_version )
303297 print ("Install TensorFlow" )
304-
298+
305299 if arguments .cxx11_abi_version == "0" :
306- command_executor (["pip" , "install" , "tensorflow==" + tf_version ])
300+ command_executor (
301+ ["pip" , "install" , "tensorflow==" + tf_version ])
307302 elif arguments .cxx11_abi_version == "1" :
308303 tags = next (sys_tags ())
309304
310305 if tags .interpreter == "cp36" :
311- command_executor (["pip" , "install" ,
312- "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v0.5.0/tensorflow_abi1-2.4.1-cp36-cp36m-manylinux2010_x86_64.whl" ])
306+ command_executor ([
307+ "pip" , "install" ,
308+ "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v0.5.0/tensorflow_abi1-2.4.1-cp36-cp36m-manylinux2010_x86_64.whl"
309+ ])
313310 if tags .interpreter == "cp37" :
314- command_executor (["pip" , "install" ,
315- "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v0.5.0/tensorflow_abi1-2.4.1-cp37-cp37m-manylinux2010_x86_64.whl" ])
311+ command_executor ([
312+ "pip" , "install" ,
313+ "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v0.5.0/tensorflow_abi1-2.4.1-cp37-cp37m-manylinux2010_x86_64.whl"
314+ ])
316315 if tags .interpreter == "cp38" :
317- command_executor (["pip" , "install" ,
318- "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v0.5.0/tensorflow_abi1-2.4.1-cp38-cp38-manylinux2010_x86_64.whl" ])
319-
316+ command_executor ([
317+ "pip" , "install" ,
318+ "https://github.com/openvinotoolkit/openvino_tensorflow/releases/download/v0.5.0/tensorflow_abi1-2.4.1-cp38-cp38-manylinux2010_x86_64.whl"
319+ ])
320+
320321 # ABI 1 TF required latest numpy
321322 command_executor (["pip" , "install" , "-U numpy" ])
322323
323324 tf_cxx_abi = get_tf_cxxabi ()
324325
325- assert (
326- arguments .cxx11_abi_version == tf_cxx_abi
327- ), ("Desired ABI version and tensorflow library installed with "
328- "pip are incompatible" )
326+ assert (arguments .cxx11_abi_version == tf_cxx_abi ), (
327+ "Desired ABI version and tensorflow library installed with "
328+ "pip are incompatible" )
329329
330330 tf_src_dir = os .path .join (artifacts_location , "tensorflow" )
331331 print ("TF_SRC_DIR: " , tf_src_dir )
@@ -364,13 +364,20 @@ def main():
364364 print ("TF_SRC_DIR: " , tf_src_dir )
365365
366366 # Build TensorFlow
367- build_tensorflow (tf_version , "tensorflow" , artifacts_location ,
368- target_arch , verbosity , use_intel_tf , arguments .cxx11_abi_version ,
369- resource_usage_ratio = float (arguments .resource_usage_ratio ))
367+ build_tensorflow (
368+ tf_version ,
369+ "tensorflow" ,
370+ artifacts_location ,
371+ target_arch ,
372+ verbosity ,
373+ use_intel_tf ,
374+ arguments .cxx11_abi_version ,
375+ resource_usage_ratio = float (arguments .resource_usage_ratio ))
370376
371377 # Now build the libtensorflow_cc.so - the C++ library
372378 build_tensorflow_cc (tf_version , tf_src_dir , artifacts_location ,
373- target_arch , verbosity , use_intel_tf , arguments .cxx11_abi_version )
379+ target_arch , verbosity , use_intel_tf ,
380+ arguments .cxx11_abi_version )
374381
375382 tf_cxx_abi = install_tensorflow (venv_dir , artifacts_location )
376383
@@ -391,27 +398,30 @@ def main():
391398 "NOTE: OpenVINO python module is not built when building from source."
392399 )
393400
394- if (arguments .openvino_version == "2021.3" ):
395- openvino_branch = "releases/2021/3"
396- elif (arguments .openvino_version == "2021.2" ):
397- openvino_branch = "releases/2021/2"
401+ if (arguments .openvino_version == "2021.3" ):
402+ openvino_branch = "releases/2021/3"
403+ elif (arguments .openvino_version == "2021.2" ):
404+ openvino_branch = "releases/2021/2"
398405
399406 # Download OpenVINO
400407 download_repo (
401408 "openvino" ,
402409 "https://github.com/openvinotoolkit/openvino" ,
403- openvino_branch ,
404- submodule_update = True )
410+ openvino_branch ,
411+ submodule_update = True )
405412 openvino_src_dir = os .path .join (os .getcwd (), "openvino" )
406413 print ("OV_SRC_DIR: " , openvino_src_dir )
407414
408415 build_openvino (build_dir , openvino_src_dir , cxx_abi , target_arch ,
409416 artifacts_location , arguments .debug_build , verbosity )
410417
411418 # Next build CMAKE options for the bridge
419+ atom_flags = ""
420+ if (target_arch == "silvermont" ):
421+ atom_flags = " -mcx16 -mssse3 -msse4.1 -msse4.2 -mpopcnt -mno-avx"
412422 openvino_tf_cmake_flags = [
413423 "-DOPENVINO_TF_INSTALL_PREFIX=" + artifacts_location ,
414- "-DCMAKE_CXX_FLAGS=-march=" + target_arch ,
424+ "-DCMAKE_CXX_FLAGS=-march=" + target_arch + atom_flags ,
415425 ]
416426
417427 openvino_artifacts_dir = ""
@@ -426,7 +436,7 @@ def main():
426436 ["-DOPENVINO_ARTIFACTS_DIR=" + openvino_artifacts_dir ])
427437
428438 openvino_tf_cmake_flags .extend (
429- ["-DOPENVINO_VERSION=" + arguments .openvino_version ])
439+ ["-DOPENVINO_VERSION=" + arguments .openvino_version ])
430440
431441 if (arguments .debug_build ):
432442 openvino_tf_cmake_flags .extend (["-DCMAKE_BUILD_TYPE=Debug" ])
@@ -457,12 +467,13 @@ def main():
457467 if arguments .disable_packaging_openvino_libs :
458468 openvino_tf_cmake_flags .extend (["-DDISABLE_PACKAGING_OPENVINO_LIBS=1" ])
459469 if arguments .python_executable != '' :
460- openvino_tf_cmake_flags .extend (["-DPYTHON_EXECUTABLE=%s" % arguments .python_executable ])
470+ openvino_tf_cmake_flags .extend (
471+ ["-DPYTHON_EXECUTABLE=%s" % arguments .python_executable ])
461472
462473 # Now build the bridge
463474 ov_tf_whl = build_openvino_tf (build_dir , artifacts_location ,
464- openvino_tf_src_dir , venv_dir ,
465- openvino_tf_cmake_flags , verbosity )
475+ openvino_tf_src_dir , venv_dir ,
476+ openvino_tf_cmake_flags , verbosity )
466477
467478 # Make sure that the openvino_tensorflow whl is present in the artfacts directory
468479 if not os .path .isfile (os .path .join (artifacts_location , ov_tf_whl )):
@@ -507,7 +518,7 @@ def main():
507518
508519 # Run a quick test
509520 install_openvino_tf (tf_version , venv_dir ,
510- os .path .join (artifacts_location , ov_tf_whl ))
521+ os .path .join (artifacts_location , ov_tf_whl ))
511522
512523 if builder_version > 0.50 and arguments .use_grappler_optimizer :
513524 import tensorflow as tf
0 commit comments