diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

FloatTensor type hint is incompatible with Tensor

Open tianze0926 opened this issue 1 year ago • 3 comments

Describe the bug

At present, the torch.FloatTensor type hint is commonly employed in the codebase. However, if one were to pass a torch.Tensor, Pyright would raise complaints about the inconsistency between these two types. Furthermore, based on information from this thread, it appears that torch.FloatTensor has been deprecated.

Reproduction

import torch
from diffusers.schedulers.scheduling_ddim import DDIMScheduler

scheduler = DDIMScheduler()
a = torch.randn(1, 3, 64, 64)
scheduler.scale_model_input(a)

Output of Pyright:

$ pyright test.py
test.py
  test.py:6:29 - error: Argument of type "Tensor" cannot be assigned to parameter "sample" of type "FloatTensor" in function "scale_model_input"
  __"Tensor" is incompatible with "FloatTensor" (reportArgumentType)
1 error, 0 warnings, 0 informations

Logs

No response

System Info

  • pyright version: 1.1.356
  • diffusers version: 0.27.2
  • Platform: Linux-5.4.210-4-velinux1-amd64-x86_64-with-glibc2.31
  • Python version: 3.12.2
  • PyTorch version (GPU?): 2.2.1 (True)
  • Huggingface_hub version: 0.22.0
  • Transformers version: not installed
  • Accelerate version: 0.28.0
  • xFormers version: not installed
  • Using GPU in script?: no
  • Using distributed or parallel set-up in script?: no

Who can help?

No response

tianze0926 avatar Mar 31 '24 15:03 tianze0926

Thanks for flagging @tianze0926 I think we can update the hints. Would you like to open a PR for it?

DN6 avatar Apr 01 '24 13:04 DN6

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar May 01 '24 15:05 github-actions[bot]

I'm working on this if that's cool

vanakema avatar May 07 '24 21:05 vanakema