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 occurred while passing Empty-Vectors as parameters #311

Open
Liuqh12 opened this issue Jun 5, 2024 · 0 comments
Open

Error occurred while passing Empty-Vectors as parameters #311

Liuqh12 opened this issue Jun 5, 2024 · 0 comments

Comments

@Liuqh12
Copy link

Liuqh12 commented Jun 5, 2024

Version
torchinfo==1.8.0

Above all
Empty-Vectors mean:

ev = torch.rand([])

which:

ev.shape=torch.Size([])
type(ev)=torch.Tensor

To Reproduce

from diffusers import StableDiffusionPipeline
import torch
from torchinfo import summary

pipe =  StableDiffusionPipeline.from_pretrained('runwayml/stable-diffusion-v1-5', torch_dtype=torch.float16)
unet = pipe.unet
# way 1:
summary(model=unet, input_size= [ [2, 4, 64, 64], [], [2, 77, 768] ], dtypes=[torch.FloatTensor, torch.Tensor, torch.Tensor])

#way 2:
s = torch.rand([2, 4, 64, 64])
t = torch.rand([])
e = torch.rand([2, 77, 768])

summary(model=unet, input_data={'sample':s, 'timestep':t, 'encoder_hidden_states':e}, depth=5)

Outputs:

For way 1:

Traceback (most recent call last):
  File "c:\liuqh12\ss\standard_pipe.py", line 23, in <module>
    summary(model=model, input_size= [ [2, 4, 64, 64], [], [2, 77, 768] ], dtypes=[torch.FloatTensor, torch.Tensor, torch.Tensor])
  File "C:\Users\miniconda3\envs\ss\lib\site-packages\torchinfo\torchinfo.py", line 220, in summary
    x, correct_input_size = process_input(
  File "C:\Users\miniconda3\envs\ss\lib\site-packages\torchinfo\torchinfo.py", line 256, in process_input
    x = get_input_tensor(correct_input_size, batch_dim, dtypes, device)
  File "C:\Users\miniconda3\envs\ss\lib\site-packages\torchinfo\torchinfo.py", line 529, in get_input_tensor
    input_tensor = torch.rand(*size)
TypeError: rand() received an invalid combination of arguments - got (), but expected one of:
 * (tuple of ints size, *, torch.Generator generator, tuple of names names, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
 * (tuple of ints size, *, torch.Generator generator, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
 * (tuple of ints size, *, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)
 * (tuple of ints size, *, tuple of names names, torch.dtype dtype, torch.layout layout, torch.device device, bool pin_memory, bool requires_grad)

For way2:

Traceback (most recent call last):
  File "c:\liuqh12\ss\standard_pipe.py", line 24, in <module>
    summary(model=model, input_data={'sample':s, 'timestep':t, 'encoder_hidden_states':e}, depth=5)
  File "C:\Users\miniconda3\envs\ss\lib\site-packages\torchinfo\torchinfo.py", line 223, in summary
    summary_list = forward_pass(
  File "C:\Users\miniconda3\envs\ss\lib\site-packages\torchinfo\torchinfo.py", line 304, in forward_pass
    raise RuntimeError(
RuntimeError: Failed to run torchinfo. See above stack traces for more details. Executed layers up to: [Timesteps: 1]

May I skip some usage detail?
thanks

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

1 participant