Skip to content

It is necessary to add this flag for compilation on Windows - #45

Open
bburrough wants to merge 1 commit into
NVlabs:mainfrom
bburrough:main
Open

bburrough wants to merge 1 commit into
NVlabs:mainfrom
bburrough:main

Conversation

@bburrough

Copy link
Copy Markdown

filtered_lrelu.cpp uses "if constexpr" which is c++17, and will otherwise fail with the following error.

filtered_lrelu.cpp(147): error C4984: 'if constexpr' is a C++17 language extension

Please note, I have not tested this on other platforms (e.g. Ubuntu), where this flag might be inappropriate.

…e, as filtered_lrelu.cpp uses "if constexpr" which is c++17, and will otherwise fail with the following error.

filtered_lrelu.cpp(147): error C4984: 'if constexpr' is a C++17 language extension
@bburrough

Copy link
Copy Markdown
Author

If you don't wish to adopt this flag, you might alternatively consider removing "if constexpr" for greater portability.

@PDillis

PDillis commented Nov 22, 2021

Copy link
Copy Markdown

I just tested this on Ubuntu 20.04 and it works, so the flag could be added in general to benefit Windows users.

PDillis referenced this pull request in PDillis/stylegan3-fun Nov 23, 2021
@PDillis

PDillis commented Nov 25, 2021

Copy link
Copy Markdown

Actually, I just tested it again with another code (random interpolation in particular), and it fails. I recommend adding a os check as follows:

def _init():
    global _plugin
    # Bob Burrough's PR (#45) so that the plugins work in Windows: https://github.com/NVlabs/stylegan3/pull/45
    extras = {}
    if os.name == 'nt':
        extras['extra_cflags'] = ['/std:c++17']
    if _plugin is None:
        _plugin = custom_ops.get_plugin(
            module_name='filtered_lrelu_plugin',
            sources=['filtered_lrelu.cpp', 'filtered_lrelu_wr.cu', 'filtered_lrelu_rd.cu', 'filtered_lrelu_ns.cu'],
            headers=['filtered_lrelu.h', 'filtered_lrelu.cu'],
            source_dir=os.path.dirname(__file__),
            extra_cuda_cflags=['--use_fast_math'],
            **extras,
        )
    return True

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants