Revert "Make c10::string_view an alias of std::string_view (#130417)"

This reverts commit c9551a3f50efc8163d8508a3c2189536528577ac.

Reverted https://github.com/pytorch/pytorch/pull/130417 on behalf of https://github.com/izaitsevfb due to depends on #130009 which needs to be reverted ([comment](https://github.com/pytorch/pytorch/pull/130417#issuecomment-2224212227))
This commit is contained in:
PyTorch MergeBot
2024-07-12 00:37:04 +00:00
parent b5b91b418d
commit 7ce5b5767c
7 changed files with 747 additions and 93 deletions

View File

@ -283,7 +283,7 @@ size_t getPadding(
bool PyTorchStreamReader::hasRecord(const std::string& name) {
std::lock_guard<std::mutex> guard(reader_lock_);
if ((!load_debug_symbol_) && c10::string_view_ext(name).ends_with(kDebugPklSuffix)) {
if ((!load_debug_symbol_) && c10::string_view(name).ends_with(kDebugPklSuffix)) {
return false;
}
std::string ss = archive_name_plus_slash_ + name;
@ -320,7 +320,7 @@ std::vector<std::string> PyTorchStreamReader::getAllRecords() {
buf);
}
if ((load_debug_symbol_) ||
(!c10::string_view_ext(buf + archive_name_plus_slash_.size()).ends_with(kDebugPklSuffix))) {
(!c10::string_view(buf + archive_name_plus_slash_.size()).ends_with(kDebugPklSuffix))) {
// NOLINTNEXTLINE(modernize-use-emplace)
out.push_back(buf + archive_name_plus_slash_.size());
}
@ -343,7 +343,7 @@ size_t PyTorchStreamReader::getRecordID(const std::string& name) {
// return dataptr, size
std::tuple<at::DataPtr, size_t> PyTorchStreamReader::getRecord(const std::string& name) {
std::lock_guard<std::mutex> guard(reader_lock_);
if ((!load_debug_symbol_) && c10::string_view_ext(name).ends_with(kDebugPklSuffix)) {
if ((!load_debug_symbol_) && c10::string_view(name).ends_with(kDebugPklSuffix)) {
at::DataPtr retval;
return std::make_tuple(std::move(retval), 0);
}
@ -424,7 +424,7 @@ PyTorchStreamReader::getRecord(const std::string& name,
return getRecord(name);
}
if ((!load_debug_symbol_) && c10::string_view_ext(name).ends_with(kDebugPklSuffix)) {
if ((!load_debug_symbol_) && c10::string_view(name).ends_with(kDebugPklSuffix)) {
at::DataPtr retval;
return std::make_tuple(std::move(retval), 0);
}
@ -448,7 +448,7 @@ PyTorchStreamReader::getRecord(const std::string& name,
size_t
PyTorchStreamReader::getRecord(const std::string& name, void* dst, size_t n) {
std::lock_guard<std::mutex> guard(reader_lock_);
if ((!load_debug_symbol_) && c10::string_view_ext(name).ends_with(kDebugPklSuffix)) {
if ((!load_debug_symbol_) && c10::string_view(name).ends_with(kDebugPklSuffix)) {
return 0;
}
size_t key = getRecordID(name);
@ -477,7 +477,7 @@ PyTorchStreamReader::getRecord(const std::string& name, void* dst, size_t n,
return getRecord(name, dst, n);
}
if ((!load_debug_symbol_) && c10::string_view_ext(name).ends_with(kDebugPklSuffix)) {
if ((!load_debug_symbol_) && c10::string_view(name).ends_with(kDebugPklSuffix)) {
return 0;
}
size_t key = getRecordID(name);
@ -508,7 +508,7 @@ size_t PyTorchStreamReader::getRecord(
void* buf,
const std::function<void(void*, const void*, size_t)>& memcpy_func) {
std::lock_guard<std::mutex> guard(reader_lock_);
if ((!load_debug_symbol_) && c10::string_view_ext(name).ends_with(kDebugPklSuffix)) {
if ((!load_debug_symbol_) && c10::string_view(name).ends_with(kDebugPklSuffix)) {
return 0;
}
if (chunk_size <= 0) {