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

When does OO syntax pass the Tensor as the resulting Tensor? #55

Open
xzhangcs opened this issue Aug 29, 2016 · 1 comment
Open

When does OO syntax pass the Tensor as the resulting Tensor? #55

xzhangcs opened this issue Aug 29, 2016 · 1 comment

Comments

@xzhangcs
Copy link

xzhangcs commented Aug 29, 2016

maths.md states:

"The Torch package adopts the same concept, so that calling a function directly on the Tensor itself using an object-oriented syntax is equivalent to passing the Tensor as the optional resulting Tensor. The following two calls are equivalent.

torch.log(x, x)
x:log()
"

However, this doesn't always seem to be the case. For example, if we call

x:cat(y), x.reshape(2,3), x:t()

then x does NOT change after the call. In particular, I can't see why x:add(y) changes x, while x:cat(y) doesn't.

So is there any rule on when a tensor will be changed by calling on itself in OO syntax? Thanks.

@soumith
Copy link
Member

soumith commented Aug 29, 2016

the three functions you listed, i.e. cat, reshape and t do not have an in-place mode, and return a new tensor (their documentation should cover that detail).

There is unfortunately no rule.

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

2 participants