Skip to content

Difference to numpy linspace with endpoint False #58129

@jumlauft

Description

@jumlauft

🐛 Bug

I am trying to reproduce np.linspace() with endpoint=False with torch.linspace() but end up with numerical differences.

To Reproduce

np.linspace(0, 1, 10, endpoint=False) - torch.linspace(0, 1, 10+1).numpy()[:-1]

Expected behavior

I expect the difference to be zero and not around 10e-8.
It would be usefule to also have a endpoint argument in pytorch

Environment

  • PyTorch Version (e.g., 1.0):1.8.1+cu111
  • OS (e.g., Linux): LInux
  • How you installed PyTorch (conda, pip, source): pip
  • Build command you used (if compiling from source):
  • Python version: 3.8
  • CUDA/cuDNN version:11.1

cc @mruberry @rgommers @heitorschueroff @gchanan

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA request for a proper, new feature.module: numpyRelated to numpy support, and also numpy compatibility of our operatorsmodule: tensor creationtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions