1 # Copyright (c) 2018 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
20 TF_VERSION=$(cd $tf_dir 2>/dev/null; git describe --abbrev=0 --tags 2>/dev/null)
22 echo "ERROR: failed to determine TensorFlow version."
23 echo "Please, set environment variable TF_VERSION with TensorFlow version."
24 echo "For example, 'export TF_VERSION=1.5'"
27 TF_VERSION=$(echo $TF_VERSION | sed 's/v\([0-9]\+\.[0-9]\+\).*/\1/')
28 echo "Automatically determined version of TensorFlow as: $TF_VERSION"
32 determine_layer_BUILD_file()
34 if [ $TF_VERSION_MAJOR -gt 1 ]; then
35 LAYER_BUILD_FILE=BUILD_1_4_higher
36 echo "TensorFlow major version is higher than 1, so use BUILD configuraion file as for 1.4."
37 echo "WARNING: this TensorFlow version has not been tested!"
39 if [ $TF_VERSION_MINOR -ge 4 ]; then
40 echo "TensorFlow minor version is higher than 3, so use BUILD configuraion file as for 1.4"
41 LAYER_BUILD_FILE=BUILD_1_4_higher
43 if [ $TF_VERSION_MINOR -ge 2 ]; then
44 echo "TensorFlow minor version is between 2 and 3, so use BUILD configuraion file as for 1.2"
45 LAYER_BUILD_FILE=BUILD_1_2_to_1_3
47 echo "ERROR: TensorFlow version is not supported. Versions 1.2-1.5 are supported"
54 THIS_DIR=`dirname "$0"`
55 if echo "$THIS_DIR" | grep -q -s ^/ || echo "$THIS_DIR" | grep -q -s ^~ ; then
56 THIS_ABSOLUTE_DIR="$THIS_DIR"
58 THIS_ABSOLUTE_DIR="`pwd`/$THIS_DIR"
61 set -e # exit if something goes wrong
62 if [ "x$INTEL_OPENVINO_DIR" = "x" ]; then
63 echo "ERROR: INTEL_OPENVINO_DIR environment variable is not set"
64 echo "Please, run the 'source <OpenVINO_install_dir>/bin/setupvars.sh'"
68 if [ "x$TF_ROOT_DIR" == 'x' ]; then
69 echo "ERROR: TF_ROOT_DIR environment variable is not set"
70 echo "Please, set TF_ROOT_DIR environment variable which points to directory with cloned TF"
74 IE_HEADERS_SRC_DIR=$INTEL_OPENVINO_DIR/inference_engine/include
75 if [ ! -e $IE_HEADERS_SRC_DIR ]; then
76 echo "ERROR: Inference Engine headers files '$IE_HEADERS_SRC_DIR' doesn't exist"
80 IE_HEADERS_DEST_DIR=$TF_ROOT_DIR/third_party/inference_engine
81 if [ -e $IE_HEADERS_DEST_DIR ]; then
82 echo "Removing old version of IE headers files from '$IE_HEADERS_DEST_DIR'"
83 rm -rf $IE_HEADERS_DEST_DIR
86 if [ "x$TF_VERSION" = "x" ]; then
87 get_tf_version $TF_ROOT_DIR
90 TF_VERSION_MINOR=$(echo $TF_VERSION | awk -F. '{print $2}')
91 TF_VERSION_MAJOR=$(echo $TF_VERSION | awk -F. '{print $1}')
92 echo "TensorFlow major version: $TF_VERSION_MAJOR"
93 echo "TensorFlow minor version: $TF_VERSION_MINOR"
95 determine_layer_BUILD_file
97 mkdir -p $IE_HEADERS_DEST_DIR
98 cp -r ${IE_HEADERS_SRC_DIR} ${IE_HEADERS_DEST_DIR}
99 cp $THIS_ABSOLUTE_DIR/inference_engine_BUILD ${IE_HEADERS_DEST_DIR}/BUILD
101 IE_LAYER_SOURCES_DIR=$THIS_ABSOLUTE_DIR/layer_sources
102 IE_LAYER_SOURCES_DEST_DIR=$TF_ROOT_DIR/tensorflow/cc/inference_engine_layer
104 if [ -e $IE_LAYER_SOURCES_DEST_DIR ]; then
105 echo "Removing old version of IE plugin source files from '$IE_LAYER_SOURCES_DEST_DIR'"
106 rm -rf $IE_LAYER_SOURCES_DEST_DIR
108 cp -r ${IE_LAYER_SOURCES_DIR} ${IE_LAYER_SOURCES_DEST_DIR}
109 cp $IE_LAYER_SOURCES_DEST_DIR/$LAYER_BUILD_FILE $IE_LAYER_SOURCES_DEST_DIR/BUILD
113 # refer to https://github.com/allenlavoie/tensorflow/commit/4afd28316f467ac3aaf600162020637c91c0c2b7 for info about --config=monolithic
114 bazel build --config=monolithic //tensorflow/cc/inference_engine_layer:libtensorflow_call_layer.so