-
Notifications
You must be signed in to change notification settings - Fork 89
Switch to fmt:string for precision #1203
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
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/meta-pytorch/torchcodec/1203
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4ffb47f with merge base dea4e93 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
src/torchcodec/_core/CMakeLists.txt
Outdated
| find_package(Python3 ${PYTHON_VERSION} EXACT COMPONENTS Development) | ||
|
|
||
| # Fetch fmt library for high-precision string formatting | ||
| include(FetchContent) |
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.
Would FetchContent + setting CMAKE_POSITION_INDEPENDENT_CODE be the best approach for linking fmt? An alternative is we could just use fmt::fmt-header-only
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.
It looks like pytorch/pytorch uses fmt-header-only.
Another concern is that we are hardcoding this URL and version of the fmt library, so we would have to handle updates to this third party library as pytorch/pytorch does.
I'm not sure what the best way to handle this is, @NicolasHug any thoughts?
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.
Yeah we should be using whatever pytorch uses. I think we might be able to just rely on the headers that torch itself is shipping:
~/dev/torchcodec (rotation*) » find /home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/args.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/base.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/chrono.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/color.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/compile.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/core.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/format-inl.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/format.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/os.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/ostream.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/printf.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/ranges.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/std.h
/home/nicolashug/miniconda3/envs/codec/lib/python3.11/site-packages/torch/include/fmt/xchar.h
(sorry if this is a bit cryptic, I'll try to share more details tomorrow but that might unblock you for the time being)
|
But to make the reproducing example pass,
Please double check me on this! |
NicolasHug
left a comment
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.
Thanks a lot @mollyxu , and thanks @Dan-Flores for cross-checking with #1200 ! I agree we can merge this in favor of #1200 since it's quite a bit simpler.
LGTM but let's wait on @Dan-Flores to make a final pass.
We have a fair amount of uses of std::to_string in the rest of the codebase. I think we should just use fmt::to_string everywhere? This could be a follow-up PR!
Dan-Flores
left a comment
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.
Please check if the change to test/CMakeLists.txt is necessary, after that LGTM!
Co-authored-by: Nicolas Hug <[email protected]>
Preserve precision for double to string conversions by using
fmt::to_string()instead ofstring::to_string()Note: some tests are edited to match the behavior of
fmt::to_string()instead ofstring::to_string()