aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/example
diff options
context:
space:
mode:
authorGravatar Shanqing Cai <cais@google.com>2016-09-11 10:03:45 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-09-11 11:17:31 -0700
commit645a554a41ef5524e7ec65beeb7976c066886da6 (patch)
treead90a0ec2b833e20941db4aad3c7a5f24b4df0ff /tensorflow/core/example
parentd49688f9c2f2acf33a408a1e010f4cc6623b93d0 (diff)
Update OSS protobuf git depedency version to 3.0.2
3.0.2 is the latest release. Add a level of indirection to the int64 type in 1) core/example/feature_util.h, feature_util.cc and the places where the type is used 2) tools/proto_text/gen_proto_text_functions_lib.cc and its tests. This is for dealing with the variability of "int64" type definition among different platforms. On some systems, int64 is "long int", while on others it is "long long int". See GitHub Issue for more details: https://github.com/tensorflow/tensorflow/issues/3626. This change list fixes the issue and eliminates the need to stick to an old (3.0.0-beta-2) commit of protobuf. Change: 132814372
Diffstat (limited to 'tensorflow/core/example')
-rw-r--r--tensorflow/core/example/feature_util.cc9
-rw-r--r--tensorflow/core/example/feature_util.h15
-rw-r--r--tensorflow/core/example/feature_util_test.cc27
3 files changed, 27 insertions, 24 deletions
diff --git a/tensorflow/core/example/feature_util.cc b/tensorflow/core/example/feature_util.cc
index ddd2435a95..6f3cc6c6c5 100644
--- a/tensorflow/core/example/feature_util.cc
+++ b/tensorflow/core/example/feature_util.cc
@@ -28,7 +28,8 @@ namespace internal {
} // namespace internal
template <>
-bool ExampleHasFeature<int64>(const string& name, const Example& example) {
+bool ExampleHasFeature<protobuf_int64>(const string& name,
+ const Example& example) {
auto it = example.features().feature().find(name);
return (it != example.features().feature().end()) &&
(it->second.kind_case() == Feature::KindCase::kInt64List);
@@ -49,14 +50,14 @@ bool ExampleHasFeature<string>(const string& name, const Example& example) {
}
template <>
-const protobuf::RepeatedField<int64>& GetFeatureValues<int64>(
+const protobuf::RepeatedField<protobuf_int64>& GetFeatureValues<protobuf_int64>(
const string& name, const Example& example) {
return example.features().feature().at(name).int64_list().value();
}
template <>
-protobuf::RepeatedField<int64>* GetFeatureValues<int64>(const string& name,
- Example* example) {
+protobuf::RepeatedField<protobuf_int64>* GetFeatureValues<protobuf_int64>(
+ const string& name, Example* example) {
return internal::ExampleFeature(name, example)
.mutable_int64_list()
->mutable_value();
diff --git a/tensorflow/core/example/feature_util.h b/tensorflow/core/example/feature_util.h
index 048930d235..4004411cb1 100644
--- a/tensorflow/core/example/feature_util.h
+++ b/tensorflow/core/example/feature_util.h
@@ -73,8 +73,8 @@ template <typename FeatureType>
struct RepeatedFieldTrait;
template <>
-struct RepeatedFieldTrait<int64> {
- using Type = protobuf::RepeatedField<int64>;
+struct RepeatedFieldTrait<protobuf_int64> {
+ using Type = protobuf::RepeatedField<protobuf_int64>;
};
template <>
@@ -95,7 +95,7 @@ struct FeatureTrait;
template <typename ValueType>
struct FeatureTrait<ValueType, typename std::enable_if<
std::is_integral<ValueType>::value>::type> {
- using Type = int64;
+ using Type = protobuf_int64;
};
template <typename ValueType>
@@ -178,7 +178,8 @@ void AppendFeatureValues(std::initializer_list<ValueType> container,
}
template <>
-bool ExampleHasFeature<int64>(const string& name, const Example& example);
+bool ExampleHasFeature<protobuf_int64>(const string& name,
+ const Example& example);
template <>
bool ExampleHasFeature<float>(const string& name, const Example& example);
@@ -187,12 +188,12 @@ template <>
bool ExampleHasFeature<string>(const string& name, const Example& example);
template <>
-const protobuf::RepeatedField<int64>& GetFeatureValues<int64>(
+const protobuf::RepeatedField<protobuf_int64>& GetFeatureValues<protobuf_int64>(
const string& name, const Example& example);
template <>
-protobuf::RepeatedField<int64>* GetFeatureValues<int64>(const string& name,
- Example* example);
+protobuf::RepeatedField<protobuf_int64>* GetFeatureValues<protobuf_int64>(
+ const string& name, Example* example);
template <>
const protobuf::RepeatedField<float>& GetFeatureValues<float>(
diff --git a/tensorflow/core/example/feature_util_test.cc b/tensorflow/core/example/feature_util_test.cc
index 9e1d645118..eb7b90af1b 100644
--- a/tensorflow/core/example/feature_util_test.cc
+++ b/tensorflow/core/example/feature_util_test.cc
@@ -32,7 +32,7 @@ TEST(GetFeatureValuesInt64Test, ReadsASingleValue) {
.mutable_int64_list()
->add_value(42);
- auto tag = GetFeatureValues<int64>("tag", example);
+ auto tag = GetFeatureValues<protobuf_int64>("tag", example);
ASSERT_EQ(1, tag.size());
EXPECT_EQ(42, tag.Get(0));
@@ -41,7 +41,7 @@ TEST(GetFeatureValuesInt64Test, ReadsASingleValue) {
TEST(GetFeatureValuesInt64Test, WritesASingleValue) {
Example example;
- GetFeatureValues<int64>("tag", &example)->Add(42);
+ GetFeatureValues<protobuf_int64>("tag", &example)->Add(42);
ASSERT_EQ(1,
example.features().feature().at("tag").int64_list().value_size());
@@ -53,7 +53,7 @@ TEST(GetFeatureValuesInt64Test, CheckUntypedFieldExistence) {
EXPECT_FALSE(ExampleHasFeature("tag", example));
- GetFeatureValues<int64>("tag", &example)->Add(0);
+ GetFeatureValues<protobuf_int64>("tag", &example)->Add(0);
EXPECT_TRUE(ExampleHasFeature("tag", example));
}
@@ -62,12 +62,12 @@ TEST(GetFeatureValuesInt64Test, CheckTypedFieldExistence) {
Example example;
GetFeatureValues<float>("tag", &example)->Add(3.14);
- ASSERT_FALSE(ExampleHasFeature<int64>("tag", example));
+ ASSERT_FALSE(ExampleHasFeature<protobuf_int64>("tag", example));
- GetFeatureValues<int64>("tag", &example)->Add(42);
+ GetFeatureValues<protobuf_int64>("tag", &example)->Add(42);
- EXPECT_TRUE(ExampleHasFeature<int64>("tag", example));
- auto tag_ro = GetFeatureValues<int64>("tag", example);
+ EXPECT_TRUE(ExampleHasFeature<protobuf_int64>("tag", example));
+ auto tag_ro = GetFeatureValues<protobuf_int64>("tag", example);
ASSERT_EQ(1, tag_ro.size());
EXPECT_EQ(42, tag_ro.Get(0));
}
@@ -78,9 +78,9 @@ TEST(GetFeatureValuesInt64Test, CopyIterableToAField) {
std::copy(values.begin(), values.end(),
protobuf::RepeatedFieldBackInserter(
- GetFeatureValues<int64>("tag", &example)));
+ GetFeatureValues<protobuf_int64>("tag", &example)));
- auto tag_ro = GetFeatureValues<int64>("tag", example);
+ auto tag_ro = GetFeatureValues<protobuf_int64>("tag", example);
ASSERT_EQ(3, tag_ro.size());
EXPECT_EQ(1, tag_ro.Get(0));
EXPECT_EQ(2, tag_ro.Get(1));
@@ -114,7 +114,7 @@ TEST(GetFeatureValuesFloatTest, WritesASingleValue) {
TEST(GetFeatureValuesFloatTest, CheckTypedFieldExistence) {
Example example;
- GetFeatureValues<int64>("tag", &example)->Add(42);
+ GetFeatureValues<protobuf_int64>("tag", &example)->Add(42);
ASSERT_FALSE(ExampleHasFeature<float>("tag", example));
GetFeatureValues<float>("tag", &example)->Add(3.14);
@@ -151,7 +151,7 @@ TEST(GetFeatureValuesStringTest, WritesASingleValue) {
TEST(GetFeatureValuesBytesTest, CheckTypedFieldExistence) {
Example example;
- GetFeatureValues<int64>("tag", &example)->Add(42);
+ GetFeatureValues<protobuf_int64>("tag", &example)->Add(42);
ASSERT_FALSE(ExampleHasFeature<string>("tag", example));
*GetFeatureValues<string>("tag", &example)->Add() = "FOO";
@@ -190,9 +190,10 @@ TEST(AppendFeatureValuesTest, FloatValuesUsingInitializerList) {
TEST(AppendFeatureValuesTest, Int64ValuesUsingInitializerList) {
Example example;
- AppendFeatureValues({1, 2, 3}, "tag", &example);
+ std::vector<protobuf_int64> values{1, 2, 3};
+ AppendFeatureValues(values, "tag", &example);
- auto tag_ro = GetFeatureValues<int64>("tag", example);
+ auto tag_ro = GetFeatureValues<protobuf_int64>("tag", example);
ASSERT_EQ(3, tag_ro.size());
EXPECT_EQ(1, tag_ro.Get(0));
EXPECT_EQ(2, tag_ro.Get(1));