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

Code Contains Unreachable Sections #293

Open
lordsoffallen opened this issue Aug 19, 2024 · 3 comments
Open

Code Contains Unreachable Sections #293

lordsoffallen opened this issue Aug 19, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@lordsoffallen
Copy link

Hi,

https://github.com/myshell-ai/OpenVoice/blob/main/openvoice/modules.py#L583 is unreachable due to if else statement above, is this a bug or it is intended?

Copy link

dosubot bot commented Aug 19, 2024

Hey @lordsoffallen! I'm here to assist you with any issues or questions you have in the OpenVoice repository. I can help you solve bugs, answer questions, and even guide you on becoming a contributor. Just let me know how I can assist you!

The code at line 583 in modules.py is part of a conditional structure within the ResidualCouplingLayer class. The if-else conditions leading up to this line determine whether the forward or inverse transformation is applied based on the reverse parameter. Here is the relevant code snippet:

if not reverse:
    x1 = m + x1 * torch.exp(logs) * x_mask
    x = torch.cat([x0, x1], 1)
    logdet = torch.sum(logs, [1, 2])
    return x, logdet
else:
    x1 = (x1 - m) * torch.exp(-logs) * x_mask
    x = torch.cat([x0, x1], 1)
    return x

The code at line 583 is part of the else block, which is executed when reverse is True. This means that the code is not unreachable; it is executed when the reverse parameter is set to True. This behavior is intended and not a bug [1].

The reverse parameter is used to determine the direction of the transformation. When reverse is False, the forward transformation is applied, and when reverse is True, the inverse transformation is applied [1].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the bug Something isn't working label Aug 19, 2024
@lordsoffallen
Copy link
Author

@dosu code at line 583 isn't part of else statement which is the issue. The if else statement you shared ends the function and the code afterwards don't get executed.

Copy link

dosubot bot commented Aug 19, 2024

The code at line 583 in modules.py is indeed unreachable because the preceding if-else statement ends the function. Specifically, the return statements within the if-else block ensure that the function exits before reaching line 583.

Here is the relevant part of the code:

if not reverse:
    return x, logdet
else:
    return x

Since both branches of the if-else statement contain a return statement, the function will exit and the code at line 583 will never be executed [1].

To continue talking to Dosu, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant