Replaced calls to tensorflow::StringPiece::ToString with std::string conversions.

That is, instances of sp.ToString() are replaced with std::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: 195162126
This commit is contained in:
Peter Hawkins 2018-05-02 16:22:41 -07:00 committed by Yifei Feng
parent 4704ae7af1
commit 5e9e6967b4
24 changed files with 62 additions and 63 deletions

View File

@ -2097,7 +2097,7 @@ static void GraphImportGraphDefLocked(TF_Graph* graph, const GraphDef& def,
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
TensorId id = results.missing_unused_input_map_keys[i]; TensorId id = results.missing_unused_input_map_keys[i];
tf_results->missing_unused_key_names_data.push_back(id.first.ToString()); tf_results->missing_unused_key_names_data.push_back(std::string(id.first));
tf_results->missing_unused_key_names[i] = tf_results->missing_unused_key_names[i] =
tf_results->missing_unused_key_names_data.back().c_str(); tf_results->missing_unused_key_names_data.back().c_str();
tf_results->missing_unused_key_indexes[i] = id.second; tf_results->missing_unused_key_indexes[i] = id.second;

View File

@ -1368,7 +1368,7 @@ TEST(CAPI, SavedModel) {
} }
const tensorflow::string input_op_name = const tensorflow::string input_op_name =
tensorflow::ParseTensorName(input_name).first.ToString(); std::string(tensorflow::ParseTensorName(input_name).first);
TF_Operation* input_op = TF_Operation* input_op =
TF_GraphOperationByName(graph, input_op_name.c_str()); TF_GraphOperationByName(graph, input_op_name.c_str());
ASSERT_TRUE(input_op != nullptr); ASSERT_TRUE(input_op != nullptr);
@ -1376,7 +1376,7 @@ TEST(CAPI, SavedModel) {
ASSERT_EQ(TF_OK, TF_GetCode(s)) << TF_Message(s); ASSERT_EQ(TF_OK, TF_GetCode(s)) << TF_Message(s);
const tensorflow::string output_op_name = const tensorflow::string output_op_name =
tensorflow::ParseTensorName(output_name).first.ToString(); std::string(tensorflow::ParseTensorName(output_name).first);
TF_Operation* output_op = TF_Operation* output_op =
TF_GraphOperationByName(graph, output_op_name.c_str()); TF_GraphOperationByName(graph, output_op_name.c_str());
ASSERT_TRUE(output_op != nullptr); ASSERT_TRUE(output_op != nullptr);

View File

@ -125,7 +125,7 @@ CheckpointReader::BuildV2VarMaps() {
const auto& slice_proto = entry.slices(i); const auto& slice_proto = entry.slices(i);
CHECK(filtered_keys CHECK(filtered_keys
.insert(EncodeTensorNameSlice( .insert(EncodeTensorNameSlice(
v2_reader_->key().ToString() /* full var's name */, std::string(v2_reader_->key()) /* full var's name */,
TensorSlice(slice_proto))) TensorSlice(slice_proto)))
.second); .second);
} }
@ -138,11 +138,11 @@ CheckpointReader::BuildV2VarMaps() {
new TensorSliceReader::VarToDataTypeMap); new TensorSliceReader::VarToDataTypeMap);
v2_reader_->Seek(kHeaderEntryKey); v2_reader_->Seek(kHeaderEntryKey);
for (v2_reader_->Next(); v2_reader_->Valid(); v2_reader_->Next()) { for (v2_reader_->Next(); v2_reader_->Valid(); v2_reader_->Next()) {
if (filtered_keys.count(v2_reader_->key().ToString()) > 0) continue; if (filtered_keys.count(std::string(v2_reader_->key())) > 0) continue;
CHECK(entry.ParseFromArray(v2_reader_->value().data(), CHECK(entry.ParseFromArray(v2_reader_->value().data(),
v2_reader_->value().size())) v2_reader_->value().size()))
<< entry.InitializationErrorString(); << entry.InitializationErrorString();
string key = v2_reader_->key().ToString(); string key = std::string(v2_reader_->key());
(*var_to_shape_map)[key] = TensorShape(entry.shape()); (*var_to_shape_map)[key] = TensorShape(entry.shape());
(*var_to_data_type_map)[key] = DataType(entry.dtype()); (*var_to_data_type_map)[key] = DataType(entry.dtype());
} }

View File

@ -511,7 +511,7 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
break; break;
} else if (must_end) { } else if (must_end) {
return InvalidArgument("Expected end of tuple; got: \"%s\"", return InvalidArgument("Expected end of tuple; got: \"%s\"",
s->ToString().c_str()); std::string(*s).c_str());
} }
shapes.emplace_back(); shapes.emplace_back();
TF_ASSIGN_OR_RETURN(shapes.back(), ParseShapeStringInternal(s)); TF_ASSIGN_OR_RETURN(shapes.back(), ParseShapeStringInternal(s));
@ -541,7 +541,7 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
if (!tensorflow::strings::safe_strto64(input.c_str(), &element)) { if (!tensorflow::strings::safe_strto64(input.c_str(), &element)) {
return InvalidArgument( return InvalidArgument(
"Invalid s64 value in parsed shape string: \"%s\" in \"%s\"", "Invalid s64 value in parsed shape string: \"%s\" in \"%s\"",
input.c_str(), s->ToString().c_str()); input.c_str(), std::string(*s).c_str());
} }
return element; return element;
}; };
@ -594,7 +594,7 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
} }
return InvalidArgument("Invalid shape string to parse: \"%s\"", return InvalidArgument("Invalid shape string to parse: \"%s\"",
s->ToString().c_str()); std::string(*s).c_str());
} }
} // namespace } // namespace
@ -603,7 +603,7 @@ StatusOr<Shape> ParseShapeStringInternal(tensorflow::StringPiece* s) {
TF_ASSIGN_OR_RETURN(Shape shape, ParseShapeStringInternal(&s)); TF_ASSIGN_OR_RETURN(Shape shape, ParseShapeStringInternal(&s));
if (!s.empty()) { if (!s.empty()) {
return InvalidArgument("Invalid shape string to parse: \"%s\"", return InvalidArgument("Invalid shape string to parse: \"%s\"",
s.ToString().c_str()); std::string(s).c_str());
} }
return shape; return shape;
} }

View File

@ -42,7 +42,7 @@ StatusOr<std::unique_ptr<Literal>> TextLiteralReader::ReadPath(
<< "TextLiteralReader no longer supports reading .gz files"; << "TextLiteralReader no longer supports reading .gz files";
std::unique_ptr<tensorflow::RandomAccessFile> file; std::unique_ptr<tensorflow::RandomAccessFile> file;
Status s = Status s =
tensorflow::Env::Default()->NewRandomAccessFile(path.ToString(), &file); tensorflow::Env::Default()->NewRandomAccessFile(std::string(path), &file);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }
@ -92,7 +92,7 @@ StatusOr<std::unique_ptr<Literal>> TextLiteralReader::ReadAllLines() {
tensorflow::StringPiece sp(shape_string); tensorflow::StringPiece sp(shape_string);
if (tensorflow::str_util::RemoveWhitespaceContext(&sp) > 0) { if (tensorflow::str_util::RemoveWhitespaceContext(&sp) > 0) {
string tmp = sp.ToString(); string tmp = std::string(sp);
shape_string = tmp; shape_string = tmp;
} }
TF_ASSIGN_OR_RETURN(Shape shape, ShapeUtil::ParseShapeString(shape_string)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeUtil::ParseShapeString(shape_string));
@ -124,10 +124,10 @@ StatusOr<std::unique_ptr<Literal>> TextLiteralReader::ReadAllLines() {
line.c_str()); line.c_str());
} }
float value; float value;
if (!tensorflow::strings::safe_strtof(value_string.ToString().c_str(), if (!tensorflow::strings::safe_strtof(std::string(value_string).c_str(),
&value)) { &value)) {
return InvalidArgument("could not parse value as float: \"%s\"", return InvalidArgument("could not parse value as float: \"%s\"",
value_string.ToString().c_str()); std::string(value_string).c_str());
} }
SplitByDelimToStringPieces(coordinates_string, ',', &coordinates); SplitByDelimToStringPieces(coordinates_string, ',', &coordinates);
coordinate_values.clear(); coordinate_values.clear();
@ -136,7 +136,7 @@ StatusOr<std::unique_ptr<Literal>> TextLiteralReader::ReadAllLines() {
if (!tensorflow::strings::safe_strto64(piece, &coordinate_value)) { if (!tensorflow::strings::safe_strto64(piece, &coordinate_value)) {
return InvalidArgument( return InvalidArgument(
"could not parse coordinate member as int64: \"%s\"", "could not parse coordinate member as int64: \"%s\"",
piece.ToString().c_str()); std::string(piece).c_str());
} }
coordinate_values.push_back(coordinate_value); coordinate_values.push_back(coordinate_value);
} }

View File

@ -33,7 +33,7 @@ namespace xla {
/* static */ tensorflow::Status TextLiteralWriter::WriteToPath( /* static */ tensorflow::Status TextLiteralWriter::WriteToPath(
const Literal& literal, tensorflow::StringPiece path) { const Literal& literal, tensorflow::StringPiece path) {
std::unique_ptr<tensorflow::WritableFile> f; std::unique_ptr<tensorflow::WritableFile> f;
auto s = tensorflow::Env::Default()->NewWritableFile(path.ToString(), &f); auto s = tensorflow::Env::Default()->NewWritableFile(std::string(path), &f);
if (!s.ok()) { if (!s.ok()) {
return s; return s;
} }

View File

@ -616,7 +616,7 @@ string BFCAllocator::RenderOccupancy() {
region_offset += region.memory_size(); region_offset += region.memory_size();
} }
return StringPiece(rendered, resolution).ToString(); return std::string(rendered, resolution);
} }
void BFCAllocator::DumpMemoryLog(size_t num_bytes) { void BFCAllocator::DumpMemoryLog(size_t num_bytes) {

View File

@ -56,7 +56,7 @@ class SimpleRendezvous : public Rendezvous {
} }
mutex_lock l(mu_); mutex_lock l(mu_);
string edge_name = parsed.edge_name.ToString(); string edge_name = std::string(parsed.edge_name);
if (table_.count(edge_name) > 0) { if (table_.count(edge_name) > 0) {
return errors::Internal("Send of an already sent tensor"); return errors::Internal("Send of an already sent tensor");
} }
@ -69,7 +69,7 @@ class SimpleRendezvous : public Rendezvous {
Tensor tensor; Tensor tensor;
Status status = Status::OK(); Status status = Status::OK();
{ {
string key = parsed.edge_name.ToString(); string key = std::string(parsed.edge_name);
mutex_lock l(mu_); mutex_lock l(mu_);
if (table_.count(key) <= 0) { if (table_.count(key) <= 0) {
status = errors::Internal("Did not find key ", key); status = errors::Internal("Did not find key ", key);

View File

@ -70,7 +70,7 @@ Status TensorStore::SaveTensors(const std::vector<string>& output_names,
// Save only the tensors in output_names in the session. // Save only the tensors in output_names in the session.
for (const string& name : output_names) { for (const string& name : output_names) {
TensorId id(ParseTensorName(name)); TensorId id(ParseTensorName(name));
const string& op_name = id.first.ToString(); const string& op_name = std::string(id.first);
auto it = tensors_.find(op_name); auto it = tensors_.find(op_name);
if (it != tensors_.end()) { if (it != tensors_.end()) {
// Save the tensor to the session state. // Save the tensor to the session state.

View File

@ -94,7 +94,7 @@ static int ExtractGpuWithStreamAll(string device_name) {
} else { } else {
// Convert the captured string into an integer. But first we need to put // Convert the captured string into an integer. But first we need to put
// the digits back in order // the digits back in order
string ordered_capture = capture.ToString(); string ordered_capture = std::string(capture);
std::reverse(ordered_capture.begin(), ordered_capture.end()); std::reverse(ordered_capture.begin(), ordered_capture.end());
int gpu_id; int gpu_id;
CHECK(strings::safe_strto32(ordered_capture, &gpu_id)); CHECK(strings::safe_strto32(ordered_capture, &gpu_id));
@ -123,7 +123,7 @@ static int ExtractGpuWithoutStream(string device_name) {
} else { } else {
// Convert the captured string into an integer. But first we need to put // Convert the captured string into an integer. But first we need to put
// the digits back in order // the digits back in order
string ordered_capture = capture.ToString(); string ordered_capture = std::string(capture);
std::reverse(ordered_capture.begin(), ordered_capture.end()); std::reverse(ordered_capture.begin(), ordered_capture.end());
int gpu_id; int gpu_id;
CHECK(strings::safe_strto32(ordered_capture, &gpu_id)); CHECK(strings::safe_strto32(ordered_capture, &gpu_id));
@ -170,7 +170,7 @@ void StepStatsCollector::BuildCostModel(
for (auto& itr : per_device_stats) { for (auto& itr : per_device_stats) {
const StringPiece device_name = itr.first; const StringPiece device_name = itr.first;
const int gpu_id = ExtractGpuWithoutStream(device_name.ToString()); const int gpu_id = ExtractGpuWithoutStream(std::string(device_name));
if (gpu_id >= 0) { if (gpu_id >= 0) {
// Reference the gpu hardware stats in addition to the regular stats // Reference the gpu hardware stats in addition to the regular stats
// for this gpu device if they're available. // for this gpu device if they're available.

View File

@ -38,15 +38,15 @@ void Collector::CollectMetricDescriptor(
mutex_lock l(mu_); mutex_lock l(mu_);
return collected_metrics_->metric_descriptor_map return collected_metrics_->metric_descriptor_map
.insert(std::make_pair( .insert(std::make_pair(
metric_def->name().ToString(), std::string(metric_def->name()),
std::unique_ptr<MetricDescriptor>(new MetricDescriptor()))) std::unique_ptr<MetricDescriptor>(new MetricDescriptor())))
.first->second.get(); .first->second.get();
}(); }();
metric_descriptor->name = metric_def->name().ToString(); metric_descriptor->name = std::string(metric_def->name());
metric_descriptor->description = metric_def->description().ToString(); metric_descriptor->description = std::string(metric_def->description());
for (const StringPiece label_name : metric_def->label_descriptions()) { for (const StringPiece label_name : metric_def->label_descriptions()) {
metric_descriptor->label_names.push_back(label_name.ToString()); metric_descriptor->label_names.push_back(std::string(label_name));
} }
metric_descriptor->metric_kind = metric_def->kind(); metric_descriptor->metric_kind = metric_def->kind();

View File

@ -72,7 +72,7 @@ class MetricCollector {
registration_time_millis_(registration_time_millis), registration_time_millis_(registration_time_millis),
collector_(collector), collector_(collector),
point_set_(point_set) { point_set_(point_set) {
point_set_->metric_name = metric_def->name().ToString(); point_set_->metric_name = std::string(metric_def->name());
} }
const MetricDef<metric_kind, Value, NumLabels>* const metric_def_; const MetricDef<metric_kind, Value, NumLabels>* const metric_def_;
@ -261,7 +261,7 @@ class Collector {
auto* const point_set = [&]() { auto* const point_set = [&]() {
mutex_lock l(mu_); mutex_lock l(mu_);
return collected_metrics_->point_set_map return collected_metrics_->point_set_map
.insert(std::make_pair(metric_def->name().ToString(), .insert(std::make_pair(std::string(metric_def->name()),
std::unique_ptr<PointSet>(new PointSet()))) std::unique_ptr<PointSet>(new PointSet())))
.first->second.get(); .first->second.get();
}(); }();

View File

@ -98,8 +98,8 @@ class AbstractMetricDef {
const std::vector<string>& label_descriptions) const std::vector<string>& label_descriptions)
: kind_(kind), : kind_(kind),
value_type_(value_type), value_type_(value_type),
name_(name.ToString()), name_(std::string(name)),
description_(description.ToString()), description_(std::string(description)),
label_descriptions_(std::vector<string>(label_descriptions.begin(), label_descriptions_(std::vector<string>(label_descriptions.begin(),
label_descriptions.end())) {} label_descriptions.end())) {}

View File

@ -407,9 +407,9 @@ size_t CurlHttpRequest::HeaderCallback(const void* ptr, size_t size,
.StopCapture() .StopCapture()
.OneLiteral(": ") .OneLiteral(": ")
.GetResult(&value, &name)) { .GetResult(&value, &name)) {
string str_value = value.ToString(); string str_value = std::string(value);
str_util::StripTrailingWhitespace(&str_value); str_util::StripTrailingWhitespace(&str_value);
that->response_headers_[name.ToString()] = str_value; that->response_headers_[std::string(name)] = str_value;
} }
return size * nmemb; return size * nmemb;
} }

View File

@ -167,13 +167,13 @@ Status ParseGcsPath(StringPiece fname, bool empty_object_ok, string* bucket,
return errors::InvalidArgument("GCS path doesn't start with 'gs://': ", return errors::InvalidArgument("GCS path doesn't start with 'gs://': ",
fname); fname);
} }
*bucket = bucketp.ToString(); *bucket = std::string(bucketp);
if (bucket->empty() || *bucket == ".") { if (bucket->empty() || *bucket == ".") {
return errors::InvalidArgument("GCS path doesn't contain a bucket name: ", return errors::InvalidArgument("GCS path doesn't contain a bucket name: ",
fname); fname);
} }
str_util::ConsumePrefix(&objectp, "/"); str_util::ConsumePrefix(&objectp, "/");
*object = objectp.ToString(); *object = std::string(objectp);
if (!empty_object_ok && object->empty()) { if (!empty_object_ok && object->empty()) {
return errors::InvalidArgument("GCS path doesn't contain an object name: ", return errors::InvalidArgument("GCS path doesn't contain an object name: ",
fname); fname);
@ -212,7 +212,7 @@ std::set<string> AddAllSubpaths(const std::vector<string>& paths) {
for (const string& path : paths) { for (const string& path : paths) {
StringPiece subpath = io::Dirname(path); StringPiece subpath = io::Dirname(path);
while (!subpath.empty()) { while (!subpath.empty()) {
result.emplace(subpath.ToString()); result.emplace(std::string(subpath));
subpath = io::Dirname(subpath); subpath = io::Dirname(subpath);
} }
} }
@ -704,7 +704,7 @@ GcsFileSystem::GcsFileSystem()
if (!header_name.empty() && !header_value.empty()) { if (!header_name.empty() && !header_value.empty()) {
additional_header_.reset(new std::pair<const string, const string>( additional_header_.reset(new std::pair<const string, const string>(
header_name.ToString(), header_value.ToString())); std::string(header_name), std::string(header_value)));
VLOG(1) << "GCS additional header ENABLED. " VLOG(1) << "GCS additional header ENABLED. "
<< "Name: " << additional_header_->first << ", " << "Name: " << additional_header_->first << ", "
@ -1095,7 +1095,7 @@ Status GcsFileSystem::GetMatchingPaths(const string& pattern,
// Find the fixed prefix by looking for the first wildcard. // Find the fixed prefix by looking for the first wildcard.
const string& fixed_prefix = const string& fixed_prefix =
pattern.substr(0, pattern.find_first_of("*?[\\")); pattern.substr(0, pattern.find_first_of("*?[\\"));
const string& dir = io::Dirname(fixed_prefix).ToString(); const string& dir = std::string(io::Dirname(fixed_prefix));
if (dir.empty()) { if (dir.empty()) {
return errors::InvalidArgument( return errors::InvalidArgument(
"A GCS pattern doesn't have a bucket name: ", pattern); "A GCS pattern doesn't have a bucket name: ", pattern);
@ -1192,7 +1192,7 @@ Status GcsFileSystem::GetChildrenBounded(const string& dirname,
" doesn't match the prefix ", object_prefix)); " doesn't match the prefix ", object_prefix));
} }
if (!relative_path.empty() || include_self_directory_marker) { if (!relative_path.empty() || include_self_directory_marker) {
result->emplace_back(relative_path.ToString()); result->emplace_back(std::string(relative_path));
} }
if (++retrieved_results >= max_results) { if (++retrieved_results >= max_results) {
return Status::OK(); return Status::OK();
@ -1220,7 +1220,7 @@ Status GcsFileSystem::GetChildrenBounded(const string& dirname,
"Unexpected response: the returned folder name ", prefix_str, "Unexpected response: the returned folder name ", prefix_str,
" doesn't match the prefix ", object_prefix); " doesn't match the prefix ", object_prefix);
} }
result->emplace_back(relative_path.ToString()); result->emplace_back(std::string(relative_path));
if (++retrieved_results >= max_results) { if (++retrieved_results >= max_results) {
return Status::OK(); return Status::OK();
} }

View File

@ -216,7 +216,7 @@ Status OAuthClient::GetTokenFromServiceAccountJson(
// Send the request to the Google OAuth 2.0 server to get the token. // Send the request to the Google OAuth 2.0 server to get the token.
std::unique_ptr<HttpRequest> request(http_request_factory_->Create()); std::unique_ptr<HttpRequest> request(http_request_factory_->Create());
std::vector<char> response_buffer; std::vector<char> response_buffer;
request->SetUri(oauth_server_uri.ToString()); request->SetUri(std::string(oauth_server_uri));
request->SetPostFromBuffer(request_body.c_str(), request_body.size()); request->SetPostFromBuffer(request_body.c_str(), request_body.size());
request->SetResultBuffer(&response_buffer); request->SetResultBuffer(&response_buffer);
TF_RETURN_IF_ERROR(request->Send()); TF_RETURN_IF_ERROR(request->Send());
@ -248,7 +248,7 @@ Status OAuthClient::GetTokenFromRefreshTokenJson(
std::unique_ptr<HttpRequest> request(http_request_factory_->Create()); std::unique_ptr<HttpRequest> request(http_request_factory_->Create());
std::vector<char> response_buffer; std::vector<char> response_buffer;
request->SetUri(oauth_server_uri.ToString()); request->SetUri(std::string(oauth_server_uri));
request->SetPostFromBuffer(request_body.c_str(), request_body.size()); request->SetPostFromBuffer(request_body.c_str(), request_body.size());
request->SetResultBuffer(&response_buffer); request->SetResultBuffer(&response_buffer);
TF_RETURN_IF_ERROR(request->Send()); TF_RETURN_IF_ERROR(request->Send());

View File

@ -124,11 +124,11 @@ TEST(OAuthClientTest, GetTokenFromServiceAccountJson) {
.OneLiteral("&assertion=") .OneLiteral("&assertion=")
.GetResult(&assertion, &grant_type)); .GetResult(&assertion, &grant_type));
EXPECT_EQ("urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer", EXPECT_EQ("urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer",
grant_type.ToString()); grant_type);
int last_dot = assertion.ToString().find_last_of("."); int last_dot = std::string(assertion).find_last_of(".");
string header_dot_claim = assertion.ToString().substr(0, last_dot); string header_dot_claim = std::string(assertion.substr(0, last_dot));
string signature_encoded = assertion.ToString().substr(last_dot + 1); string signature_encoded = std::string(assertion.substr(last_dot + 1));
// Check that 'signature' signs 'header_dot_claim'. // Check that 'signature' signs 'header_dot_claim'.

View File

@ -32,7 +32,7 @@ inline Status FileExists(const string& filename) {
} }
inline Status FileExists(const port::StringPiece& filename) { inline Status FileExists(const port::StringPiece& filename) {
return Env::Default()->FileExists(filename.ToString()); return Env::Default()->FileExists(std::string(filename));
} }
} // namespace port } // namespace port

View File

@ -33,7 +33,7 @@ string JoinPathImpl(std::initializer_list<port::StringPiece> paths) {
if (path.empty()) continue; if (path.empty()) continue;
if (result.empty()) { if (result.empty()) {
result = path.ToString(); result = std::string(path);
continue; continue;
} }

View File

@ -31,7 +31,7 @@ inline string StripSuffixString(port::StringPiece str, port::StringPiece suffix)
if (tensorflow::str_util::EndsWith(str, suffix)) { if (tensorflow::str_util::EndsWith(str, suffix)) {
str.remove_suffix(suffix.size()); str.remove_suffix(suffix.size());
} }
return str.ToString(); return std::string(str);
} }
using tensorflow::str_util::Lowercase; using tensorflow::str_util::Lowercase;

View File

@ -92,9 +92,8 @@ Status ExtractMinMaxRecords(const string& log_file_name,
if (!str_util::EndsWith(name_string, print_suffix)) { if (!str_util::EndsWith(name_string, print_suffix)) {
continue; continue;
} }
string name = string name = std::string(
name_string.substr(0, name_string.size() - print_suffix.size()) name_string.substr(0, name_string.size() - print_suffix.size()));
.ToString();
records->push_back({name, min, max}); records->push_back({name, min, max});
} }
return Status::OK(); return Status::OK();

View File

@ -42,8 +42,8 @@ class SparsifyGatherTest : public ::testing::Test {
const std::vector<NodeDef*>& inputs, GraphDef* graph_def, const std::vector<NodeDef*>& inputs, GraphDef* graph_def,
bool control_dep = false) { bool control_dep = false) {
NodeDef* node_def = graph_def->add_node(); NodeDef* node_def = graph_def->add_node();
node_def->set_name(name.ToString()); node_def->set_name(std::string(name));
node_def->set_op(op.ToString()); node_def->set_op(std::string(op));
if (!control_dep) { if (!control_dep) {
std::for_each(inputs.begin(), inputs.end(), [&node_def](NodeDef* input) { std::for_each(inputs.begin(), inputs.end(), [&node_def](NodeDef* input) {
node_def->add_input(input->name()); node_def->add_input(input->name());

View File

@ -65,19 +65,19 @@ Status ParseTransformParameters(const string& transforms_string,
.GetResult(&remaining, &transform_name); .GetResult(&remaining, &transform_name);
if (!found_transform_name) { if (!found_transform_name) {
return errors::InvalidArgument("Looking for transform name, but found ", return errors::InvalidArgument("Looking for transform name, but found ",
remaining.ToString().c_str()); std::string(remaining).c_str());
} }
if (Scanner(remaining).OneLiteral("(").GetResult(&remaining, &match)) { if (Scanner(remaining).OneLiteral("(").GetResult(&remaining, &match)) {
state = TRANSFORM_PARAM_NAME; state = TRANSFORM_PARAM_NAME;
} else { } else {
// Add a transform with no parameters. // Add a transform with no parameters.
params_list->push_back({transform_name.ToString(), func_parameters}); params_list->push_back({std::string(transform_name), func_parameters});
transform_name = ""; transform_name = "";
state = TRANSFORM_NAME; state = TRANSFORM_NAME;
} }
} else if (state == TRANSFORM_PARAM_NAME) { } else if (state == TRANSFORM_PARAM_NAME) {
if (Scanner(remaining).OneLiteral(")").GetResult(&remaining, &match)) { if (Scanner(remaining).OneLiteral(")").GetResult(&remaining, &match)) {
params_list->push_back({transform_name.ToString(), func_parameters}); params_list->push_back({std::string(transform_name), func_parameters});
transform_name = ""; transform_name = "";
state = TRANSFORM_NAME; state = TRANSFORM_NAME;
} else { } else {
@ -92,13 +92,13 @@ Status ParseTransformParameters(const string& transforms_string,
if (!found_parameter_name) { if (!found_parameter_name) {
return errors::InvalidArgument( return errors::InvalidArgument(
"Looking for parameter name, but found ", "Looking for parameter name, but found ",
remaining.ToString().c_str()); std::string(remaining).c_str());
} }
if (Scanner(remaining).OneLiteral("=").GetResult(&remaining, &match)) { if (Scanner(remaining).OneLiteral("=").GetResult(&remaining, &match)) {
state = TRANSFORM_PARAM_VALUE; state = TRANSFORM_PARAM_VALUE;
} else { } else {
return errors::InvalidArgument("Looking for =, but found ", return errors::InvalidArgument("Looking for =, but found ",
remaining.ToString().c_str()); std::string(remaining).c_str());
} }
} }
} else if (state == TRANSFORM_PARAM_VALUE) { } else if (state == TRANSFORM_PARAM_VALUE) {
@ -120,10 +120,10 @@ Status ParseTransformParameters(const string& transforms_string,
} }
if (!found_parameter_value) { if (!found_parameter_value) {
return errors::InvalidArgument("Looking for parameter name, but found ", return errors::InvalidArgument("Looking for parameter name, but found ",
remaining.ToString().c_str()); std::string(remaining).c_str());
} }
func_parameters[parameter_name.ToString()].push_back( func_parameters[std::string(parameter_name)].push_back(
parameter_value.ToString()); std::string(parameter_value));
// Eat up any trailing quotes. // Eat up any trailing quotes.
Scanner(remaining).ZeroOrOneLiteral("\"").GetResult(&remaining, &match); Scanner(remaining).ZeroOrOneLiteral("\"").GetResult(&remaining, &match);
Scanner(remaining).ZeroOrOneLiteral("'").GetResult(&remaining, &match); Scanner(remaining).ZeroOrOneLiteral("'").GetResult(&remaining, &match);

View File

@ -93,7 +93,7 @@ void NodeNamePartsFromInput(const string& input_name, string* prefix,
} else { } else {
*prefix = ""; *prefix = "";
} }
*node_name = node_name_piece.ToString(); *node_name = std::string(node_name_piece);
} }
string NodeNameFromInput(const string& input_name) { string NodeNameFromInput(const string& input_name) {