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

requiresGrad lost when creating tensors from scalars or sequences #80

Open
marcelluethi opened this issue Dec 22, 2024 · 0 comments
Open

Comments

@marcelluethi
Copy link
Contributor

marcelluethi commented Dec 22, 2024

Hello

I just stumbled upon the following problem. When creating a tensor from a scalar or sequence, with requiresGrad=true, the value of the argument is lost. The following code exposes the problem

  val x = Tensor(Seq(1.0f), requiresGrad = true)
  assert(x.requiresGrad == true)

Setting the parameter explicitly with x.requiresGrad(true) works.

I looked into the problem but could not spot anything wrong. It seems to get lost in this line

The problem persists when using the latest pytorch version (2.5.1). Does anybody know what could be the problem?

@marcelluethi marcelluethi changed the title requiresGrad lost when creating Tensors from Scalars of Sequences requiresGrad lost when creating tensors from scalars or sequences Dec 22, 2024
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