Suppress warning: calling a constexpr __host__ function from a __host__ __device__ function is not allowed warning#49197
Closed
r-barnes wants to merge 1 commit intopytorch:masterfrom
Closed
Conversation
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D25440771 |
af5fd18 to
0e8908d
Compare
…t__ __device__ function is not allowed` warning (pytorch#49197) Summary: Pull Request resolved: pytorch#49197 Compiling currently gives a number of these warnings: ``` caffe2/c10/util/TypeCast.h(27): warning: calling a constexpr __host__ function from a __host__ __device__ function is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this. detected during: instantiation of "decltype(auto) c10::maybe_real<true, src_t>::apply(src_t) [with src_t=c10::complex<double>]" (57): here instantiation of "uint8_t c10::static_cast_with_inter_type<uint8_t, src_t>::apply(src_t) [with src_t=c10::complex<double>]" (157): here instantiation of "To c10::convert<To,From>(From) [with To=uint8_t, From=c10::complex<double>]" (169): here instantiation of "To c10::checked_convert<To,From>(From, const char *) [with To=uint8_t, From=c10::complex<double>]" caffe2/c10/co ``` Here we fix this by adding `C10_HOST_DEVICE` to the offending function. Test Plan: Compiling ``` buck build mode/dev-nosan -c=python.package_style=inplace dper3/dper3_models/experimental/pytorch/ads:ads_model_generation_script ``` shows this warning. We rely on sandcastle for testing here. Reviewed By: xw285cornell Differential Revision: D25440771 fbshipit-source-id: c5a75ea1d9dd512d4e3a0c77353e3a9a74131616
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D25440771 |
0e8908d to
a95a999
Compare
Contributor
|
This pull request has been merged in 1133428. |
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
…t__ __device__ function is not allowed` warning (pytorch#49197) Summary: Pull Request resolved: pytorch#49197 Compiling currently gives a number of these warnings: ``` caffe2/c10/util/TypeCast.h(27): warning: calling a constexpr __host__ function from a __host__ __device__ function is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this. detected during: instantiation of "decltype(auto) c10::maybe_real<true, src_t>::apply(src_t) [with src_t=c10::complex<double>]" (57): here instantiation of "uint8_t c10::static_cast_with_inter_type<uint8_t, src_t>::apply(src_t) [with src_t=c10::complex<double>]" (157): here instantiation of "To c10::convert<To,From>(From) [with To=uint8_t, From=c10::complex<double>]" (169): here instantiation of "To c10::checked_convert<To,From>(From, const char *) [with To=uint8_t, From=c10::complex<double>]" caffe2/c10/co ``` Here we fix this by adding `C10_HOST_DEVICE` to the offending function. Test Plan: Compiling ``` buck build mode/dev-nosan -c=python.package_style=inplace dper3/dper3_models/experimental/pytorch/ads:ads_model_generation_script ``` shows this warning. We rely on sandcastle for testing here. Reviewed By: xw285cornell Differential Revision: D25440771 fbshipit-source-id: 876c412eb06e8837978061cc4793abda42fac821
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Compiling currently gives a number of these warnings:
Here, we take the compiler up on its suggestion and use the
--expt-relaxed-constexprflag.As noted here either
#pragma nv_exec_check_disableor#pragma hd_warning_disablecould also be used. This would have less over-all impact on the code (since using the flag applies to all files touched by NVCC within this target); however, their effects are not as well documented asconstexpr.Test Plan:
Compiling
shows this warning.
We rely on sandcastle for testing here.
Reviewed By: xw285cornell
Differential Revision: D25440771