if (IsCPPKeyword(name)) {
return strings::StrCat(name, "_");
}
- return name.ToString();
+ return std::string(name);
}
void InferArgAttributes(const OpDef::ArgDef& arg,
for (const string& entry : node_constraints) {
StringPiece s(entry);
if (str_util::ConsumePrefix(&s, kColocationGroupPrefix)) {
- current_constraints.insert(s.ToString());
+ current_constraints.insert(std::string(s));
}
}
} else {
// Push input nodes of the currently visited node to name_queue.
for (const string& in_edge : map_entry.second->input()) {
auto id = ParseTensorName(in_edge);
- const string node_name = id.first.ToString();
+ const string node_name = std::string(id.first);
if (feed_tensors.find(std::make_pair(node_name, id.second)) ==
feed_tensors.end()) {
name_queue.push(node_name);
XlaOpRegistrationBuilder::XlaOpRegistrationBuilder(StringPiece name) {
registration_.reset(new XlaOpRegistry::OpRegistration);
- registration_->name = name.ToString();
+ registration_->name = std::string(name);
}
XlaOpRegistrationBuilder XlaOpRegistrationBuilder::Name(StringPiece name) {
gtl::ArraySlice<StringPiece> devices) {
registration_->has_device_whitelist = true;
for (StringPiece device : devices) {
- registration_->device_whitelist.insert(device.ToString());
+ registration_->device_whitelist.insert(std::string(device));
}
return *this;
}
XlaOpRegistrationBuilder& XlaOpRegistrationBuilder::Device(StringPiece device) {
registration_->has_device_whitelist = true;
- registration_->device_whitelist.insert(device.ToString());
+ registration_->device_whitelist.insert(std::string(device));
return *this;
}
XlaOpRegistrationBuilder& XlaOpRegistrationBuilder::TypeConstraint(
StringPiece attr_name, DataType allowed) {
std::set<DataType>& types =
- registration_->type_constraints[attr_name.ToString()];
+ registration_->type_constraints[std::string(attr_name)];
types.insert(allowed);
return *this;
}
XlaOpRegistrationBuilder& XlaOpRegistrationBuilder::TypeConstraint(
StringPiece attr_name, gtl::ArraySlice<DataType> allowed) {
std::set<DataType>& types =
- registration_->type_constraints[attr_name.ToString()];
+ registration_->type_constraints[std::string(attr_name)];
for (DataType t : allowed) {
types.insert(t);
}
XlaOpRegistrationBuilder& XlaOpRegistrationBuilder::CompileTimeConstInput(
StringPiece input_name) {
- registration_->compile_time_constant_inputs.insert(input_name.ToString());
+ registration_->compile_time_constant_inputs.insert(std::string(input_name));
return *this;
}
StringPiece name, gtl::ArraySlice<DataType> types,
XlaOpRegistry::BackendOpFilter op_filter) {
XlaOpRegistry& registry = XlaOpRegistry::Instance();
- registry.RegisterBackend(name.ToString(), types, op_filter);
+ registry.RegisterBackend(std::string(name), types, op_filter);
}
} // namespace tensorflow
llvm::Value* start_index, llvm::Value* end_index,
llvm::Value* step, bool prevent_unrolling,
bool prevent_vectorization)
- : prefix_(prefix.ToString()),
- suffix_(suffix.ToString()),
+ : prefix_(std::string(prefix)),
+ suffix_(std::string(suffix)),
start_index_(start_index),
end_index_(end_index),
step_(step),
: ForLoopNest(/*name=*/"", ir_builder) {}
ForLoopNest(tensorflow::StringPiece name, llvm::IRBuilder<>* ir_builder)
- : name_(name.ToString()),
+ : name_(std::string(name)),
outer_loop_preheader_bb_(nullptr),
outer_loop_exit_bb_(nullptr),
inner_loop_body_bb_(nullptr),
}
}
- str_val_ = identifier.ToString();
+ str_val_ = std::string(identifier);
return TokKind::kIdent;
}
std::vector<string> error_lines;
error_lines.push_back(
StrCat("was parsing ", line, ":", col, ": error: ", msg));
- error_lines.push_back(lexer_.GetLine(loc).ToString());
+ error_lines.push_back(std::string(lexer_.GetLine(loc)));
error_lines.push_back(col == 0 ? "" : StrCat(string(col - 1, ' '), "^"));
error_.push_back(tensorflow::str_util::Join(error_lines, "\n"));
"Malformed attributes in debug op name \"", debug_op_name, "\"");
}
- const string key = seg.substr(0, eq_index).ToString();
- const string value =
- seg.substr(eq_index + 1, attribute_seg.size() - eq_index - 1)
- .ToString();
+ const string key = std::string(seg.substr(0, eq_index));
+ const string value = std::string(
+ seg.substr(eq_index + 1, attribute_seg.size() - eq_index - 1));
if (key.empty() || value.empty()) {
return errors::InvalidArgument(
"Malformed attributes in debug op name \"", debug_op_name, "\"");
strings::Printf("%.14lld", session_run_index))),
Env::Default()->NowMicros());
status.Update(DebugFileIO::DumpEventProtoToFile(
- event, io::Dirname(core_metadata_path).ToString(),
- io::Basename(core_metadata_path).ToString()));
+ event, std::string(io::Dirname(core_metadata_path)),
+ std::string(io::Basename(core_metadata_path))));
}
}
std::vector<Event> events;
TF_RETURN_IF_ERROR(
WrapTensorAsEvents(debug_node_key, tensor, wall_time_us, 0, &events));
- return DumpEventProtoToFile(events[0], io::Dirname(file_path).ToString(),
- io::Basename(file_path).ToString());
+ return DumpEventProtoToFile(events[0], std::string(io::Dirname(file_path)),
+ std::string(io::Basename(file_path)));
}
Status DebugFileIO::RecursiveCreateDir(Env* env, const string& dir) {
return Status::OK();
}
- string parent_dir = io::Dirname(dir).ToString();
+ string parent_dir = std::string(io::Dirname(dir));
if (!env->FileExists(parent_dir).ok()) {
// The parent path does not exist yet, create it first.
Status s = RecursiveCreateDir(env, parent_dir); // Recursive call
// inadvertently slowing down the normal run path.
if (is_partial_) {
for (const auto& name_index : feeds) {
- const auto iter = part.feed_key.find(name_index.first.ToString());
+ const auto iter = part.feed_key.find(std::string(name_index.first));
if (iter == part.feed_key.end()) {
// The provided feed must be for a different partition.
continue;
// Skip if already fed.
if (input.second) continue;
TensorId id(ParseTensorName(input.first));
- const Node* n = execution_state->get_node_by_name(id.first.ToString());
+ const Node* n = execution_state->get_node_by_name(std::string(id.first));
if (n == nullptr) {
return errors::NotFound("Feed ", input.first, ": not found");
}
for (size_t i = 0; i < req.num_fetches(); ++i) {
const string& fetch = req.fetch_name(i);
const TensorId id(ParseTensorName(fetch));
- const Node* n = execution_state->get_node_by_name(id.first.ToString());
+ const Node* n = execution_state->get_node_by_name(std::string(id.first));
if (n == nullptr) {
return errors::NotFound("Fetch ", fetch, ": not found");
}
auto pos = fullname.rfind('/');
CHECK_NE(pos, StringPiece::npos);
fullname.remove_prefix(pos + 1);
- return fullname.ToString();
+ return std::string(fullname);
}
class RemoteDevice : public Device {
// Returns the node name and position in a single call.
inline string ParseNodeName(const string& name, int* position) {
- return ParseNodeNameAsStringPiece(name, position).ToString();
+ return std::string(ParseNodeNameAsStringPiece(name, position));
}
// Add a prefix to a node name with a custom delimiter.
for (const string& output_node_name : output_node_names) {
const TensorId tid = ParseTensorName(output_node_name);
- const string node_name = tid.first.ToString();
+ const string node_name = std::string(tid.first);
const int port = tid.second;
const int node_id = node_name_to_id_cache_map_.at(node_name);
const Node* node = node_name_cache_list_.at(node_id);
new_output_node_info.set_output_count(0);
const TensorId tid = ParseTensorName(graph_output.name());
- const string node_name = tid.first.ToString();
+ const string node_name = std::string(tid.first);
const int port = tid.second;
// Register node input for the new output node
const GraphTransferNodeInfo* node_info =
if (path.empty()) continue;
if (result.empty()) {
- result = path.ToString();
+ result = std::string(path);
continue;
}
}
string CleanPath(StringPiece unclean_path) {
- string path = unclean_path.ToString();
+ string path = std::string(unclean_path);
const char* src = path.c_str();
string::iterator dst = path.begin();
string CreateURI(StringPiece scheme, StringPiece host, StringPiece path) {
if (scheme.empty()) {
- return path.ToString();
+ return std::string(path);
}
return strings::StrCat(scheme, "://", host, path);
}
virtual ~Constructor() {}
void Add(const string& key, const StringPiece& value) {
- data_[key] = value.ToString();
+ data_[key] = std::string(value);
}
// Finish constructing the data structure with all the keys that have
builder.Add(it->first, it->second);
}
// Open the block
- data_ = builder.Finish().ToString();
+ data_ = std::string(builder.Finish());
BlockContents contents;
contents.data = data_;
contents.cachable = false;
for (int e = 0; e < num_entries; e++) {
string v;
Add(test::RandomKey(&rnd, rnd.Skewed(4)),
- test::RandomString(&rnd, rnd.Skewed(5), &v).ToString());
+ std::string(test::RandomString(&rnd, rnd.Skewed(5), &v)));
}
Test(&rnd);
}
BundleWriter::BundleWriter(Env* env, StringPiece prefix, const Options& options)
: env_(env),
options_(options),
- prefix_(prefix.ToString()),
+ prefix_(std::string(prefix)),
tmp_metadata_path_(strings::StrCat(MetaFilename(prefix_), ".tempstate",
random::New64())),
tmp_data_path_(strings::StrCat(DataFilename(prefix_, 0, 1), ".tempstate",
random::New64())),
out_(nullptr),
size_(0) {
- status_ = env_->CreateDir(io::Dirname(prefix_).ToString());
+ status_ = env_->CreateDir(std::string(io::Dirname(prefix_)));
if (!status_.ok() && !errors::IsAlreadyExists(status_)) {
return;
}
Status BundleWriter::Add(StringPiece key, const Tensor& val) {
if (!status_.ok()) return status_;
CHECK_NE(key, kHeaderEntryKey);
- const string key_string = key.ToString();
+ const string key_string = std::string(key);
if (entries_.find(key_string) != entries_.end()) {
status_ = errors::InvalidArgument("Adding duplicate key: ", key);
return status_;
// In the case of a sharded save, MergeBundles() is responsible for merging
// the "slices" field of multiple metadata entries corresponding to the same
// full tensor.
- const string full_tensor_key_string = full_tensor_key.ToString();
+ const string full_tensor_key_string = std::string(full_tensor_key);
BundleEntryProto* full_entry = &entries_[full_tensor_key_string];
if (full_entry->dtype() != DT_INVALID) {
CHECK_EQ(full_entry->dtype(), slice_tensor.dtype());
// Loops through the non-header to-merge entries.
BundleEntryProto to_merge_entry;
for (; iter->Valid(); iter->Next()) {
- const string key = iter->key().ToString();
+ const string key = std::string(iter->key());
const auto entry_iter = merge_state->entries.find(key);
// Illegal: the duplicated entry is a non-slice tensor.
// Merges all metadata tables.
// TODO(zhifengc): KeyValue sorter if it becomes too big.
MergeState merge;
- Status status = env->CreateDir(io::Dirname(merged_prefix).ToString());
+ Status status = env->CreateDir(std::string(io::Dirname(merged_prefix)));
if (!status.ok() && !errors::IsAlreadyExists(status)) return status;
for (int i = 0; i < prefixes.size(); ++i) {
TF_RETURN_IF_ERROR(MergeOneBundle(env, prefixes[i], &merge));
BundleReader::BundleReader(Env* env, StringPiece prefix)
: env_(env),
- prefix_(prefix.ToString()),
+ prefix_(std::string(prefix)),
metadata_(nullptr),
table_(nullptr),
iter_(nullptr) {
const TensorShape full_shape(TensorShape(full_tensor_entry.shape()));
std::vector<std::pair<TensorSlice, string>> details;
- const string full_tensor_key_string = full_tensor_key.ToString();
+ const string full_tensor_key_string = std::string(full_tensor_key);
const TensorSliceSet* tss =
gtl::FindPtrOrNull(tensor_slices_, full_tensor_key_string);
reader->Seek(kHeaderEntryKey);
reader->Next();
for (; reader->Valid(); reader->Next()) {
- ret.push_back(reader->key().ToString());
+ ret.push_back(std::string(reader->key()));
}
return ret;
}
static const char *kStubPrefix = "__device_stub_";
void KernelBase::set_name(port::StringPiece name) {
- name_ = name.ToString();
+ name_ = std::string(name);
port::StringPiece stubless_name = name;
if (tensorflow::str_util::StartsWith(name, kStubPrefix)) {
stubless_name.remove_prefix(strlen(kStubPrefix));
namespace stream_executor {
KernelLoaderSpec::KernelLoaderSpec(port::StringPiece kernelname)
- : kernelname_(kernelname.ToString()) {}
+ : kernelname_(std::string(kernelname)) {}
OnDiskKernelLoaderSpec::OnDiskKernelLoaderSpec(port::StringPiece filename,
port::StringPiece kernelname)
- : KernelLoaderSpec(kernelname), filename_(filename.ToString()) {}
+ : KernelLoaderSpec(kernelname), filename_(std::string(filename)) {}
CudaPtxOnDisk::CudaPtxOnDisk(port::StringPiece filename,
port::StringPiece kernelname)
OpenCLTextInMemory::OpenCLTextInMemory(port::StringPiece text,
port::StringPiece kernelname)
- : KernelLoaderSpec(kernelname), text_(text.ToString()) {}
+ : KernelLoaderSpec(kernelname), text_(std::string(text)) {}
OpenCLBinaryOnDisk::OpenCLBinaryOnDisk(port::StringPiece filename,
port::StringPiece kernelname)