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

ERROR with ReLU, inplace_unfold cause the bad shape. #73

Open
charnameRed opened this issue Jun 18, 2024 · 2 comments
Open

ERROR with ReLU, inplace_unfold cause the bad shape. #73

charnameRed opened this issue Jun 18, 2024 · 2 comments

Comments

@charnameRed
Copy link

charnameRed commented Jun 18, 2024

Describe the bug
I tried to use auto_LiRPA to verify the robustness of my audio processing model. Unfortunately, when I use model.compute_bounds, a RuntimeError: The following operation failed in the TorchScript interpreter. occurred.

The situation directly caused by the unfitted shape of A_pos([64, 4, 25, 20, 64, 9, 9]) and d_pos([1, 4, 24, 19, 64, 9, 9]) in A_new = d_pos * A_pos + d_neg * A_neg, which happens during clamp_mutiply_forward operation. I tried to trace back the cause of this difference, and find something happened in the inplace_unfold step of maybe_unfold_patches, in the relu.py.

Here follows my code. I make a emulation dataset to provide random data with the same attributes of real data, which are Mel Spectrograms of some audio, to avoid unnecessary uploadings. And I used an adjusted Resnet18 to extract the features, to make it work correctly on [B, 1, 100, 80] shaped data.

To Reproduce

Test Code
Adjusted Resnet

System configuration:

  • OS: Ubuntu 22.04
  • Python version: Python 3.10
  • Pytorch Version: Pytorch 2.2
  • Hardware: RTX 4090
  • Have you tried to reproduce the problem in a cleanly created conda/virtualenv environment using official installation instructions and the latest code on the main branch?: Yes
@shizhouxing
Copy link
Member

Hi @charnameRed, could you please post your complete error message?

@charnameRed
Copy link
Author

THX for replying. The error message is as follows:

The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
  File "/home/cnred/anaconda3/envs/realForen/lib/python3.11/site-packages/auto_LiRPA/operators/clampmult.py", line 44, in <fused code>
            A_new = d_pos * A
        else:  
            A_new = d_pos * A_pos + d_neg * A_neg
                    ~~~~~~~~~~~~~ <--- HERE
        
        bias_pos = bias_neg = torch.zeros(
RuntimeError: The size of tensor a (19) must match the size of tensor b (20) at non-singleton dimension 3

  File "/home/cnred/projects/RealForensics/stage2/chR/test.py", line 87, in <module>
    lb_a,ub_a = a_submodel.compute_bounds(x=(aud_ptbd,))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript (most recent call last):
  File "/home/cnred/anaconda3/envs/realForen/lib/python3.11/site-packages/auto_LiRPA/operators/clampmult.py", line 44, in <fused code>
            A_new = d_pos * A
        else:  
            A_new = d_pos * A_pos + d_neg * A_neg
                    ~~~~~~~~~~~~~ <--- HERE
        
        bias_pos = bias_neg = torch.zeros(
RuntimeError: The size of tensor a (19) must match the size of tensor b (20) at non-singleton dimension 3

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

No branches or pull requests

2 participants