Skip to content

Commit f8f73af

Browse files
Removal of tsl-specific string type.
PiperOrigin-RevId: 837914694
1 parent 5194cea commit f8f73af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+830
-752
lines changed

third_party/tsl/tsl/platform/abi.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" char* __unDName(char* output_string, const char* name,
3939
namespace tsl {
4040
namespace port {
4141

42-
string MaybeAbiDemangle(const char* name) {
42+
std::string MaybeAbiDemangle(const char* name) {
4343
#if defined(_MSC_VER)
4444
std::unique_ptr<char> demangled{__unDName(nullptr, name, 0, std::malloc,
4545
std::free,

third_party/tsl/tsl/platform/coding.cc

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

1616
#include "tsl/platform/coding.h"
1717

18+
#include <string>
19+
1820
#include "xla/tsl/platform/byte_order.h"
1921
#include "xla/tsl/platform/types.h"
2022
#include "tsl/platform/stringpiece.h"
@@ -58,19 +60,19 @@ void EncodeFixed64(char* buf, uint64 value) {
5860
}
5961
}
6062

61-
void PutFixed16(string* dst, uint16 value) {
63+
void PutFixed16(std::string* dst, uint16 value) {
6264
char buf[sizeof(value)];
6365
EncodeFixed16(buf, value);
6466
dst->append(buf, sizeof(buf));
6567
}
6668

67-
void PutFixed32(string* dst, uint32 value) {
69+
void PutFixed32(std::string* dst, uint32 value) {
6870
char buf[sizeof(value)];
6971
EncodeFixed32(buf, value);
7072
dst->append(buf, sizeof(buf));
7173
}
7274

73-
void PutFixed64(string* dst, uint64 value) {
75+
void PutFixed64(std::string* dst, uint64 value) {
7476
char buf[sizeof(value)];
7577
EncodeFixed64(buf, value);
7678
dst->append(buf, sizeof(buf));
@@ -104,7 +106,7 @@ char* EncodeVarint32(char* dst, uint32 v) {
104106
return reinterpret_cast<char*>(ptr);
105107
}
106108

107-
void PutVarint32(string* dst, uint32 v) {
109+
void PutVarint32(std::string* dst, uint32 v) {
108110
char buf[5];
109111
char* ptr = EncodeVarint32(buf, v);
110112
dst->append(buf, ptr - buf);
@@ -127,7 +129,7 @@ char* EncodeVarint64(char* dst, uint64 v) {
127129
return reinterpret_cast<char*>(ptr);
128130
}
129131

130-
void PutVarint64(string* dst, uint64 v) {
132+
void PutVarint64(std::string* dst, uint64 v) {
131133
char buf[10];
132134
char* ptr = EncodeVarint64(buf, v);
133135
dst->append(buf, ptr - buf);

third_party/tsl/tsl/platform/coding.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ limitations under the License.
2121
#ifndef TENSORFLOW_TSL_PLATFORM_CODING_H_
2222
#define TENSORFLOW_TSL_PLATFORM_CODING_H_
2323

24+
#include <string>
25+
2426
#include "absl/strings/string_view.h"
2527
#include "xla/tsl/platform/types.h"
2628
#include "tsl/platform/stringpiece.h"
@@ -40,12 +42,12 @@ static const int kMaxVarint64Bytes = 10;
4042
extern void EncodeFixed16(char* dst, uint16 value);
4143
extern void EncodeFixed32(char* dst, uint32 value);
4244
extern void EncodeFixed64(char* dst, uint64 value);
43-
extern void PutFixed16(string* dst, uint16 value);
44-
extern void PutFixed32(string* dst, uint32 value);
45-
extern void PutFixed64(string* dst, uint64 value);
45+
extern void PutFixed16(std::string* dst, uint16 value);
46+
extern void PutFixed32(std::string* dst, uint32 value);
47+
extern void PutFixed64(std::string* dst, uint64 value);
4648

47-
extern void PutVarint32(string* dst, uint32 value);
48-
extern void PutVarint64(string* dst, uint64 value);
49+
extern void PutVarint32(std::string* dst, uint32 value);
50+
extern void PutVarint64(std::string* dst, uint64 value);
4951

5052
extern void PutVarint32(tstring* dst, uint32 value);
5153
extern void PutVarint64(tstring* dst, uint64 value);

third_party/tsl/tsl/platform/cpu_info.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class CPUIDInfo {
312312
return false;
313313
}
314314

315-
string vendor_str() const { return vendor_str_; }
315+
std::string vendor_str() const { return vendor_str_; }
316316
int family() const { return family_; }
317317
int model_num() { return model_num_; }
318318

@@ -364,7 +364,7 @@ class CPUIDInfo {
364364
int have_sse4_2_ : 1;
365365
int have_ssse3_ : 1;
366366
int have_hypervisor_ : 1;
367-
string vendor_str_;
367+
std::string vendor_str_;
368368
int family_;
369369
int model_num_;
370370
};

third_party/tsl/tsl/platform/demangle.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ limitations under the License.
1616
#ifndef TENSORFLOW_TSL_PLATFORM_DEMANGLE_H_
1717
#define TENSORFLOW_TSL_PLATFORM_DEMANGLE_H_
1818

19+
#include <string>
20+
1921
#include "xla/tsl/platform/types.h"
2022

2123
namespace tsl {
2224
namespace port {
2325

2426
// If the compiler supports, demangle a mangled symbol name and return
2527
// the demangled name. Otherwise, returns 'mangled' as is.
26-
string Demangle(const char* mangled);
27-
inline string Demangle(const string mangled) {
28+
std::string Demangle(const char* mangled);
29+
inline std::string Demangle(const std::string mangled) {
2830
return Demangle(mangled.c_str());
2931
}
3032

third_party/tsl/tsl/platform/hash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ struct hash<T*> {
9494
};
9595

9696
template <>
97-
struct hash<string> {
98-
size_t operator()(const string& s) const {
97+
struct hash<std::string> {
98+
size_t operator()(const std::string& s) const {
9999
return static_cast<size_t>(Hash64(s));
100100
}
101101
};

third_party/tsl/tsl/platform/hash_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ TEST(StringPieceHasher, Equality) {
107107
}
108108

109109
TEST(StringPieceHasher, HashMap) {
110-
string s1("foo");
111-
string s2("bar");
112-
string s3("baz");
110+
std::string s1("foo");
111+
std::string s2("bar");
112+
std::string s3("baz");
113113

114114
absl::string_view p1(s1);
115115
absl::string_view p2(s2);

third_party/tsl/tsl/platform/host_info.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
#define TENSORFLOW_TSL_PLATFORM_HOST_INFO_H_
1818

1919
#include <cstdint>
20+
#include <string>
2021

2122
#include "xla/tsl/platform/types.h"
2223

@@ -37,11 +38,11 @@ struct IOStatistics {
3738
};
3839

3940
// Return the hostname of the machine on which this process is running.
40-
string Hostname();
41+
std::string Hostname();
4142

4243
// Return the job name as a string if it exists, otherwise return an empty
4344
// string.
44-
string JobName();
45+
std::string JobName();
4546

4647
// Returns the Borg job UID as an int64_t if it exists. Otherwise return -1.
4748
int64_t JobUid();

third_party/tsl/tsl/platform/human_readable_json.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ absl::StatusOr<std::string> ProtoToHumanReadableJson(
4040

4141
// Converts a string produced by ProtoToHumanReadableJSON to a protobuf. Not
4242
// guaranteed to work for general JSON.
43-
absl::Status HumanReadableJsonToProto(const string& str,
43+
absl::Status HumanReadableJsonToProto(const std::string& str,
4444
protobuf::Message* proto);
45-
absl::Status HumanReadableJsonToProto(const string& str,
45+
absl::Status HumanReadableJsonToProto(const std::string& str,
4646
protobuf::MessageLite* proto);
4747

4848
} // namespace tsl

third_party/tsl/tsl/platform/null_file_system.h

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,70 +39,72 @@ class NullFileSystem : public FileSystem {
3939
TF_USE_FILESYSTEM_METHODS_WITH_NO_TRANSACTION_SUPPORT;
4040

4141
absl::Status NewRandomAccessFile(
42-
const string& fname, TransactionToken* token,
42+
const std::string& fname, TransactionToken* token,
4343
std::unique_ptr<RandomAccessFile>* result) override {
4444
return errors::Unimplemented("NewRandomAccessFile unimplemented");
4545
}
4646

47-
absl::Status NewWritableFile(const string& fname, TransactionToken* token,
47+
absl::Status NewWritableFile(const std::string& fname,
48+
TransactionToken* token,
4849
std::unique_ptr<WritableFile>* result) override {
4950
return errors::Unimplemented("NewWritableFile unimplemented");
5051
}
5152

5253
absl::Status NewAppendableFile(
53-
const string& fname, TransactionToken* token,
54+
const std::string& fname, TransactionToken* token,
5455
std::unique_ptr<WritableFile>* result) override {
5556
return errors::Unimplemented("NewAppendableFile unimplemented");
5657
}
5758

5859
absl::Status NewReadOnlyMemoryRegionFromFile(
59-
const string& fname, TransactionToken* token,
60+
const std::string& fname, TransactionToken* token,
6061
std::unique_ptr<ReadOnlyMemoryRegion>* result) override {
6162
return errors::Unimplemented(
6263
"NewReadOnlyMemoryRegionFromFile unimplemented");
6364
}
6465

65-
absl::Status FileExists(const string& fname,
66+
absl::Status FileExists(const std::string& fname,
6667
TransactionToken* token) override {
6768
return errors::Unimplemented("FileExists unimplemented");
6869
}
6970

70-
absl::Status GetChildren(const string& dir, TransactionToken* token,
71-
std::vector<string>* result) override {
71+
absl::Status GetChildren(const std::string& dir, TransactionToken* token,
72+
std::vector<std::string>* result) override {
7273
return errors::Unimplemented("GetChildren unimplemented");
7374
}
7475

75-
absl::Status GetMatchingPaths(const string& pattern, TransactionToken* token,
76-
std::vector<string>* results) override {
76+
absl::Status GetMatchingPaths(const std::string& pattern,
77+
TransactionToken* token,
78+
std::vector<std::string>* results) override {
7779
return internal::GetMatchingPaths(this, Env::Default(), pattern, results);
7880
}
7981

80-
absl::Status DeleteFile(const string& fname,
82+
absl::Status DeleteFile(const std::string& fname,
8183
TransactionToken* token) override {
8284
return errors::Unimplemented("DeleteFile unimplemented");
8385
}
8486

85-
absl::Status CreateDir(const string& dirname,
87+
absl::Status CreateDir(const std::string& dirname,
8688
TransactionToken* token) override {
8789
return errors::Unimplemented("CreateDir unimplemented");
8890
}
8991

90-
absl::Status DeleteDir(const string& dirname,
92+
absl::Status DeleteDir(const std::string& dirname,
9193
TransactionToken* token) override {
9294
return errors::Unimplemented("DeleteDir unimplemented");
9395
}
9496

95-
absl::Status GetFileSize(const string& fname, TransactionToken* token,
97+
absl::Status GetFileSize(const std::string& fname, TransactionToken* token,
9698
uint64* file_size) override {
9799
return errors::Unimplemented("GetFileSize unimplemented");
98100
}
99101

100-
absl::Status RenameFile(const string& src, const string& target,
102+
absl::Status RenameFile(const std::string& src, const std::string& target,
101103
TransactionToken* token) override {
102104
return errors::Unimplemented("RenameFile unimplemented");
103105
}
104106

105-
absl::Status Stat(const string& fname, TransactionToken* token,
107+
absl::Status Stat(const std::string& fname, TransactionToken* token,
106108
FileStatistics* stat) override {
107109
return errors::Unimplemented("Stat unimplemented");
108110
}

0 commit comments

Comments
 (0)