aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-08-27 11:01:09 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-08-27 11:12:14 -0700
commit8b05705ce58d264d09330531eea0c0701cc07ae2 (patch)
treeb6ad2bacaa4b07938ade9d37b019e23e00eed569
parentbf0382b3d05c86485589c792ed914dfd043ff89b (diff)
Replaced calls to tensorflow::StringPiece::ToString with std::string conversions.
That is, instances of sp.ToString() are replaced with string(sp). This will allow tensorflow::StringPiece::ToString to be removed, which is necessary before it can be replaced with absl::string_view. PiperOrigin-RevId: 210394878
-rw-r--r--tensorflow/cc/saved_model/loader.cc4
-rw-r--r--tensorflow/contrib/android/asset_manager_filesystem.cc4
-rw-r--r--tensorflow/contrib/data/kernels/csv_dataset_op.cc2
-rw-r--r--tensorflow/core/common_runtime/eager/attr_builder.h4
-rw-r--r--tensorflow/core/common_runtime/graph_execution_state.cc4
-rw-r--r--tensorflow/core/framework/function_testlib.cc4
-rw-r--r--tensorflow/core/graph/tensor_id.cc2
-rw-r--r--tensorflow/core/grappler/optimizers/data/graph_utils.cc14
-rw-r--r--tensorflow/core/grappler/optimizers/data/map_and_filter_fusion_test.cc4
-rw-r--r--tensorflow/core/grappler/optimizers/data/map_fusion_test.cc2
-rw-r--r--tensorflow/core/grappler/optimizers/data/map_vectorization_test.cc10
-rw-r--r--tensorflow/core/grappler/optimizers/scoped_allocator_optimizer.cc2
-rw-r--r--tensorflow/core/lib/io/path_test.cc6
-rw-r--r--tensorflow/core/platform/cloud/compute_engine_zone_provider.cc2
-rw-r--r--tensorflow/tools/graph_transforms/fold_constants_lib.cc2
15 files changed, 33 insertions, 33 deletions
diff --git a/tensorflow/cc/saved_model/loader.cc b/tensorflow/cc/saved_model/loader.cc
index 222e769881..c6abe2f41b 100644
--- a/tensorflow/cc/saved_model/loader.cc
+++ b/tensorflow/cc/saved_model/loader.cc
@@ -148,7 +148,7 @@ Status RunMainOp(const RunOptions& run_options, const string& export_dir,
AddAssetsTensorsToInputs(export_dir, asset_file_defs, &inputs);
RunMetadata run_metadata;
const StringPiece main_op_name = main_op_it->second.node_list().value(0);
- return RunOnce(run_options, inputs, {}, {main_op_name.ToString()},
+ return RunOnce(run_options, inputs, {}, {string(main_op_name)},
nullptr /* outputs */, &run_metadata, session);
}
return Status::OK();
@@ -187,7 +187,7 @@ Status RunRestore(const RunOptions& run_options, const string& export_dir,
AddAssetsTensorsToInputs(export_dir, asset_file_defs, &inputs);
RunMetadata run_metadata;
- return RunOnce(run_options, inputs, {}, {restore_op_name.ToString()},
+ return RunOnce(run_options, inputs, {}, {string(restore_op_name)},
nullptr /* outputs */, &run_metadata, session);
}
diff --git a/tensorflow/contrib/android/asset_manager_filesystem.cc b/tensorflow/contrib/android/asset_manager_filesystem.cc
index 513d519eab..d14b2126a0 100644
--- a/tensorflow/contrib/android/asset_manager_filesystem.cc
+++ b/tensorflow/contrib/android/asset_manager_filesystem.cc
@@ -28,7 +28,7 @@ string RemoveSuffix(const string& name, const string& suffix) {
string output(name);
StringPiece piece(output);
str_util::ConsumeSuffix(&piece, suffix);
- return piece.ToString();
+ return string(piece);
}
// Closes the given AAsset when variable is destructed.
@@ -231,7 +231,7 @@ string AssetManagerFileSystem::NormalizeDirectoryPath(const string& fname) {
string AssetManagerFileSystem::RemoveAssetPrefix(const string& name) {
StringPiece piece(name);
str_util::ConsumePrefix(&piece, prefix_);
- return piece.ToString();
+ return string(piece);
}
bool AssetManagerFileSystem::DirectoryExists(const std::string& fname) {
diff --git a/tensorflow/contrib/data/kernels/csv_dataset_op.cc b/tensorflow/contrib/data/kernels/csv_dataset_op.cc
index d242cfdf49..0ba905b92e 100644
--- a/tensorflow/contrib/data/kernels/csv_dataset_op.cc
+++ b/tensorflow/contrib/data/kernels/csv_dataset_op.cc
@@ -713,7 +713,7 @@ class CSVDatasetOp : public DatasetOpKernel {
component.scalar<string>()() =
dataset()->record_defaults_[output_idx].flat<string>()(0);
} else {
- component.scalar<string>()() = field.ToString();
+ component.scalar<string>()() = string(field);
}
break;
}
diff --git a/tensorflow/core/common_runtime/eager/attr_builder.h b/tensorflow/core/common_runtime/eager/attr_builder.h
index ccc95a35e5..cbe6a1cb50 100644
--- a/tensorflow/core/common_runtime/eager/attr_builder.h
+++ b/tensorflow/core/common_runtime/eager/attr_builder.h
@@ -122,12 +122,12 @@ class AttrBuilder {
AttrValue attr_value;
if (found == nullptr) {
SetAttrValue(value, &attr_value);
- m->insert(AttrValueMap::value_type(attr_name.ToString(), attr_value));
+ m->insert(AttrValueMap::value_type(string(attr_name), attr_value));
} else {
// TODO(ashankar): Do what is done in
// NodeDefBuilder::CheckInconsistency(attr_name, *found, attr_value);
SetAttrValue(std::forward<T>(value), &attr_value);
- (*m)[attr_name.ToString()] = attr_value;
+ (*m)[string(attr_name)] = attr_value;
}
}
diff --git a/tensorflow/core/common_runtime/graph_execution_state.cc b/tensorflow/core/common_runtime/graph_execution_state.cc
index c23b7d3699..346befc255 100644
--- a/tensorflow/core/common_runtime/graph_execution_state.cc
+++ b/tensorflow/core/common_runtime/graph_execution_state.cc
@@ -581,7 +581,7 @@ Status GraphExecutionState::OptimizeGraph(
if (id.second != 0) {
return errors::InvalidArgument("Unsupported feed: ", feed);
}
- feeds.insert(id.first.ToString());
+ feeds.emplace(id.first);
}
for (const TensorConnection& tensor_connection :
options.callable_options.tensor_connection()) {
@@ -590,7 +590,7 @@ Status GraphExecutionState::OptimizeGraph(
return errors::InvalidArgument("Unsupported feed: ",
tensor_connection.to_tensor());
}
- feeds.insert(id.first.ToString());
+ feeds.emplace(id.first);
}
for (const NodeDef& node : original_graph_def_.node()) {
if (feeds.find(node.name()) == feeds.end()) {
diff --git a/tensorflow/core/framework/function_testlib.cc b/tensorflow/core/framework/function_testlib.cc
index 41270b8e5e..6e38256ba8 100644
--- a/tensorflow/core/framework/function_testlib.cc
+++ b/tensorflow/core/framework/function_testlib.cc
@@ -49,8 +49,8 @@ NodeDef NDef(StringPiece name, StringPiece op, gtl::ArraySlice<string> inputs,
gtl::ArraySlice<std::pair<string, FDH::AttrValueWrapper>> attrs,
const string& device) {
NodeDef n;
- n.set_name(name.ToString());
- n.set_op(op.ToString());
+ n.set_name(string(name));
+ n.set_op(string(op));
for (const auto& in : inputs) n.add_input(in);
n.set_device(device);
for (auto na : attrs) n.mutable_attr()->insert({na.first, na.second.proto});
diff --git a/tensorflow/core/graph/tensor_id.cc b/tensorflow/core/graph/tensor_id.cc
index 80c76df255..5a5b85e727 100644
--- a/tensorflow/core/graph/tensor_id.cc
+++ b/tensorflow/core/graph/tensor_id.cc
@@ -25,7 +25,7 @@ namespace tensorflow {
TensorId::TensorId(const SafeTensorId& id) : TensorId(id.first, id.second) {}
SafeTensorId::SafeTensorId(const TensorId& id)
- : SafeTensorId(id.first.ToString(), id.second) {}
+ : SafeTensorId(string(id.first), id.second) {}
TensorId ParseTensorName(const string& name) {
return ParseTensorName(StringPiece(name.data(), name.size()));
diff --git a/tensorflow/core/grappler/optimizers/data/graph_utils.cc b/tensorflow/core/grappler/optimizers/data/graph_utils.cc
index 883037173b..5a7fe19265 100644
--- a/tensorflow/core/grappler/optimizers/data/graph_utils.cc
+++ b/tensorflow/core/grappler/optimizers/data/graph_utils.cc
@@ -94,11 +94,11 @@ NodeDef* AddNode(StringPiece name, StringPiece op,
MutableGraphView* graph) {
NodeDef node;
if (!name.empty()) {
- node.set_name(name.ToString());
+ node.set_name(string(name));
} else {
SetUniqueGraphNodeName(op, graph->GetGraph(), &node);
}
- node.set_op(op.ToString());
+ node.set_op(string(op));
for (const string& input : inputs) {
node.add_input(input);
}
@@ -114,11 +114,11 @@ NodeDef* AddNode(StringPiece name, StringPiece op,
FunctionDef* fd) {
NodeDef* node = fd->add_node_def();
if (!name.empty()) {
- node->set_name(name.ToString());
+ node->set_name(string(name));
} else {
SetUniqueFunctionNodeName(op, fd, node);
}
- node->set_op(op.ToString());
+ node->set_op(string(op));
for (const string& input : inputs) {
node->add_input(input);
}
@@ -270,7 +270,7 @@ NodeDef* GetInputNode(const NodeDef& node, const MutableGraphView& graph) {
void SetUniqueGraphNodeName(StringPiece prefix, GraphDef* graph,
NodeDef* node) {
- string name = prefix.ToString();
+ string name = string(prefix);
int id = graph->node_size();
while (ContainsGraphNodeWithName(name, *graph)) {
if (name.rfind("_generated") != std::string::npos &&
@@ -286,7 +286,7 @@ void SetUniqueGraphNodeName(StringPiece prefix, GraphDef* graph,
void SetUniqueFunctionNodeName(StringPiece prefix, FunctionDef* function,
NodeDef* node) {
- string name = prefix.ToString();
+ string name = string(prefix);
int id = function->node_def_size();
while (ContainsFunctionNodeWithName(name, *function)) {
name = strings::StrCat(prefix, "/_", id);
@@ -297,7 +297,7 @@ void SetUniqueFunctionNodeName(StringPiece prefix, FunctionDef* function,
void SetUniqueGraphFunctionName(StringPiece prefix, FunctionDefLibrary* library,
FunctionDef* function) {
- string name = prefix.ToString();
+ string name = string(prefix);
int id = library->function_size();
while (ContainsGraphFunctionWithName(name, *library)) {
name = strings::StrCat(prefix, "/_", id);
diff --git a/tensorflow/core/grappler/optimizers/data/map_and_filter_fusion_test.cc b/tensorflow/core/grappler/optimizers/data/map_and_filter_fusion_test.cc
index 3b6829ade3..f029a093fa 100644
--- a/tensorflow/core/grappler/optimizers/data/map_and_filter_fusion_test.cc
+++ b/tensorflow/core/grappler/optimizers/data/map_and_filter_fusion_test.cc
@@ -30,7 +30,7 @@ namespace {
NodeDef MakeMapNode(StringPiece name, StringPiece input_node_name) {
return test::function::NDef(
- name, "MapDataset", {input_node_name.ToString()},
+ name, "MapDataset", {string(input_node_name)},
{{"f", FunctionDefHelper::FunctionRef("XTimesTwo")},
{"Targuments", {}},
{"output_shapes", {}},
@@ -39,7 +39,7 @@ NodeDef MakeMapNode(StringPiece name, StringPiece input_node_name) {
NodeDef MakeFilterNode(StringPiece name, StringPiece input_node_name) {
return test::function::NDef(
- name, "FilterDataset", {input_node_name.ToString()},
+ name, "FilterDataset", {string(input_node_name)},
{{"predicate", FunctionDefHelper::FunctionRef("IsZero")},
{"Targuments", {}},
{"output_shapes", {}},
diff --git a/tensorflow/core/grappler/optimizers/data/map_fusion_test.cc b/tensorflow/core/grappler/optimizers/data/map_fusion_test.cc
index df6c19dc7c..b25dfbd0b8 100644
--- a/tensorflow/core/grappler/optimizers/data/map_fusion_test.cc
+++ b/tensorflow/core/grappler/optimizers/data/map_fusion_test.cc
@@ -30,7 +30,7 @@ namespace {
NodeDef MakeMapNode(StringPiece name, StringPiece input_node_name) {
return test::function::NDef(
- name, "MapDataset", {input_node_name.ToString()},
+ name, "MapDataset", {string(input_node_name)},
{{"f", FunctionDefHelper::FunctionRef("XTimesTwo")},
{"Targuments", {}},
{"output_shapes", {}},
diff --git a/tensorflow/core/grappler/optimizers/data/map_vectorization_test.cc b/tensorflow/core/grappler/optimizers/data/map_vectorization_test.cc
index be2475bae8..ed1bd6bc97 100644
--- a/tensorflow/core/grappler/optimizers/data/map_vectorization_test.cc
+++ b/tensorflow/core/grappler/optimizers/data/map_vectorization_test.cc
@@ -55,8 +55,8 @@ NodeDef MakeMapNodeHelper(
const gtl::ArraySlice<const gtl::ArraySlice<int>>& output_shapes,
const gtl::ArraySlice<DataType>& output_types) {
return test::function::NDef(
- name, map_op_name, {input_node_name.ToString()},
- {{"f", FunctionDefHelper::FunctionRef(function_name.ToString())},
+ name, map_op_name, {string(input_node_name)},
+ {{"f", FunctionDefHelper::FunctionRef(string(function_name))},
{"Targuments", {}},
{"output_shapes", MakeShapeListAttr(output_shapes)},
{"output_types", output_types}});
@@ -76,7 +76,7 @@ NodeDef MakeBatchNode(
const gtl::ArraySlice<const gtl::ArraySlice<int>>& output_shapes,
const gtl::ArraySlice<DataType>& output_types) {
return NDef(name, "BatchDataset",
- {input_node_name.ToString(), input_batch_size_name.ToString()},
+ {string(input_node_name), string(input_batch_size_name)},
{{"output_types", output_types},
{"output_shapes", MakeShapeListAttr(output_shapes)}});
}
@@ -87,8 +87,8 @@ NodeDef MakeBatchV2Node(
const gtl::ArraySlice<const gtl::ArraySlice<int>>& output_shapes,
const gtl::ArraySlice<DataType>& output_types) {
return NDef(name, "BatchDatasetV2",
- {input_node_name.ToString(), input_batch_size_name.ToString(),
- input_drop_remainder_name.ToString()},
+ {string(input_node_name), string(input_batch_size_name),
+ string(input_drop_remainder_name)},
{{"output_types", output_types},
{"output_shapes", MakeShapeListAttr(output_shapes)}});
}
diff --git a/tensorflow/core/grappler/optimizers/scoped_allocator_optimizer.cc b/tensorflow/core/grappler/optimizers/scoped_allocator_optimizer.cc
index 275568e464..0d4aaf6462 100644
--- a/tensorflow/core/grappler/optimizers/scoped_allocator_optimizer.cc
+++ b/tensorflow/core/grappler/optimizers/scoped_allocator_optimizer.cc
@@ -203,7 +203,7 @@ void ScopedAllocatorOptimizer::ExtendNodeAttr(StringPiece name,
NodeDef* node_def) {
if (HasNodeAttr(*node_def, name)) {
VLOG(2) << "extending";
- AttrValue* existing = &(*node_def->mutable_attr())[name.ToString()];
+ AttrValue* existing = &(*node_def->mutable_attr())[string(name)];
for (int32 i : values) {
existing->mutable_list()->add_i(i);
}
diff --git a/tensorflow/core/lib/io/path_test.cc b/tensorflow/core/lib/io/path_test.cc
index e3275b93b6..0090b9100c 100644
--- a/tensorflow/core/lib/io/path_test.cc
+++ b/tensorflow/core/lib/io/path_test.cc
@@ -104,9 +104,9 @@ TEST(PathTest, CleanPath) {
StringPiece u(uri); \
StringPiece s, h, p; \
ParseURI(u, &s, &h, &p); \
- EXPECT_EQ(scheme, s.ToString()); \
- EXPECT_EQ(host, h.ToString()); \
- EXPECT_EQ(path, p.ToString()); \
+ EXPECT_EQ(scheme, s); \
+ EXPECT_EQ(host, h); \
+ EXPECT_EQ(path, p); \
EXPECT_EQ(uri, CreateURI(scheme, host, path)); \
EXPECT_LE(u.begin(), s.begin()); \
EXPECT_GE(u.end(), s.begin()); \
diff --git a/tensorflow/core/platform/cloud/compute_engine_zone_provider.cc b/tensorflow/core/platform/cloud/compute_engine_zone_provider.cc
index dacf56187c..e147d88371 100644
--- a/tensorflow/core/platform/cloud/compute_engine_zone_provider.cc
+++ b/tensorflow/core/platform/cloud/compute_engine_zone_provider.cc
@@ -43,7 +43,7 @@ Status ComputeEngineZoneProvider::GetZone(string* zone) {
*zone = cached_zone;
} else {
LOG(ERROR) << "Failed to parse the zone name from location: "
- << location.ToString();
+ << string(location);
}
return Status::OK();
diff --git a/tensorflow/tools/graph_transforms/fold_constants_lib.cc b/tensorflow/tools/graph_transforms/fold_constants_lib.cc
index f858411876..6df2718e61 100644
--- a/tensorflow/tools/graph_transforms/fold_constants_lib.cc
+++ b/tensorflow/tools/graph_transforms/fold_constants_lib.cc
@@ -121,7 +121,7 @@ Status RewriteInputsAsPlaceholders(const TransformFuncContext& context,
GraphDef* graph_def) {
std::unordered_set<string> input_names;
for (const string& input_name : context.input_names) {
- input_names.insert(ParseTensorName(input_name).first.ToString());
+ input_names.emplace(ParseTensorName(input_name).first);
}
for (NodeDef& node : *graph_def->mutable_node()) {