Skip to content

Commit 7e41717

Browse files
r-barnespytorchmergebot
authored andcommitted
c10::string_view -> std::string_view in caffe2/jit (pytorch#142383)
Test Plan: Sandcastle Differential Revision: D66939979 Pull Request resolved: pytorch#142383 Approved by: https://github.com/malfet
1 parent dd2d0c6 commit 7e41717

11 files changed

+20
-20
lines changed

test/cpp/jit/source_range_test.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TEST(SourceRangeTest, test_find) {
99
strings.push_back(std::make_shared<std::string>("hello world"));
1010
strings.push_back(std::make_shared<std::string>("nihaoma"));
1111

12-
std::vector<c10::string_view> pieces{*strings[0], *strings[1]};
12+
std::vector<std::string_view> pieces{*strings[0], *strings[1]};
1313

1414
StringCordView view(pieces, strings);
1515

@@ -22,7 +22,7 @@ TEST(SourceRangeTest, test_substr) {
2222
strings.push_back(std::make_shared<std::string>("hello world"));
2323
strings.push_back(std::make_shared<std::string>("nihaoma"));
2424

25-
std::vector<c10::string_view> pieces{*strings[0], *strings[1]};
25+
std::vector<std::string_view> pieces{*strings[0], *strings[1]};
2626

2727
StringCordView view(pieces, strings);
2828

@@ -36,7 +36,7 @@ TEST(SourceRangeTest, test_iter) {
3636
strings.push_back(std::make_shared<std::string>("hello world"));
3737
strings.push_back(std::make_shared<std::string>("nihaoma"));
3838

39-
std::vector<c10::string_view> pieces{*strings[0], *strings[1]};
39+
std::vector<std::string_view> pieces{*strings[0], *strings[1]};
4040

4141
StringCordView view(pieces, strings);
4242

test/cpp/jit/test_class_import.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace torch {
1010
namespace jit {
1111

12-
static constexpr c10::string_view classSrcs1 = R"JIT(
12+
static constexpr std::string_view classSrcs1 = R"JIT(
1313
class FooNestedTest:
1414
def __init__(self, y):
1515
self.y = y
@@ -26,7 +26,7 @@ class FooTest:
2626
self.x = self.class_attr.y + self.class_attr2.y
2727
)JIT";
2828

29-
static constexpr c10::string_view classSrcs2 = R"JIT(
29+
static constexpr std::string_view classSrcs2 = R"JIT(
3030
class FooTest:
3131
def __init__(self, x):
3232
self.dx = x
@@ -134,7 +134,7 @@ TEST(ClassImportTest, ClassDerive) {
134134
ASSERT_TRUE(newCls2->findMethod(method->name()));
135135
}
136136

137-
static constexpr c10::string_view torchbindSrc = R"JIT(
137+
static constexpr std::string_view torchbindSrc = R"JIT(
138138
class FooBar1234(Module):
139139
__parameters__ = []
140140
f : __torch__.torch.classes._TorchScriptTesting._StackString

test/cpp/jit/test_class_parser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace torch {
77
namespace jit {
8-
constexpr c10::string_view testSource = R"JIT(
8+
constexpr std::string_view testSource = R"JIT(
99
class FooTest:
1010
def __init__(self, x):
1111
self.x = x

test/cpp/jit/test_interface.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def forward(self, x: Tensor) -> Tensor:
2323
return self.subMod.forward(x)
2424
)JIT";
2525

26-
static constexpr c10::string_view moduleInterfaceSrc = R"JIT(
26+
static constexpr std::string_view moduleInterfaceSrc = R"JIT(
2727
class OneForward(ModuleInterface):
2828
def one(self, x: Tensor, y: Tensor) -> Tensor:
2929
pass

test/cpp/jit/test_module_api.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
namespace torch {
1414
namespace jit {
1515

16-
static constexpr c10::string_view moduleInterfaceSrc = R"JIT(
16+
static constexpr std::string_view moduleInterfaceSrc = R"JIT(
1717
class OneInterface(ModuleInterface):
1818
def one(self, x: Tensor, y: Tensor) -> Tensor:
1919
pass

torch/csrc/jit/frontend/source_range.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ StringCordView::StringCordView() {
1414
}
1515

1616
StringCordView::StringCordView(
17-
std::vector<c10::string_view> inputs,
17+
std::vector<std::string_view> inputs,
1818
std::vector<std::shared_ptr<std::string>> ownerships)
1919
: pieces_(std::move(inputs)), owned_strings_(std::move(ownerships)) {
2020
accumulated_sizes_.push_back(0);
@@ -70,7 +70,7 @@ size_t StringCordView::find_regex(const std::string& tok, size_t start) const {
7070
}
7171

7272
StringCordView StringCordView::substr(size_t start, size_t size) const {
73-
std::vector<c10::string_view> pieces;
73+
std::vector<std::string_view> pieces;
7474
std::vector<std::shared_ptr<std::string>> ownerships;
7575
if (start >= this->size()) {
7676
// out of bounds

torch/csrc/jit/frontend/source_range.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct TORCH_API StringCordView {
2222
StringCordView(const StringCordView&) = default;
2323
StringCordView(StringCordView&&) noexcept = default;
2424
StringCordView(
25-
std::vector<c10::string_view> inputs,
25+
std::vector<std::string_view> inputs,
2626
std::vector<std::shared_ptr<std::string>> ownerships);
2727

2828
StringCordView& operator=(const StringCordView&) = default;
@@ -171,7 +171,7 @@ struct TORCH_API StringCordView {
171171
Iterator iter_for_pos(size_t pos) const;
172172

173173
private:
174-
std::vector<c10::string_view> pieces_;
174+
std::vector<std::string_view> pieces_;
175175
std::vector<size_t> accumulated_sizes_;
176176
std::vector<std::shared_ptr<std::string>> owned_strings_;
177177
};

torch/csrc/jit/frontend/tracer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,13 @@ void addInputs(
659659
const std::optional<at::Scalar>& value) {
660660
detail::genericAddOptionalInput(n, name, value);
661661
}
662-
void addInputs(Node* n, const char* name, const c10::string_view value) {
662+
void addInputs(Node* n, const char* name, const std::string_view value) {
663663
detail::genericAddInput(n, std::string(value));
664664
}
665665
void addInputs(
666666
Node* n,
667667
const char* name,
668-
const std::optional<c10::string_view>& value) {
668+
const std::optional<std::string_view>& value) {
669669
detail::genericAddOptionalInput(n, name, value);
670670
}
671671
void addInputs(Node* n, const char* name, const at::Tensor& value) {

torch/csrc/jit/frontend/tracer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,11 @@ TORCH_API void addInputs(
305305
TORCH_API void addInputs(
306306
Node* n,
307307
const char* name,
308-
const c10::string_view value);
308+
const std::string_view value);
309309
TORCH_API void addInputs(
310310
Node* n,
311311
const char* name,
312-
const std::optional<c10::string_view>& value);
312+
const std::optional<std::string_view>& value);
313313
TORCH_API void addInputs(Node* n, const char* name, at::Device value);
314314
TORCH_API void addInputs(Node* n, const char* name, c10::Stream stream);
315315
TORCH_API void addInputs(Node* n, const char* name, at::Layout value);

torch/csrc/jit/mobile/type_parser.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ TypePtr TypeParser::parse() {
182182
// ]
183183
// ]"
184184
TypePtr TypeParser::parseNamedTuple(const std::string& qualified_name) {
185-
std::vector<c10::string_view> field_names;
185+
std::vector<std::string_view> field_names;
186186
std::vector<TypePtr> field_types;
187187
expect(",");
188188
expect("[");
@@ -282,7 +282,7 @@ void TypeParser::expect(const char* s) {
282282
advance();
283283
}
284284

285-
// c10::string_view::operator== calls memcmp to compare against the target
285+
// std::string_view::operator== calls memcmp to compare against the target
286286
// string; we can do better if we specialize for a single character.
287287
void TypeParser::expectChar(char c) {
288288
std::string_view token = cur();

torch/csrc/jit/runtime/static/ops.cpp

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

0 commit comments

Comments
 (0)