Skip to content

Commit 96960a8

Browse files
authored
Merge pull request #1153 from netfs/r1.11
Cherry picks for upcoming 1.11.1 release
2 parents a3eef51 + a313d90 commit 96960a8

File tree

10 files changed

+127
-27
lines changed

10 files changed

+127
-27
lines changed

tensorflow_serving/model_servers/BUILD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ cc_library(
330330
srcs = [
331331
"main.cc",
332332
],
333-
hdrs = ["version.h"],
333+
hdrs = [
334+
"version.h",
335+
],
336+
linkstamp = "version.cc",
334337
visibility = [
335338
":tensorflow_model_server_custom_op_clients",
336339
"//tensorflow_serving:internal",
@@ -347,6 +350,7 @@ cc_library(
347350

348351
cc_binary(
349352
name = "tensorflow_model_server",
353+
stamp = 1,
350354
visibility = ["//tensorflow_serving:internal"],
351355
deps = [
352356
":tensorflow_model_server_main_lib",

tensorflow_serving/model_servers/main.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ int main(int argc, char** argv) {
158158
}
159159

160160
if (display_version) {
161-
std::cout << "TensorFlow ModelServer: " << TF_MODELSERVER_VERSION_STRING
162-
<< "\n"
161+
std::cout << "TensorFlow ModelServer: " << TF_Serving_Version() << "\n"
163162
<< "TensorFlow Library: " << TF_Version() << "\n";
164163
return 0;
165164
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Copyright 2018 Google Inc. All Rights Reserved.
2+
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
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
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.
14+
==============================================================================*/
15+
16+
#include "tensorflow_serving/model_servers/version.h"
17+
18+
const char kTFS_SCM_Revision[] = TF_MODELSERVER_VERSION_STRING;
19+
20+
extern "C" {
21+
const char* TF_Serving_Version() { return kTFS_SCM_Revision; }
22+
}

tensorflow_serving/model_servers/version.h

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,43 @@ limitations under the License.
1616
#ifndef TENSORFLOW_SERVING_MODEL_SERVERS_VERSION_H_
1717
#define TENSORFLOW_SERVING_MODEL_SERVERS_VERSION_H_
1818

19-
// TF Serving Model Server uses semantic versioning, see http://semver.org/.
19+
// TF Serving Model Server uses semantic versioning for releases
20+
// - see http://semver.org/. For nightlies, a git hash is used to track the
21+
// build via linkstamping
22+
#define TF_MODELSERVER_STR_HELPER(x) #x
23+
#define TF_MODELSERVER_STR(x) TF_MODELSERVER_STR_HELPER(x)
2024

2125
#define TF_MODELSERVER_MAJOR_VERSION 1
2226
#define TF_MODELSERVER_MINOR_VERSION 11
2327
#define TF_MODELSERVER_PATCH_VERSION 0
24-
2528
// TF_MODELSERVER_VERSION_SUFFIX is non-empty for pre-releases
2629
// (e.g. "-alpha", "-alpha.1", "-beta", "-rc", "-rc.1")
2730
#define TF_MODELSERVER_VERSION_SUFFIX ""
2831

29-
#define TF_MODELSERVER_STR_HELPER(x) #x
30-
#define TF_MODELSERVER_STR(x) TF_MODELSERVER_STR_HELPER(x)
31-
32-
// e.g. "0.5.0" or "0.6.0-alpha".
32+
#ifndef TF_MODELSERVER_VERSION_NO_META
33+
// TF_MODELSERVER_BUILD_TAG can be set to be nightly for nightly builds
34+
#ifndef TF_MODELSERVER_BUILD_TAG
35+
#define TF_MODELSERVER_META_TAG "+dev"
36+
#else
37+
#define TF_MODELSERVER_META_TAG "+" TF_MODELSERVER_STR(TF_MODELSERVER_BUILD_TAG)
38+
#endif
39+
#define TF_MODELSERVER_META_SCM_HASH ".sha." BUILD_SCM_REVISION
40+
#else
41+
#define TF_MODELSERVER_META_TAG ""
42+
#define TF_MODELSERVER_META_SCM_HASH ""
43+
#endif
44+
45+
// e.g. "0.5.0+nightly.sha.a1b2c3d" or "0.6.0-rc1".
3346
// clang-format off
3447
#define TF_MODELSERVER_VERSION_STRING \
3548
(TF_MODELSERVER_STR(TF_MODELSERVER_MAJOR_VERSION) "." TF_MODELSERVER_STR( \
36-
TF_MODELSERVER_MINOR_VERSION) "." TF_MODELSERVER_STR( \
37-
TF_MODELSERVER_PATCH_VERSION) TF_MODELSERVER_VERSION_SUFFIX)
49+
TF_MODELSERVER_MINOR_VERSION) "." TF_MODELSERVER_STR( \
50+
TF_MODELSERVER_PATCH_VERSION) TF_MODELSERVER_VERSION_SUFFIX \
51+
TF_MODELSERVER_META_TAG TF_MODELSERVER_META_SCM_HASH)
3852
// clang-format on
3953

54+
extern "C" {
55+
const char* TF_Serving_Version();
56+
}
57+
4058
#endif // TENSORFLOW_SERVING_MODEL_SERVERS_VERSION_H_

tensorflow_serving/tools/docker/Dockerfile.devel-gpu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ RUN echo "Building with Bazel options: ${TF_SERVING_BAZEL_OPTIONS}"
155155

156156
RUN ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \
157157
LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs:${LD_LIBRARY_PATH} \
158-
bazel build --color=yes --curses=yes --config=cuda \
158+
bazel build --color=yes --curses=yes --config=cuda --copt="-fPIC"\
159159
${TF_SERVING_BAZEL_OPTIONS} \
160160
--verbose_failures \
161161
--output_filter=DONT_MATCH_ANYTHING \

tensorflow_serving/util/json_tensor.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ limitations under the License.
1515

1616
#include "tensorflow_serving/util/json_tensor.h"
1717

18+
#include <cstdlib>
1819
#include <limits>
1920
#include <string>
2021
#include <type_traits>
@@ -209,15 +210,26 @@ Status LossyDecimalError(const rapidjson::Value& val, const string& target) {
209210
template <typename T>
210211
bool IsLosslessDecimal(const rapidjson::Value& val) {
211212
static_assert(std::is_same<T, float>::value || std::is_same<T, double>::value,
212-
"Only floating-point value types are supported.");
213+
"Only floating point value types are supported.");
214+
static_assert(std::numeric_limits<T>::radix == 2,
215+
"Floating point type must have base 2.");
213216

214217
// Note, we use GetDouble() for both types as std::isfinite() returns false
215218
// for decimal values that do not fit in float (due to the static_cast<> used
216219
// in converting double to float in GetFloat() call).
217220
if (!std::isfinite(val.GetDouble())) return true;
218221

219-
if (std::is_same<T, float>::value) return val.IsLosslessFloat();
220-
return val.IsLosslessDouble();
222+
// Maximum integer value that can be represented by the floating type.
223+
static constexpr int64 kMaxInt = (1LL << std::numeric_limits<T>::digits) - 1;
224+
225+
if (val.IsUint64()) {
226+
return val.GetUint64() <= kMaxInt;
227+
}
228+
if (val.IsInt64()) {
229+
return std::abs(val.GetInt64()) <= kMaxInt;
230+
}
231+
return val.GetDouble() <= std::numeric_limits<T>::max() &&
232+
val.GetDouble() >= std::numeric_limits<T>::lowest();
221233
}
222234

223235
// Adds a JSON value to Tensor. Returns error if value cannot be converted

tensorflow_serving/util/json_tensor_test.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ TEST(JsontensorTest, SingleUnnamedTensor) {
8181
)"));
8282
}
8383

84-
TEST(JsontensorTest, IntegerInputForFloatTensor) {
84+
TEST(JsontensorTest, MixedInputForFloatTensor) {
8585
TensorInfoMap infomap;
8686
ASSERT_TRUE(
8787
TextFormat::ParseFromString("dtype: DT_FLOAT", &infomap["default"]));
@@ -90,24 +90,26 @@ TEST(JsontensorTest, IntegerInputForFloatTensor) {
9090
JsonPredictRequestFormat format;
9191
TF_EXPECT_OK(FillPredictRequestFromJson(R"(
9292
{
93-
"instances": [1, 2, 3, 4, 5]
93+
"instances": [1, 2.0, 3, 4, 5.003, 0.007, 0.0]
9494
})",
9595
getmap(infomap), &req, &format));
9696
auto tmap = req.inputs();
9797
EXPECT_EQ(tmap.size(), 1);
9898
EXPECT_EQ(format, JsonPredictRequestFormat::kRow);
9999
EXPECT_THAT(tmap["default"], EqualsProto(R"(
100100
dtype: DT_FLOAT
101-
tensor_shape { dim { size: 5 } }
101+
tensor_shape { dim { size: 7 } }
102102
float_val: 1
103-
float_val: 2
103+
float_val: 2.0
104104
float_val: 3
105105
float_val: 4
106-
float_val: 5
106+
float_val: 5.003
107+
float_val: 0.007
108+
float_val: 0.0
107109
)"));
108110
}
109111

110-
TEST(JsontensorTest, IntegerInputForDoubleTensor) {
112+
TEST(JsontensorTest, MixedInputForDoubleTensor) {
111113
TensorInfoMap infomap;
112114
ASSERT_TRUE(
113115
TextFormat::ParseFromString("dtype: DT_DOUBLE", &infomap["default"]));
@@ -116,20 +118,22 @@ TEST(JsontensorTest, IntegerInputForDoubleTensor) {
116118
JsonPredictRequestFormat format;
117119
TF_EXPECT_OK(FillPredictRequestFromJson(R"(
118120
{
119-
"instances": [1, 2, 3, 4, 5]
121+
"instances": [1.0, 2, 3, 4, 0.662, 0, 0.0]
120122
})",
121123
getmap(infomap), &req, &format));
122124
auto tmap = req.inputs();
123125
EXPECT_EQ(tmap.size(), 1);
124126
EXPECT_EQ(format, JsonPredictRequestFormat::kRow);
125127
EXPECT_THAT(tmap["default"], EqualsProto(R"(
126128
dtype: DT_DOUBLE
127-
tensor_shape { dim { size: 5 } }
128-
double_val: 1
129+
tensor_shape { dim { size: 7 } }
130+
double_val: 1.0
129131
double_val: 2
130132
double_val: 3
131133
double_val: 4
132-
double_val: 5
134+
double_val: 0.662
135+
double_val: 0
136+
double_val: 0.0
133137
)"));
134138
}
135139

tools/bazel.rc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ build -c opt
3333
# Adding --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0" creates parity with TF
3434
# compilation options. It also addresses memory use due to
3535
# copy-on-write semantics of std::strings of the older ABI.
36-
build --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0
36+
build --cxxopt=-D_GLIBCXX_USE_CXX11_ABI=0
37+
38+
build --workspace_status_command=/proc/self/cwd/tools/gen_status_stamp.sh

tools/bazel_in_docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function get_switch_user_cmd() {
4646
local username=$(id -n -u)
4747
local groupname=$(id -n -g)
4848
local cmdline="groupadd -f ${groupname} && groupmod -o -g ${gid} ${groupname}"
49-
cmdline+="; id -u ${username} &>/dev/null || useradd ${username} && usermod -o -u ${uid} -g ${gid} ${username}"
49+
cmdline+="; id -u ${username} &>/dev/null || useradd -N ${username} && usermod -o -u ${uid} -g ${gid} ${username}"
5050
cmdline+="; chroot --userspec=${username} / "
5151
echo "${cmdline}"
5252
}

tools/gen_status_stamp.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ==============================================================================
16+
17+
# This script will be run by the building process to generate key-value
18+
# information that represents the status of the workspace. The output should be
19+
# in the format:
20+
#
21+
# KEY1 VALUE1
22+
# KEY2 VALUE2
23+
#
24+
# If the script exits with non-zero code, it's considered as a failure
25+
# and the output will be discarded.
26+
27+
# if we're inside a git tree
28+
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1; then
29+
git_rev=$(git rev-parse --short HEAD)
30+
if [[ $? != 0 ]];
31+
then
32+
exit 1
33+
fi
34+
echo "BUILD_SCM_REVISION ${git_rev}"
35+
else
36+
echo "BUILD_SCM_REVISION no_git"
37+
fi;
38+
39+

0 commit comments

Comments
 (0)