-
Notifications
You must be signed in to change notification settings - Fork 25.9k
Open
Labels
module: cppRelated to C++ APIRelated to C++ APImodule: printingIssues related to the printing format of tensorsIssues related to the printing format of tensorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
In Python, we have the following tensor print behavior:
>>> x=torch.ones(2, 2, requires_grad=True)
>>> x
tensor([[1., 1.],
[1., 1.]], requires_grad=True)
>>> y=x*2
>>> y
tensor([[2., 2.],
[2., 2.]], grad_fn=<MulBackward0>)However in C++, we have the following behavior:
auto x = torch::ones({2, 2}, torch::requires_grad());
std::cout << x << std::endl;
auto y = x * 2;
std::cout << y << std::endl; 1 1
1 1
[ CPUFloatType{2,2} ]
2 2
2 2
[ CPUFloatType{2,2} ]It would be nice to show requires_grad and grad_fn in C++ tensor print as well.
cc @yf225
Metadata
Metadata
Assignees
Labels
module: cppRelated to C++ APIRelated to C++ APImodule: printingIssues related to the printing format of tensorsIssues related to the printing format of tensorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module