Skip to content
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

Make memory allocation macros windows-compatible #4071

Closed
wants to merge 1 commit into from

Conversation

dvorjackz
Copy link
Contributor

@dvorjackz dvorjackz commented Jun 26, 2024

Summary:
Make ET_TRY_ALLOCATE_OR, ET_TRY_ALLOCATE_INSTANCE_OR, and ET_TRY_ALLOCATE_LIST_OR raise static assertion errors at compile time when compiled with statement expression-incompatible compilers (namely MSVC, among others).

The recommended alternative is to eschew the above macros in favor of directly allocating the memory, as hinted by the assertion comments.

The memory_allocator_test.cpp now only tests the macros if compiled using GCC 3.0+/Clang (statement expression-compatible). This is for backwards compatibility temporarily. Eventually the goal is remove all call-sites of ET_TRY_ALLOCATE_OR, ET_TRY_ALLOCATE_INSTANCE_OR, and ET_TRY_ALLOCATE_LIST_OR yet.

Differential Revision: D58850316

Copy link

pytorch-bot bot commented Jun 26, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit 5c67c77 with merge base 929fc80 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 26, 2024
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 26, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

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

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

dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 26, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

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

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

dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 27, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

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

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

dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 27, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

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

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

dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 27, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

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

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

dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 27, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

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

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

dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 27, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

Differential Revision: D58850316
dvorjackz added a commit to dvorjackz/executorch that referenced this pull request Jun 28, 2024
Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

Reviewed By: dbort

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

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

Summary:
Pull Request resolved: pytorch#4071

Make windows-compatible versions of memory allocation macros `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR` by using lambda functions. Previously the preprocessing did not work because the windows compiler does not support expression statements. Keep the original implementations to maintain compatibility with other call-sites, which will eventually be refactored.

Then refactor the `memory_allocator_test.cpp` to migrate away from using `ET_TRY_ALLOCATE_OR`, `ET_TRY_ALLOCATE_INSTANCE_OR`, and `ET_TRY_ALLOCATE_LIST_OR`.

Reviewed By: dbort

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

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

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 748a4f8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants