You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, I find the pros of matmul() with out parameter is that the result is displayed with one line of code different from matmul() without out parameter which are two lines of code using IPython, Jupyter Notebook, Google Colab, etc as shown below:
importtorchtensor1=torch.tensor([0, 1, 2])
tensor2=torch.tensor([3, 4, 5])
new_tensor=torch.tensor(0)
# One line of codetorch.matmul(input=tensor1, other=tensor2, out=new_tensor) # tensor(14)# Two lines of codenew_tensor=torch.matmul(input=tensor1, other=tensor2)
new_tensor# tensor(14)
About out parameter of functions in PyTorch:
Pros:
Less lines of code.
Cons:
People will write either of 2 ways(with or without out parameter) so it breaks the consistency of how people write code so such a code is less readable, less efficient and less productive which is seriously bad.
It makes PyTorch documentation complicated (I mean It is not simple because of out parameter.).
So, I think out parameter has more disadvantages than advantages so out parameter should be removed to simplify the functions and the documentation.
Alternatives
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
馃殌 The feature, motivation and pitch
In PyTorch, there is
out
parameter in many functions like matmul(), rand(), arrange().For example, I find the pros of
matmul()
without
parameter is that the result is displayed with one line of code different frommatmul()
withoutout
parameter which are two lines of code using IPython, Jupyter Notebook, Google Colab, etc as shown below:About
out
parameter of functions in PyTorch:Pros:
Cons:
out
parameter) so it breaks the consistency of how people write code so such a code is less readable, less efficient and less productive which is seriously bad.out
parameter.).So, I think
out
parameter has more disadvantages than advantages soout
parameter should be removed to simplify the functions and the documentation.Alternatives
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: