Skip to content

Commit

Permalink
Address torch.tensor warnings in derivative sensitivity measures (#2378)
Browse files Browse the repository at this point in the history
Summary:
Eliminates 5 instances of the following warning in tests:
```
UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
```

Pull Request resolved: #2378

Reviewed By: Balandat

Differential Revision: D56314211

Pulled By: saitcakmak

fbshipit-source-id: 6466a55f61dd60085896c4bcd27b8ddacb8cd933
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Apr 18, 2024
1 parent 1ee617d commit eef87a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ax/utils/sensitivity/derivative_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def gradient_measure(self) -> torch.Tensor:
else
Tensor: (values) x dim
"""
return self.aggregation(torch.tensor)
return self.aggregation(torch.as_tensor)

def gradient_absolute_measure(self) -> torch.Tensor:
r"""Computes the gradient absolute measure:
Expand Down

0 comments on commit eef87a0

Please sign in to comment.