Skip to content

[nativert] Port string join and split to c10/util#152873

Closed
yiming0416 wants to merge 1 commit intopytorch:mainfrom
yiming0416:export-D74202473
Closed

[nativert] Port string join and split to c10/util#152873
yiming0416 wants to merge 1 commit intopytorch:mainfrom
yiming0416:export-D74202473

Conversation

@yiming0416
Copy link
Contributor

@yiming0416 yiming0416 commented May 5, 2025

Summary:
Torch Native Runtime RFC: pytorch/rfcs#72
Port string utils functions join and split to c10/util

Test Plan:
Added tests in string_util_test.cpp
buck2 run mode/opt caffe2/c10/test:util_base_tests

Differential Revision: D74202473

@pytorch-bot
Copy link

pytorch-bot bot commented May 5, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/152873

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 59cdec9 with merge base 7a0781e (image):

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74202473


C10_API std::string join(
std::string_view delimiter,
const std::vector<std::string>& keys);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to use std::vector<std::string_view>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyyever well maybe... but for usability, we have existing internal usage of this function with std::vector<std::string> as the argument type, it might be a bit clunky to convert the input types. So I'd prefer to keep the current signature if this is not a blocking comment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 6, 2025
@cyyever
Copy link
Collaborator

cyyever commented May 6, 2025

@yiming0416 If there are more string functions coming, we should consider ranges.

return atoms;
}

std::string join(
Copy link
Collaborator

@Skylion007 Skylion007 May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C10::str already implements a join method. Also for other code, just use fmt::join. It is more performant FYI and doesn't require any C10 dependency.

@albanD albanD removed their request for review May 6, 2025 13:44
Summary:
Pull Request resolved: pytorch#152873

Port string utils functions join and split to c10/util

Test Plan:
Added tests in `string_util_test.cpp`
buck2 run mode/opt caffe2/c10/test:util_base_tests

Differential Revision: D74202473
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D74202473

@yiming0416
Copy link
Contributor Author

Removed the newly added join() as it can be replaced by fmt::join()

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / cuda12.4-py3.10-gcc9-sm80 / build

Details for Dev Infra team Raised by workflow job

@huydhn
Copy link
Contributor

huydhn commented May 7, 2025

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request fb-exported Merged topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants