c10::string_view -> std::string_view in caffe2/jit (#142383)

Test Plan: Sandcastle

Differential Revision: D66939979

Pull Request resolved: https://github.com/pytorch/pytorch/pull/142383
Approved by: https://github.com/malfet
This commit is contained in:
Richard Barnes 2024-12-10 15:42:28 +00:00 committed by PyTorch MergeBot
parent dd2d0c6b80
commit 7e41717a26
11 changed files with 20 additions and 20 deletions

View file

@ -9,7 +9,7 @@ TEST(SourceRangeTest, test_find) {
strings.push_back(std::make_shared<std::string>("hello world"));
strings.push_back(std::make_shared<std::string>("nihaoma"));
std::vector<c10::string_view> pieces{*strings[0], *strings[1]};
std::vector<std::string_view> pieces{*strings[0], *strings[1]};
StringCordView view(pieces, strings);
@ -22,7 +22,7 @@ TEST(SourceRangeTest, test_substr) {
strings.push_back(std::make_shared<std::string>("hello world"));
strings.push_back(std::make_shared<std::string>("nihaoma"));
std::vector<c10::string_view> pieces{*strings[0], *strings[1]};
std::vector<std::string_view> pieces{*strings[0], *strings[1]};
StringCordView view(pieces, strings);
@ -36,7 +36,7 @@ TEST(SourceRangeTest, test_iter) {
strings.push_back(std::make_shared<std::string>("hello world"));
strings.push_back(std::make_shared<std::string>("nihaoma"));
std::vector<c10::string_view> pieces{*strings[0], *strings[1]};
std::vector<std::string_view> pieces{*strings[0], *strings[1]};
StringCordView view(pieces, strings);

View file

@ -9,7 +9,7 @@
namespace torch {
namespace jit {
static constexpr c10::string_view classSrcs1 = R"JIT(
static constexpr std::string_view classSrcs1 = R"JIT(
class FooNestedTest:
def __init__(self, y):
self.y = y
@ -26,7 +26,7 @@ class FooTest:
self.x = self.class_attr.y + self.class_attr2.y
)JIT";
static constexpr c10::string_view classSrcs2 = R"JIT(
static constexpr std::string_view classSrcs2 = R"JIT(
class FooTest:
def __init__(self, x):
self.dx = x
@ -134,7 +134,7 @@ TEST(ClassImportTest, ClassDerive) {
ASSERT_TRUE(newCls2->findMethod(method->name()));
}
static constexpr c10::string_view torchbindSrc = R"JIT(
static constexpr std::string_view torchbindSrc = R"JIT(
class FooBar1234(Module):
__parameters__ = []
f : __torch__.torch.classes._TorchScriptTesting._StackString

View file

@ -5,7 +5,7 @@
namespace torch {
namespace jit {
constexpr c10::string_view testSource = R"JIT(
constexpr std::string_view testSource = R"JIT(
class FooTest:
def __init__(self, x):
self.x = x

View file

@ -23,7 +23,7 @@ def forward(self, x: Tensor) -> Tensor:
return self.subMod.forward(x)
)JIT";
static constexpr c10::string_view moduleInterfaceSrc = R"JIT(
static constexpr std::string_view moduleInterfaceSrc = R"JIT(
class OneForward(ModuleInterface):
def one(self, x: Tensor, y: Tensor) -> Tensor:
pass

View file

@ -13,7 +13,7 @@
namespace torch {
namespace jit {
static constexpr c10::string_view moduleInterfaceSrc = R"JIT(
static constexpr std::string_view moduleInterfaceSrc = R"JIT(
class OneInterface(ModuleInterface):
def one(self, x: Tensor, y: Tensor) -> Tensor:
pass

View file

@ -14,7 +14,7 @@ StringCordView::StringCordView() {
}
StringCordView::StringCordView(
std::vector<c10::string_view> inputs,
std::vector<std::string_view> inputs,
std::vector<std::shared_ptr<std::string>> ownerships)
: pieces_(std::move(inputs)), owned_strings_(std::move(ownerships)) {
accumulated_sizes_.push_back(0);
@ -70,7 +70,7 @@ size_t StringCordView::find_regex(const std::string& tok, size_t start) const {
}
StringCordView StringCordView::substr(size_t start, size_t size) const {
std::vector<c10::string_view> pieces;
std::vector<std::string_view> pieces;
std::vector<std::shared_ptr<std::string>> ownerships;
if (start >= this->size()) {
// out of bounds

View file

@ -22,7 +22,7 @@ struct TORCH_API StringCordView {
StringCordView(const StringCordView&) = default;
StringCordView(StringCordView&&) noexcept = default;
StringCordView(
std::vector<c10::string_view> inputs,
std::vector<std::string_view> inputs,
std::vector<std::shared_ptr<std::string>> ownerships);
StringCordView& operator=(const StringCordView&) = default;
@ -171,7 +171,7 @@ struct TORCH_API StringCordView {
Iterator iter_for_pos(size_t pos) const;
private:
std::vector<c10::string_view> pieces_;
std::vector<std::string_view> pieces_;
std::vector<size_t> accumulated_sizes_;
std::vector<std::shared_ptr<std::string>> owned_strings_;
};

View file

@ -659,13 +659,13 @@ void addInputs(
const std::optional<at::Scalar>& value) {
detail::genericAddOptionalInput(n, name, value);
}
void addInputs(Node* n, const char* name, const c10::string_view value) {
void addInputs(Node* n, const char* name, const std::string_view value) {
detail::genericAddInput(n, std::string(value));
}
void addInputs(
Node* n,
const char* name,
const std::optional<c10::string_view>& value) {
const std::optional<std::string_view>& value) {
detail::genericAddOptionalInput(n, name, value);
}
void addInputs(Node* n, const char* name, const at::Tensor& value) {

View file

@ -305,11 +305,11 @@ TORCH_API void addInputs(
TORCH_API void addInputs(
Node* n,
const char* name,
const c10::string_view value);
const std::string_view value);
TORCH_API void addInputs(
Node* n,
const char* name,
const std::optional<c10::string_view>& value);
const std::optional<std::string_view>& value);
TORCH_API void addInputs(Node* n, const char* name, at::Device value);
TORCH_API void addInputs(Node* n, const char* name, c10::Stream stream);
TORCH_API void addInputs(Node* n, const char* name, at::Layout value);

View file

@ -182,7 +182,7 @@ TypePtr TypeParser::parse() {
// ]
// ]"
TypePtr TypeParser::parseNamedTuple(const std::string& qualified_name) {
std::vector<c10::string_view> field_names;
std::vector<std::string_view> field_names;
std::vector<TypePtr> field_types;
expect(",");
expect("[");
@ -282,7 +282,7 @@ void TypeParser::expect(const char* s) {
advance();
}
// c10::string_view::operator== calls memcmp to compare against the target
// std::string_view::operator== calls memcmp to compare against the target
// string; we can do better if we specialize for a single character.
void TypeParser::expectChar(char c) {
std::string_view token = cur();

View file

@ -1900,7 +1900,7 @@ REGISTER_OPERATOR_FUNCTOR(aten::div, aten_div, [](Node* n) -> SROperator {
const auto& in0_t = p_node->Input(0).toTensor();
std::optional<std::string_view> rounding_mode = std::nullopt;
if (p_node->num_inputs() > 2) {
rounding_mode = p_node->Input(2).toOptional<c10::string_view>();
rounding_mode = p_node->Input(2).toOptional<std::string_view>();
}
const auto& in1_t = p_node->Input(1).isTensor()
? p_node->Input(1).toTensor()