Skip to content

Conversation

xuhancn
Copy link
Collaborator

@xuhancn xuhancn commented Jul 31, 2024

This PR fix the UndefinedTensorImpl::_singleton can't export on Windows issue.
Snapshot:
image

The reason is MSVC can't export class static data to external linkage, ref: https://learn.microsoft.com/en-us/cpp/cpp/using-dllimport-and-dllexport-in-cpp-classes?view=msvc-170#_pluslang_using_dllimport_and_dllexport_in_c2b2bselectivememberimportexport

I use another singleton implenmentation to avoid the issue, for Windows.

Since this PR, cpp_wrapper on Windows would start to work.
image

Next step, I will enable the cpp_wrapper UTs.

cc @peterjc123 @mszhanyi @skyline75489 @nbcsm @iremyux @Blackhex @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @voznesenskym @penguinwu @EikanWang @Guobing-Chen @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @ColinPeppler @amjames @desertfire @chauhang

Copy link

pytorch-bot bot commented Jul 31, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 460143f with merge base 39a3c98 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@xuhancn xuhancn added module: windows Windows support for PyTorch ciflow/trunk Trigger trunk jobs on your pull request intel This tag is for PR from Intel module: inductor labels Jul 31, 2024
@xuhancn xuhancn added the topic: not user facing topic category label Jul 31, 2024
@xuhancn xuhancn marked this pull request as ready for review July 31, 2024 22:41
@xuhancn xuhancn requested a review from jgong5 July 31, 2024 22:41
@xuhancn xuhancn changed the title fix UndefinedTensorImpl singleton can't export on Windows. [inductor] fix UndefinedTensorImpl singleton can't export on Windows. Jul 31, 2024
Copy link
Collaborator

@jgong5 jgong5 left a comment

Choose a reason for hiding this comment

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

Can we do getInstance() regardless of whether it is MSVC build or not?

@xuhancn
Copy link
Collaborator Author

xuhancn commented Aug 1, 2024

Can we do getInstance() regardless of whether it is MSVC build or not?

460143f getInstance() will fail with constexpr on non-Windows OS.

@xuhancn xuhancn requested review from desertfire, jansel and jgong5 August 1, 2024 01:07
@desertfire
Copy link
Contributor

The doc you linked suggests using dllexport (C10_EXPORT in PyTorch) would solve the problem. Have you tried that?

@xuhancn
Copy link
Collaborator Author

xuhancn commented Aug 1, 2024

The doc you linked suggests using dllexport (C10_EXPORT in PyTorch) would solve the problem. Have you tried that?

@desertfire
I tried the C10_EXPORT for the variable, and It doesn't work, I checked with dumpbin, and confirmed. class static variable is not exported by C10_EXPORT.
image

@xuhancn
Copy link
Collaborator Author

xuhancn commented Aug 1, 2024

@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 intel This tag is for PR from Intel Merged module: inductor module: windows Windows support for PyTorch open source topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants