Fix two error messages involving Tensor.dense() (#152631)

Two error messages in the codebase instruct the user to use `Tendor.dense()`. This method doesn't exist, but `Tensor.to_dense()` does, and this is what the user should be using instead.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/152631
Approved by: https://github.com/jansel
This commit is contained in:
Matthijs Hogervorst 2025-05-04 20:44:04 +00:00 committed by PyTorch MergeBot
parent 220870ce9e
commit b117a6c47b
2 changed files with 2 additions and 2 deletions

View File

@ -822,7 +822,7 @@ class TensorVariable(VariableTracker):
unimplemented("Tensor.numpy(). NumPy is not available")
if self.layout != torch.strided:
raise TypeError(
f"can't convert {self.layout} layout tensor to numpy. Use Tensor.dense() first"
f"can't convert {self.layout} layout tensor to numpy. Use Tensor.to_dense() first"
)
from ..symbolic_convert import InstructionTranslator

View File

@ -132,7 +132,7 @@ PyObject* tensor_to_numpy(const at::Tensor& tensor, bool force /*=false*/) {
"can't convert ",
c10::str(tensor.layout()).c_str(),
" layout tensor to numpy. ",
"Use Tensor.dense() first.");
"Use Tensor.to_dense() first.");
if (!force) {
TORCH_CHECK_TYPE(