Skip to content

FloatTensor type hint is incompatible with Tensor #7535

@tianze0926

Description

@tianze0926

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions