Use std::string_view in tests (#146120)

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/146120
Approved by: https://github.com/albanD
This commit is contained in:
cyy 2025-02-04 09:51:36 +00:00 committed by PyTorch MergeBot
parent 8444fe019a
commit 3f63f2bced
2 changed files with 4 additions and 4 deletions

View file

@ -283,9 +283,9 @@ struct EValue {
return tag == Tag::String;
}
at::string_view toString() const {
std::string_view toString() const {
ET_CHECK_MSG(isString(), "EValue is not a String.");
return at::string_view(
return std::string_view(
payload.copyable_union.as_string.data(),
payload.copyable_union.as_string.size());
}
@ -452,7 +452,7 @@ EVALUE_DEFINE_TO(at::Scalar, toScalar)
EVALUE_DEFINE_TO(int64_t, toInt)
EVALUE_DEFINE_TO(bool, toBool)
EVALUE_DEFINE_TO(double, toDouble)
EVALUE_DEFINE_TO(at::string_view, toString)
EVALUE_DEFINE_TO(std::string_view, toString)
EVALUE_DEFINE_TO(at::ScalarType, toScalarType)
EVALUE_DEFINE_TO(at::MemoryFormat, toMemoryFormat)
EVALUE_DEFINE_TO(std::optional<at::Tensor>, toOptional<at::Tensor>)

View file

@ -689,7 +689,7 @@ def generate_tensor_like_override_tests(cls):
return torch.float32
elif arg_type == "c10::string_view":
return ""
elif arg_type == "std::string_view":
elif arg_type in ("std::string_view", "::std::string_view"):
return ""
elif arg_type == "SymInt":
# TODO: generate actual SymbolicInt