Skip to content

Tensor.to(Tensor) doesn't change dtype of Tensor. #653

Closed

Description

@kaiidams

PyTorch outputs torch.float64

import torch
x = torch.linspace(0, 1, 100, dtype=torch.float32)
y = torch.linspace(0, 1, 100, dtype=torch.float64)
x.to(y).dtype

TorchSharp (8005af9) outputs Float32.

// commit 8005af93ef3ebf66f3b246a4ccbe4ba791f7f9f9
using TorchSharp;
var x = torch.linspace(0, 1, 100, dtype: torch.float32);
var y = torch.linspace(0, 1, 100, dtype: torch.float64);
x.to(y).dtype

Activity

  1. kaiidams commented on Jul 12, 2022

    @kaiidams
    ContributorAuthor

    TorchSharp provides Tensor.type_as(Tensor) to change Tensor.dtype, however, this difference from PyTorch is confusing when poirting from PyTorch. Also in many case, to() is used to apply operators to two tensors where dtype and device of them need to be compatible.

  2. NiklasGustafsson commented on Jul 20, 2022

    @NiklasGustafsson

    @kaiidams -- this will be fixed in the next release (which I will release today).

  3. added a commit that references this issue on Jul 20, 2022
  4. linked a pull request that will close this issueIssue #653 #659on Jul 20, 2022
  5. added a commit that references this issue on Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions