-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[jit] Add string index/slice operations #18247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds support for string indexing (`"a"[0]`) and slicing (`"abc"[1:3]`) to script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driazati has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
torch/csrc/jit/register_prim_ops.cpp
Outdated
| } | ||
|
|
||
| std::string result; | ||
| result.insert(result.begin(), string.begin() + start, string.begin() + end); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need an extra insert(), just use the constructor e.g. std::string result(string, start, end-start)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driazati is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
| {"max", std::make_shared<BuiltinFunction>(prim::max, at::nullopt)}, | ||
| {"list", std::make_shared<BuiltinFunction>(aten::list, at::nullopt)}, | ||
| {"ord", std::make_shared<BuiltinFunction>(aten::ord, at::nullopt)}, | ||
| {"rangelist", std::make_shared<BuiltinFunction>(prim::rangelist, at::nullopt)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: is this line a duplicate of the line below?
Summary: Adds support for string indexing (`"a"[0]`) and slicing (`"abc"[1:3]`) to script. Pull Request resolved: pytorch/pytorch#18247 Differential Revision: D14574486 Pulled By: driazati fbshipit-source-id: 4b42aa0881e5398ea7f112be46c0335e6e19dced
Adds support for string indexing (
"a"[0]) and slicing ("abc"[1:3])to script.